SME Dehradun

Here we will explain you, how you can send DHT11 sensor data to the All new blynk 2.0 cloud. 

So we need the following components to make this project-

  • NodeMCU/ NuttyFi Wifi Module
  • DHT11 Sensor
  • 3 female to female connecting wires
 

 Circuit diagram of DHT11 connections with Nuttyfi Wifi development board. Where orange color wire denote to 12V, Blue color wire denote to GND and Red color wire denote to 5V, here connect DHT data pin to D2 number pin of Nuttyfy.

This is the Circuit diagram with DHT11 Humidity & Temperature Sensor. Connect your circuit as per this circuit diagram.

Now, go to the web browser and open the blynk cloud by typing the blynk.cloud at the web browser and hit enter. Blynk2.0 Cloud has been opened. Here we login or create a new account. As I already have an account so I login to blynk.

Blynk dashboard has been opened. We click on a new template.  A new template has been opened. Write the name for the template. After that select the hardware esp8266 as we are going to use Nuttyfi or NodeMCU board. Write the description for your project and click on done.

The Info tab of the project has been opened. Firmware configuration, this is the important part of our blynk project.  Template id and device name. we have to write it to our arduino program. It is verified by the blynk cloud when the device connects to it via the internet.

Then go to the metadata tab, here you get the information about your project like device name, device owner name, location etc.

In the datastream tab, you define your method to connect with hardware. like we are going to connect our dht11 sensor data to blynk cloud, so how do we interface it’s data? Through digital pins, analog pins or are we going to access it through virtual pins?

So, let’s start defining it. click on new datastream, click on virtual pin because we are going to display the DHT11 sensor data through virtual pins. Virtual pin datastream property gets opened.

Write the name of the virtual pin as Humidity. Select the pin as v0, and select the data type as double. and we define the maximum value of humidity to 100 and click to create. Next Screen will display you that we have successfully created our humidity datastream to V0 virtual pin.

Again click to new datastream and click on virtual pin. Write the field name as Temperature, select the pin as V1 and data type double and write the max value for temperature 100.

Also we select the unit for the temperature as Celsius.

In the web dashboard, we take the label to display the humidity and temperature values. So drag and drop the label at the web dashboard. Now click on the setting icon on the label and select the datastream as humidity V0 and click to save.

Now drag and drop another label to the web dashboard and open the setting by clicking on the setting icon. Select the datastream as Temperature V1 and click on save. As you can see the demo value to the humidity and temperature label.

 

And at the last tab, mobile dashboard, you can download the Blynk 2.0 mobile app for IOS or Android mobile.

 

Now, it’s time to work on programming code.

 

Before that, we need to download the New blynk library for Blynk 2.0,  and dht sensor library & Adafruit Sensor Library for arduino.

Download and extract all these three library  extract it by using winrar or winzip software. and go inside the folder and you will get the arduino program file with ino file extension with the name dht11_sensor_data_to_blynk_2.0. open it with an arduino ide. 

Copy all these extracted folders and go to the place where you installed the arduino software. Go inside it and you will get the folder with the name “library”. Go inside this folder and paste both libraries inside it.

Now download the programming code for DHT Sensor and extract it.

Go inside the folder and you will get the arduino program file with ino file extension with the name dht11_sensor_data_to_blynk_2.0. Open it with an arduino ide. 

/*
* This program is property of SME Dehradun. for any query related to this program, contact us at www.smedehradn.com
* if your want any soluiton related for any IoT Customized Boards and Sensor to www.nuttyengineer.com
*/
// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID “Replace it”
#define BLYNK_DEVICE_NAME “Replace it”

#define BLYNK_FIRMWARE_VERSION “0.1.0”
#define BLYNK_PRINT Serial
#define USE_NODE_MCU_BOARD
#include “BlynkEdgent.h”
#include “DHT.h”
#define DHTPIN D2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);
float t, h;

