In this lesson, we will tell user to send MQTT message to MQTT broker

Parts required:
OSOYOO Wifi Shield x 1
Arduino UNO board x 1

Hardware connection:
Please insert OSOYOO wifi shield into Arduino UNO 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:

1)WifiESP library

2)MQTT PubSubClient library

Software Sample sketch code:
Please download sample code from

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 “”, 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 and subscribe topic “OSOYO-Topic” and get the message from our sample program.

We use free online MQTT client and see the result as following: