Hello
First thing witch came to me when i discover ESP and Blynk was a simple temperature monitoring
However, connection just DHT sensor is not interesting, so, i decide to do some automation, connect at least 2 sensor and add some relay
e.q used hardware for now consist following parts
- One ESP8266 board
- One 5VDC adapter
- One 2x relay board
- One DHT 11
- One DHT 22
For now system is incomplete, as i have no time to finalize auto power on scheme. need to solder power adapter with common ground and +3 /+5 vdc, since in current connection ESP is going down as power is been used by external device
Code, like hardware is simple, but useful. please any comment are welcome
#include <DHT.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#define DHTPIN 12
#define DHTPIN1 2
#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
DHT dht1(DHTPIN1, DHTTYPE);
SimpleTimer timer;
WidgetLED led1(10)
WidgetLED led1(11)
int relay =5;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "SSID", "SECRET");
dht.begin();
dht1.begin();
pinMode(relay, OUTPUT);
timer.setInterval(1000L, readtemp);
}
void readtemp()
{
float h = dht.readHumidity();//outside
float t = dht.readTemperature();//outside
float h1 = dht1.readHumidity();
float t1 = dht1.readTemperature();
Blynk.virtualWrite(1, h); //out
Blynk.virtualWrite(2, t);//out
Blynk.virtualWrite(3, h1);
Blynk.virtualWrite(4, t1);
if (t1<17)
{
digitalWrite(relay, HIGH);
led1.on();
}
void loop()
{
Blynk.run();
timer.run(); // SimpleTimer is working
}