void sendSensor()
{
h = dht.readHumidity();
t = dht.readTemperature();
Blynk.virtualWrite(V0, h);
Blynk.virtualWrite(V1, t);
}

void setup()
{
Serial.begin(9600);
dht.begin();
BlynkEdgent.begin();
delay(2000);
timer.setInterval(1000L, sendSensor);
}

void loop()
{
BlynkEdgent.run();
timer.run(); // Initiates SimpleTimer
}

Now, top of the program, you can see the Template ID and device name definition like this 

#define BLYNK_TEMPLATE_ID “Replace it”
#define BLYNK_DEVICE_NAME “Replace it”

we need to replace the Template ID and device name with our project. So go to the blynk web dashboard and click on the info tab and copy these template ID and Device name configuration and replace it here.

 

Here we define the NodeMCU firmware version. This is the command to display the serial once Nuttyfi connects to blynk.

#define BLYNK_FIRMWARE_VERSION “0.1.0”
#define BLYNK_PRINT Serial

Here we define the nodemcu board and blynk edgent header file.

#define USE_NODE_MCU_BOARD
#include “BlynkEdgent.h”

Here we include the dht sensor library. We define the dht pin to D2 and dht sensor type to DHT11.

#include “DHT.h”
#define DHTPIN D2
#define DHTTYPE DHT11

Now we call the dht function by passing the arguments dht pin and dht type.  we takes two flaot variable h and t. h is used to store the humidity and t for temperature.

Now here we make a separate function sendSensor() to capture the dht sensor data and send that data to blynk.

Inside this function we store the humidity sensor value to h variable by using dht.readHumidity() command. And temperature in t variable using dht.readTemperature.

void sendSensor()
{
h = dht.readHumidity();
t = dht.readTemperature();
Blynk.virtualWrite(V0, h);
Blynk.virtualWrite(V1, t);
}

As we have stored the humidity and temperature values to h and t variables, now we send these data to blynk by using blynk.virtualwrite command. We send the h variable data to V0 as we have defined humidity in the V0 pin in the datastream tab. And similarly we define temperature to V1. So we send the  t variable value to V1 pin. 

Now below in the setup function, we begin the serial at 9600 baud rate. Here we begin the dht sensor by using the dht.begin command.

Now we begin the blynkEdgent.begin  to authenticate the nutyfi with blynk cloud. we give the delay of 2000 ms here.

void setup()
{
Serial.begin(9600);
dht.begin();
BlynkEdgent.begin();
delay(2000);
timer.setInterval(1000L, sendSensor);
}

This timer.setInterval command is used here to call the sendSensor function, in which we define the h and t variable to send the data of  dht11 sensor to blynk cloud every 1000 ms. Understand.

timer.setInterval(1000L, sendSensor);

And in the loop function, we call the BlynkEdgent.run function to call all the blynk functions defined inside the program when interrupts happen.

And finally, the timer.run function has been defined here.

void loop()
{
BlynkEdgent.run();
timer.run(); // Initiates SimpleTimer
}

So this is the program. we need to select the wifi board. So go to the tools, go to the board and select NodeMCU 1.0(ESP-12E Module). 

If you don’t have a wifi board installed in your arduino IDE, then this the link to show you, how you can install NuttyFi/ NodeMCU Wifi to the arduino IDE.

So time to upload the program to the Nuttyfi board. So connect the Nuttyfi to Computer’s usb port and select the Port as com9. 

 

Now click on the upload button. Once uploading done, nuttyfi is ready to connect with Blynk2.0 IoT app.

So time to configure the blynk app on the mobile. So go to the app store and search for blynk. You can see we got the two blynk app, blynk legacy and blynk IoT New. Blynk legacy is blynk 1.0 old app. So we installed blynk IoT New that is blynk 2.0. As I have already downloaded it,  so open the blynk app and you can see we have got the two options, sign up or login. As we already have an account so login to it.

