3.2 KiB
3.2 KiB
MQTT Example
This is nRF24L01 and MQTT gateway application.
+----------+ +----------+ +----------+ +----------+
| | | | | | | |
|Publisher |--(MQTT)-->| Broker |--(MQTT)-->| ESP32 |--(SPI)--->| nRF24L01 |==(Radio)==>
| | | | | | | |
+----------+ +----------+ +----------+ +----------+
+----------+ +----------+ +----------+ +----------+
| | | | | | | |
==(Radio)==>| nRF24L01 |--(SPI)--->| ESP32 |--(MQTT)-->| Broker |--(MQTT)-->|Subscriber|
| | | | | | | |
+----------+ +----------+ +----------+ +----------+
Configuration
WiFi Setting
Radioi Setting
MQTT to Radio
Subscribe with MQTT and send to Radio.
You can use mosquitto_pub as Publisher.
sh ./mqtt_pub.sh
+----------+ +----------+ +----------+ +----------+
| | | | | | | |
|Publisher |--(MQTT)-->| Broker |--(MQTT)-->| ESP32 |--(SPI)--->| nRF24L01 |==(Radio)==>
| | | | | | | |
+----------+ +----------+ +----------+ +----------+
Radio to MQTT
Receive from Radio and publish as MQTT.
You can use mosquitto_sub as Subscriber.
sh ./mqtt_sub.sh
+----------+ +----------+ +----------+ +----------+
| | | | | | | |
==(Radio)==>| nRF24L01 |--(SPI)--->| ESP32 |--(MQTT)-->| Broker |--(MQTT)-->|Subscriber|
| | | | | | | |
+----------+ +----------+ +----------+ +----------+
Specifying an MQTT Broker
You can specify your MQTT broker in one of the following ways:
- IP address
192.168.10.20
- mDNS host name
mqtt-broker.local
- Fully Qualified Domain Name
broker.emqx.io
You can use this as broker.
https://github.com/nopnop2002/esp-idf-mqtt-broker
Communicate with Arduino Environment
Run this sketch.
ArduinoCode\Peer-to-peer\StringTest