Temperature monitoring ESP 8266

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

  1. One ESP8266 board
  2. One 5VDC adapter
  3. One 2x relay board
  4. One DHT 11
  5. 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

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()
    Blynk.begin(auth, "SSID", "SECRET");
     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);

void loop()
{;; // SimpleTimer is working

Have you considered adding LDR’s to automate lights?

yes, i already wire it, but as i say for now need to solve power issue

Show a schematic (drawing / picture) how you have wired up your hardware then a recommendation can be made to help with your power problem. First there must be sufficient amperage (mA - milliamps) from your power supply to supply the whole project. Available amperage from digital and analog outputs are limited. Most likely the relay is using more amperage(mA’s) than the digital output can provide, so adding a transistor in the relay coil circuit would be used to provide the mA’s needed. I can provide a simple schematic for a standard low voltage relay.


Thanks. Im using 5vdc 2 a power adapter for optical-split relay, and 3vdc for ESP board, problem is, when im turning relay on or off, blynk restart’s connection.But for now i have no time to solve it, however, i plan to make drawing and finalize system for a weekend’s

Ok this sketch work , but if the temperature exceeds for example 20° degrees the relay is not deactivated, in this way the temperature continues to rise.

@emax2000 an extract from our sketch is shown below. With a max (TooHot) and min (TooCold) temperature setting the central heating will be on if the temperature is less or equal to TooHot and off above TooHot. Central heating stays on below TooCold and up to an including TooHot.

  if(Mode > 3){
    if (temp >= TooHot){
       DeviceOff();   // Send OFF signal
       lcd.print(0, 1, " HOT ENOUGH OFF ");
    if ((temp < TooCold) || (temp < TooHot)){
       if(CentralHeating == 0){
         DeviceOn();   // Send ON signal
       lcd.print(0, 1, " TOO COLD SO ON ");

which sketch???

you should post the sketch you are trying to use.