book collections email follower instructable user

This lesson will show the basic MQTT protocol usage on the NodeMCU board .We use the MQTTBox as the MQTT client here, and we will use the NodeMCU to complete following operations:

Publish “hello world” to the topic “outTopic” every two seconds.Subscribe to the topic “inTopic”, print out any received messages.It assumes the received payloads are strings not binaries.If the subscribed message is “1”, light the onboards LED.Turn off the onboard LED if the message to subscribe is “0”.

Osoyoo NodeMCU x1

USB Cable x1

PC x1

Arduino IDE(Versin 1.6.4+)

Connect the NodeMCU to PC via USB cable.

Step 1: Library Installation

Picture of Library Installation

Install PubSubClient library

We need install MQTT endpoint library(PubSubClient) to communicate with MQTT broker, please download the library from following link:

Unzip above file, move the unzipped folder to Arduino IDE library folder.

Open the Arduino IED,you can find the “pubsubclient” on the “Examples” column.

Install MQTT Client:

we will use the MQTTBox as the MQTT client. please download from:

SidNelson made it!2 months ago
It works perfectly!
PhyoLay7 months ago
Can I get the code?
rfoley49 months ago
Can't I skip the MQTTBox step if I'm already running a local MQTT broker?
I don't quite understand what it's doing.
SatishM201 year ago

3)MQTT Client Settings
If your MQTT broker require clientID,username and password authentication,you need to

Which clientID, username and password we required?

Oliverhall1 year ago

You can find parts for this project on

Really cool! I tried and was successful immediately.
Thank you for the tutorial!

Thank you for the tutorial, I made it!

henrychau94 made it!1 year ago

Thank you for the tutorial, I made it!

GüntherS21 year ago

My first Arduino experience - perfect!