-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDHT11_Blynk_App.ino
54 lines (41 loc) · 1.14 KB
/
DHT11_Blynk_App.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*Sending Digital Temperature and Humidity(DHT11) sensor's data to Blynk!
https://www.clevertronics.blogspot.com
Used Hardware : ESP8266 (NodeMCU)
Used IDE : Arduino IDE 1.8.12
*/
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
char auth[] = "xxxxxxxxxxxxxxx-xxxxx"; //Enter the Auth code which was send by Blink
char ssid[] = "Your_SSID"; //Enter your WIFI name
char pass[] = "Your_Password"; //Enter your WIFI password
#define DHTPIN 2 // Digital pin 4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
//user defined and customizable.
Blynk.virtualWrite(V5, h); //V5 is for Humidity
Blynk.virtualWrite(V6, t); //V6 is for Temperature
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}