Hello Visitors, Today i show you how to interface DHT sensor Value in Blynk Apps use ESP8266 .

Things used in this project

ESP8266 Board

DHT11 Temperature & Humidity Sensor

Breadboard

Male/Female Jumper Wires

Arduino IDE

Blynk

DHT11 sensor measures and provides humidity and temperature values serially over a single wire. First read this article and prepare arduino for ESP8266 Arduino Support for ESP8266 with simple test code

PIN Connection:

Create a Project use Blynk apps Following Instruction First LogIn your Blynk App Then Flow the Step By Step

NOTE – You got your AUTH TOKEN it send to your email address.

Now Flash this code in ESP8266. Here Replace SSID, SSID PASSWORD and Auth TOKEN. You need to Some library.

So Download by this link https://github.com/blynkkk/blynk-library/archive/master.zip

Adafruit DHT sensor libraries:

https://github.com/adafruit/Adafruit_Sensor

https://github.com/adafruit/DHT-sensor-library

Download these library and extract it. Now open Arduino and go to File>Properties. Here you find path of Arduino.

Now go to Arduino path and paste all extracted libraries folder in Libraries Folder. Select Board “Nodemcu 1.0” in Tool tab of Arduino IDE and Select right Port for Nodemcu. Now Flash this code given below.

Code

/************************************************************* WARNING :

For this example you’ll need Adafruit DHT sensor libraries:

https://github.com/adafruit/Adafruit_Sensor

https://github.com/adafruit/DHT-sensor-library App project setup:

Value Display widget attached to V5

Value Display widget attached to V6

*************************************************************/ /* Comment this out to disable prints and save space */

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <DHT.h> // You should get Auth Token in the Blynk App.

// Go to the Project Settings (nut icon).

char auth[] = “AUTH TOKEN”; // replace with your auth token, You got your AUTH TOKEN it send to your email. // Your WiFi credentials.

// Set password to “” for open networks.

char ssid[] = “YOUR SSID”; // replace with your SSID

char pass[] = “SSID PASSWORD”; // SSID Password #define DHTPIN 2 // What digital pin we’re connected to // Uncomment whatever type you’re using!

#define DHTTYPE DHT11 // DHT 11

//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321

//#define DHTTYPE DHT21 // DHT 21, AM2301 DHT dht(DHTPIN, DHTTYPE);

BlynkTimer timer; // This function sends Arduino’s up time every second to Virtual Pin (5).

// In the app, Widget’s reading frequency should be set to PUSH. This means

// that you define how often to send data to Blynk App.

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;

}

// You can send any value at any time.

// Please don’t send more that 10 values per second.

Blynk.virtualWrite(V5, h);

Blynk.virtualWrite(V6, t);

} void setup()

{

// Debug console

Serial.begin(9600); Blynk.begin(auth, ssid, pass);

// You can also specify server:

//Blynk.begin(auth, ssid, pass, “blynk-cloud.com”, 80);

//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080); dht.begin(); // Setup a function to be called every second

timer.setInterval(1000L, sendSensor);

} void loop()

{

Blynk.run();

timer.run();

}

Like this: Like Loading...