In this lesson, we will tell user to send MQTT message to MQTT broker
OSOYOO WIFI Shield x 1
OSOYOO Basic board x 1
Please insert OSOYOO wifi shield into OSOYOO Basic board, then use jumper caps to connect D4,D5 to E_TX and E_RX as following picture(the red square_:
Software library requirment:
You need installed following library:
2)MQTT PubSubClient library
Software Sample sketch code:
Please download sample code from https://osoyoo.com/driver/wifi-iot/osoyoo-mqtt.zip
Open the code with Arduino IDE, you need replace line 10,11 with your own WIFI SSID and password.
mqtt_server variable in Line 12 is the MQTT server you need to connect. We use free MQTT server “broker.mqttdashboard.com”, you can set this variable to your own MQTT broker if you like.
After running the code, the sketch code will send “Hello World ****” (**** is the time stamp) to MQTT server under topic “OSOYO-Topic” (defined in line 1117) every 2 seconds.
You can use any MQTT client to connect to broker.mqttdashboard.com and subscribe topic “OSOYO-Topic” and get the message from our sample program.
We use free online MQTT client http://www.hivemq.com/demos/websocket-client/ and see the result as following:
DownLoad Url osoyoo.com