How to send DHT data from ESP8266 to Arduino IoT Cloud

Samuel Adesola
7 min readApr 2, 2022

IoT being an integral part of cloud computing, several cloud vendors make IoT part of the services they render. Also, with the emergence of IoT, there are different platforms that make IoT implementation available even to individuals. In this tutorial, I will be taking you through the steps in sending data from NodeMCU, an IoT development platform to Arduino Cloud. To ensure all necessary things are in place, you will have to set up your computer to communicate with NodeMCU or ESP8266 before you can follow along with this tutorial. In this tutorial, we will be using DHT 11 sensor to send Temperature and Humidity data to Arduino Cloud. Materials Needed

  1. NodeMCU or ESP8266
  2. DHT 11 sensor
  3. 10K resistor
  4. Personal Computer
  5. Arduino IDE software
  6. Jumper Wires

Step 1:

The very first step is to ensure that your PC has been configured to communicate with ESP 8266. If you haven’t did this already, now is the time. Once you have configured your PC, come right back to continue following this tutorial.

Step 2:

Hardware Setup: Connect the NodeMCU and the DHT 11 to the breadboard, depending on your model of DHT 11, it can be a 3-pin ready-made model or a 4-pin model, in this tutorial, I am using a 3-pin model. If you are using a 3-pin model, connect the VCC to 3V of the NodeMCU, GND of the DHT 11 to GND on the NodeMCU, and connect the data pin to Pin 4 of the NodeMCU. If it is the 4-pin model you are using, connect Pin 1 of the DHT11 to 3V of the NodeMCU, connect the 10K resistor between pin 1 and pin 2 of the DHT 11, leave pin 3 of the DHT 11 sensor unconnected, and connect pin 4 of the DHT 11 to GND on the NodeMCU. Connect the NodeMCU via a USB cable to your computer and you are good to go.

Step 3:

After setting up the hardware connection, the next thing is to configure the cloud environment. To access the Arduino IoT cloud, open your browser and type the URL cloud.arduino.cc, you will be presented with the Arduino IoT Cloud interface, on the webpage, click on the 9-dot option button at the right-hand corner and select IoT Cloud, a new page will be presented to you where you can define all your cloud parameters, the tabs on the page are Things, Dashboard, Device, Integrations, and Template. To add a new IoT device to the cloud, under Things click on Create Thing.

Step 4:

After clicking on create a thing, you can give your thing a name by clicking on Untitled, on this window, we will be able to define variables that our thing will be sent to the cloud, we will choose our device type, and also set up connectivity. On this page, there are three tabs to work on, Setup, Sketch, and Serial Monitor, the first tab we will be working on is Setup, where we can define our variables. Variables depend on the kind of data you will be receiving from your device, if it's temperature, volume, Boolean, etc. you will define it in the variable. To add a variable, click on Add Variable

Give your Variable a name and select the type of data it will hold, leave everything else as default and click on Add Variable. Repeat this step for all variables you will take from your IoT device.

Step 5:

After adding all needed variables, the next thing is to link your IoT device with the Cloud. Under device, click on the link button and click on Set up New Device, then select Third-party device.

Select ESP8266 as device type and NodeMCU as device model. After that click on continue and you will be asked to give your device a name, type in a suitable name and it must not contain any special character, and click on Next.

After this, you will be presented with your device ID and key, copy these two down as you will need them in your code. There is also an option for you to download them as PDFs.

If you are able to achieve this, you are all set. You have successfully added your device to the cloud. The offline status will be shown meaning you have not connected your device to the cloud.

Step 6:

The next thing to set up is the network, click on the network button, Type in your network details, and paste the secret key you copied earlier.

Step 7:

Go to the Sketch tab and click on generate new sketch, your IoT cloud will generate a new sketch based on the variables you inputted.

To better work on your sketch, click on Open full Editor. Here, I have to point out that if you haven’t worked with the Arduino cloud before, you have to download the Arduino cloud agent, in most cases, on your first time accessing the Arduino cloud, you will be guided on how to install this. If not, just search for Arduino cloud Agent from google and you will be guided on how to set it up.

Step 8:

The next thing you want to do is to set up your dashboard, go back to IoT Cloud and click on Dashboard. Click on Build Dashboard and you will be able to add widgets through the add button.

For this tutorial, I will be adding a Switch for controlling an LED, chart, and gauge. After selecting Switch, you can give it a name, then click on Link Variable and select the right variable and click Done. Follow the same procedure to link other widgets you want.

Finally, I have:

Step 9:

Go back to the full monitor and include DHT 11 library from the library manager. Copy the code from my GitHub page, https://github.com/adesolasamuel/NodeMCU-DHT-Data-to-Arduino-IoT-Cloud and edit all necessary credentials, connect your board to the computer and upload the code. Go back to your Dashboard and you should see the charts reading showing data has been successfully sent to the Dashboard from our IoT device. You can also monitor the data on your mobile phone by downloading IoT Remote (Arduino Cloud) from your app store. Check out the Video Link below for a step by step

FOR A VIDEO GUIDE, GO TO:

--

--

Samuel Adesola

I am an embedded system engineer. Most of my works focus on IoT, AI and Machine Learning. With years of experience in programming and electronics