And android user, they can download it from android store.

 

 

So click on add new device. here we got 3 options, connect to wifi, scan QR code and quick start device.

 

 

So we select connect to wifi, and next screen has been appeared, here we need to power up NuttyFi and click on Ready.

As you can see, we got the popup with wifi name start from blynk. Click to join. 

 

Now it’s connecting to the device and getting its information. Now it’s asking to join a wifi network so that it can use that network to connect with the blynk cloud.

So provide the credentials of the wifi and click on continue. Now it is configuring the wifi network. Click on continue and then done. Now exit from the app. back to the main dashboard of the blynk app. You got your blynk project here.

Click on the project and click on the setting icon. Inside, click on + sign and scroll below. Click on the value display widget. 

 

We add 2 widgets to the dashboard for humidity and temperature.  

We place it at an appropriate place as per our requirement. We can also resize it by long press on the widgets. Now click on the first widget and its property gets opened. Select the data stream as Humidity V0 and write the title as Humidity. Now back to the dashboard and click on another widget. In the property, select datastream as Temperature V1 and write the title temperature. Back to the dashboard. So this is how we can configure the blynk2.0 app.

 

Now it’s time to connect the dht sensor to Nuttyfi. So we take the 3 female to female wires and connect them to the dht sensor.  Now connect the Vcc wire of the DHT sensor to the 5V pin of Nuttyfi, GND pin Dht sensor to GND pin of Nuttyfi and Data pin of DHT sensor to D2 pin of Nuttyfi. If you get confused, then download the circuit diagram from the video description.  And this is how we connect the USB cable to Nuttyfi.

Now I am connecting the Nuttyfi to my laptop’s USB port. As you see, Nuttyfi and dht11 sensor both are powered up. Now open the blynk 2.0 app. You can see, app is in offlline state.  

It can take 5 to 10 second to come online. It’s online now. Click on the Blynk2.0 mobile app and inside it, you can see the relational humidity and temperature of the atmosphere.

 

So that’s how you can interface DHT11 sensor data to the Blynk 2.0. 

 

 

We add 2 widgets to the dashboard for humidity and temperature.  

We place it at an appropriate place as per our requirement. We can also resize it by long press on the widgets. Now click on the first widget and its property gets opened. Select the data stream as Humidity V0 and write the title as Humidity. Now back to the dashboard and click on another widget. In the property, select datastream as Temperature V1 and write the title temperature. Back to the dashboard. So this is how we can configure the blynk2.0 app.

 

Now it’s time to connect the dht sensor to Nuttyfi. So we take the 3 female to female wires and connect them to the dht sensor.  Now connect the Vcc wire of the DHT sensor to the 5V pin of Nuttyfi, GND pin Dht sensor to GND pin of Nuttyfi and Data pin of DHT sensor to D2 pin of Nuttyfi. If you get confused, then download the circuit diagram from the video description.  And this is how we connect the USB cable to Nuttyfi.

Now I am connecting the Nuttyfi to my laptop’s USB port. As you see, Nuttyfi and dht11 sensor both are powered up. Now open the blynk 2.0 app. You can see, app is in offlline state.  

It can take 5 to 10 second to come online. It’s online now. Click on the Blynk2.0 mobile app and inside it, you can see the relational humidity and temperature of the atmosphere.

 

So that’s how you can interface DHT11 sensor data to the Blynk 2.0

If you want any help in your any project, you can contact us. Definitely we will help you. Link to contact us is available at video description. For any kind of Customized IoT board and Sensor solutions (for your research, for your company or Industry), You can contact Nutty Engineer Company, link is available in the video description.

 

2 Responses

  1. Hi ,
    you explain very well and I had no trouble following your directions. However , when I compile the sketch it gives me a fault of “BlynkEdgent….No such filr or directory ”
    Can you assist me please ?

    Thank you ,
    W.M.Bird.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.