Monitoring Temperature and Humidity in Blynk App Using Smart Phone
by samiobi in Circuits > Arduino
608 Views, 2 Favorites, 0 Comments
Monitoring Temperature and Humidity in Blynk App Using Smart Phone
Home IOT (internet of things) technology becomes more in use everyday, interacting with the home gives the user more flexibility to utilize wisely his appliances as needed, even more it advice the user in case of any threat or danger which can be a life saving. However using IOT for homes needs good understanding because this technology will continue in the future and understanding it will prevent critical security issues in the future.
Supplies
- DHT 11 sensor
- ESP8266 NODE MCU
- Jumper cables
- micro USB cable
Concept of Operation
The system can be placed at any room within the house with a Wi-Fi coverage, then the system measures the ambient temperature and humidity then sends this data to Blynk application through the internet, eventually from the smart phone the user can check the temperature and humidity inside the home at any time and from anywhere. During the coding of the user include in the code the authentication key, this value acts as the way for the Blynk server to recognize the user account.
The system is capable of monitoring the values in Celsius or Fahrenheit which requires simple adjustment on the code .Although this system may sound a simple project but this project enhances the understanding of home IOT system of the user, also it can be used to build up a complete smart home. Blynk application is a useful IOT software platform, in addition is has a verity of libraries also its can be integrated with many hardware's such as Arduino, Esp8266 and so on.
Block Diagram
The block diagram shown in the figure describes the interconnection between ESP8266 Node MCU and the DTH11 sensor. The voltage power 3.3V and 0 V Ground sourced is the Node MCU which provides the required voltage to the sensor. The Node MCU is powered using micro USB for this project but this unit can be powered through Vin or an adapter. The signal output form the DHT is a data signal, this signal goes to pin D4 in the Node MCU. The Node MCU is capable to connect to Wi-Fi medium which then sends the data to Blynk server.
Hardware Connection
First connect the Node MCU to DHT11 sensor as described in the block diagram section, then connect the micro USB cable to the Node MCU then to the PC.
Pre Coding
In order to start with the coding make sure that ESP8266 Node MCU is configured in your IDE Arduino software, first go to file / preferences and in the additional board manger URL copy the link then press OK (as in the first figure)
"http://arduino.esp8266.com/stable/package_esp8266com_index.json"
Second go to tool / boards/ board manger/ type in esp8266 then install (as in the second figure), third install Blynk library go to sketch / include library / manage libraries then type in Blynk and install (as in the third figure).
After that go to tools boards and select the type of board will be working on Node MUC 1.0 (depends on the version used if it did not work select 0.9) sometimes the version is deferent if this information is not visual on the board (as in the fourth figure).
Installation of Blynk App and Configurating the Workspace
Install Blynk App in your smart phone then create an account, after signing in the app select new project (the authentication key will be sent to your email). Next on the new project page type in the project name (for example HomeTemp & Humid) and select the type of device used for the project select NODE MCU and on the connection type select WIFI.
Now the platform is ready, press on the work space to select two gauge and align them in the workspace. Then select the first gauge call it Temp and select the input as virtual 0 (V0) also define the maximum value for the Temp (60) and for the label type C for Celsius s. Additionally do the same for the second gauge, but this time select virtual (V1) and because the humidity is percentage so define the max value as 100 and percentage sign for label, for both values make the refresh rate as one second. The figures above explains the process of configuring Blynk pages. There are some parameters that can be altered as user wish.
Coding
The code of the system is pretty straight forward and with minimum knowledge of coding it can be understood easily. Copy the following code and past it in the IDE software, then make the changes on the authentication key, SSID and password. After that load the code in the Node MCU.
THE CODE
#define BLYNK_PRINT Serial
#include < ESP8266WiFi.h >
#include < BlynkSimpleEsp8266.h >
#include < DHT.h >
char auth[] = "xxxxxxxxxxxxxxxxxxx"; // replace the xxx with your authentication key
char ssid[] = "xxxxx"; // replace xxx with your wifi ssid
char pass[] = "xxxxx"; // replace xxx with your wifi password
#define DHTPIN 2 // connect to pin D4
// un comment the type of sensor you use
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void sendSensor() {
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return; }
Blynk.virtualWrite(V0, t); // Virtual pin 0
Blynk.virtualWrite(V1, h); // Virtual pin 1
}
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(1000L, sendSensor); // Setup a function to be called every second
}
void loop() {
Blynk.run();
timer.run(); }
Finally
Finally the App is ready as well as the system, after loading the codes in the system disconnect the USB cable from the PC and power on the system using the normal means (as in the photo above) there are many options for power in the Node MCU. Then access the App notice that when the system in online a message will be highlighted initially on the Blynk space. Finally you can monitor the value of the Temperature and Humidity the refresh rate of the data is every one second.
Hope you enjoy this project, and if you have any difficulty do not hastate to send.
Best regards