How To Interface DHT11 With NodeMcu ESP8266 and Sending It
How To Interface DHT11 With NodeMcu ESP8266 and Sending It
Ubidots cloud
About Ubidots
Ubidots is an IoT(Internet of Things) data analytics and visualization company. We turn sensor data into
information that matters for business-decisions, machine-to-machine interactions, educational research,
and increase economization of global resources. Ubidots exists as an easy and affordable means to
integrate the power of the IoT into your business or research.
Ubidots technology and engineering stack was developed to deliver a secure, white-glove experience for
our users. Device friendly APIs (accessed over HTTP/MQTT/TCP/UDP protocols) provide a simple and
secure connection for sending and retrieving data to and from our cloud service in real-time. Ubidots’
time-series backend services are performance optimized for IoT data storage, computation, and
retrieval. Our application enablement platform supports interactive, real-time data visualization
(widgets), and an IoT App Builder that allows developers to extend the platform with their own HTML/JS
code for private customization when desired. Ubidots exists to empower your data from device to
visualization.
Because of different plans for different users high response rate, easy to use, fast services Ubidots is
widely used by developers and industries
Features of ubidots:-
Reasonably priced
Can send up to 20 -30 values per second
Can be used with any IoT tool like Raspberry Pi, NodeMcu etc.
Works on rest api
1. For students: - Ubidots provides free 5000 credits point and after consumption of 5000 credits
you can purchase 1000 credits for 5$ for only one device.
Figure 1 Pricing for students and developers
2. For developers:- Ubidots provides a trial for 30 days and later on 20 USD per month with some
advance features and up to 10 devices at a time
3. For a IOT lab:- for IOT lab in colleges or training Ubidots charge $99 USD per month and you can
use up to 60 devices at a time
4. For industries:- Ubidots charge $499 USD per month and you can use up to 400 devices at a time
5. For large scale :- for a large scale usage Ubidots charge $ 2499 USD per month and you can use
up to 5000 devices at a time
Components Required
DHT 11 sensor module (costs around $3 USD)
NodeMcu ESP8266 (costs around $6 USD)
Jumper wires
Software required
Arduino IDE
Libraries required
DHT.H
UbidotsMicroESP8266.h
Now after making circuit it’s time to setup ubidots account. Creating ubidots account is very
simple easy and just takes only few steps.
Creating Ubidots account
1. Open browser and search apps.ubidots.com and go
7. Now SIGN UP. You can also sign up using your Twitter , Github , Google or Facebook account
Fill all the details mentioned in the form and click on signup.
At username place any username for example - xyzio
Please give your any mail id in email for example - xyz.gmail.com
Now enter any password of your choice and signup
Now ,Ubidots setup is complete let’s move on to the coding part all the left part for ubidots
setup should be only done after successfully run of code.
Coding
1. Open Arduino IDE and go to file and new.
Figure 9. Arduino IDE
6. And now open the path where the library is downloaded and click on open the file
7. Now the library get installed in Arduino IDE automatically
8. Now paste the below given code in Arduino IDE
9. Change the token . get your token from going onto your Ubidots account. Click on your
username first at the right upper corner
10. After clicking some option open there click on API Credentials .
11. After clicking on API credentials copy your default token from there and replace the given token
in code
12. Also change wifi name and password in code with your wifi name and password
Please write the wifi name and password in double cots.
Code
#include "DHT.h"
#define DHTPIN D1
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
8. Now, after sign up this type of page appears
#include "UbidotsMicroESP8266.h"
#define TOKEN "A1E-kjeI6pKCeYOn6SFBDEBBiRezl68lxU" // Put here your Ubidots TOKEN
#define WIFISSID "Nokia 3.1" // Put here your wifi name here
#define PASSWORD "" // Put here your wifi password here my wifi is open put your
Ubidots client(TOKEN);
unsigned long lastMillis = 0;
void setup(){
Serial.begin(115200);
dht.begin();
delay(10);
client.wifiConnection(WIFISSID, PASSWORD);
}
void loop(){
lastMillis = millis();
client.add("MyHumidity",MyHumidity );
Figure 13. page after signup
client.add("MyTemperature",MyTemperature );
client.sendAll(true);
9. After successful creation of variables and device set your location by You can add a location to
yo
}
10.
} 11.
Code explanation
#include "DHT.h"
#define DHTPIN D1
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
This lines are used to call library for DHT11 sensor and type of DHT sensor we are
Using and on which pin DHT is connecting to the NodeMcu
#include "UbidotsMicroESP8266.h"
#define TOKEN "A1E-kjeI6pKCeYOn6SFBDEBBiRezl68lxU" // Put here
your Ubidots TOKEN
This lines are used to call ubidots library for ESP8266 and get access to your account
Using token its save our token in the string Token
#define WIFISSID "Nokia 3.1"
#define PASSWORD ""
client.add("MyHumidity",MyHumidity );
client.add("MyTemperature",MyTemperature )
client.sendAll(true);
The above lines create feed in the device which receive the data with name MyHumidity
And MyTemperature
1. After running the code go to ubidots and click on Devices u will see this block with tag
ESP8266 DATA there
2. Now click on ESP8266 DATA block and click You can add a location to your Device by clicking here on
this line on the upper side and allow location
Figure 14. allow location
3. After clicking on allow location . just simply tap on your city ,town or village
9. Now repeat the steps 16 to 19 after step 19 choose MyHumidity and finish.
10. Now the setup is complete and dashboard look alike the picture given below
Now run the code with all the setup.
Now you can download the android app from play store and see all the readings in your phone
also and do login from same details as here and check the data from your phone.