Tim is currently doing research in Internet of Things (IoT). His desire to spread the concept, ideas, and experience of IoT.
In this tutorial I will show you how send temperature and humidity data from DHT11 sensor to Adafruit IO (AIO) platform via MQTT protocol. I will develop a sensor node which acts as an MQTT client and publishes the data. On AIO platform the published data will be displayed using graphs.
- NodeMCU X 1
- DTH11 Sensor X 1
- Jumper Wires X 3 (Male-To-Male)
- Breadboard X 1
In this tutorial I am using DHT11 sensor which has three pins, DATA, VCC and GND as shown in following figure. You can also use the other DHT11 sensor which has 4 pins.
Connect the DATA pin of DHT11 sensor to NodeMCU D6 pin and VCC, GND to Vin and GND pins respectively of NodeMCU. The circuit diagram is shown below.
Now upload the following Arduino code to NodeMCU. Please remember to specify your WiFi SSID and password and also username and KEY of Adafruit IO (AIO) platform. To get AIO Key follow instruction in my other tutorial.
Build User Interface
Our next step is to build the user interface (UI) where we can display the data published by sensor node.
To create UI, logon to your Adafruit IO account.
The first thing we need is the Feeds where our data will be published. The Feeds are the MQTT topics. These topics are then bind to our UI which will display data graphically. In this tutorial I'll show another method to create feeds.
For creating feeds goto to Feeds->View All as shown in following figure.
You will see already created feeds 'brightness' and 'onoff' from our previous article as shown below. Don't bother if you do not see anything, just create the feeds as instructed in this article.
To do this click on Actions->Create a New Feed as shown below.
You will see Create new feed dialogbox as shown in following figure. Name the feed as 'temp'.
Repeat the action and create another feed 'hum' as shown below.
Now you will have two feeds 'temp' and 'hum' to store temperature and humidity data as shown below.
Now go to Dashboard->AIO_Controller
And click the '+' button to add new block (i.e. Line Chart UI) as shown in following image.
Click on Line Chart UI and select the 'temp' feed from the list of feeds in the dialog box.
Click next and specify block settings
Similarly add another Line Chart block by selecting 'hum' feed as shown in following two images
You will now see dashboard with two line chart blocks.
Now connect your device and you will see temperature and humidity values published on the UI.