Cmtelesann
Published

Honey! I'm Cold!

Remote room temperature control with NodeMCU + Blynk.

BeginnerFull instructions provided1 hour672
Honey! I'm Cold!

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
DHT-22 Temperature and Humidity Sensor (3 Pin with resistor)
×1
SSR-25DA Solid State Relay
×1
Wall Mounted Heater (Bumb Type)
×1
Socket 230V
×1

Software apps and online services

Arduino IDE
Arduino IDE
Fritzing

Story

Read more

Code

NodeMCU

Arduino
#include "DHT.h"                              // DHT Sensor
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "BlynkAuth";
char ssid[] = "SSID";
char pass[] = "Password";

DHT dhtA(5, DHT22);                           // DHT instance named dhtA, Pin on NodeMCU D1 and sensor type

int RelayPin = 0;                             // Pin on NodeMcu D0

void setup() {
  Serial.begin(9600);                         // Debug purposes only to check if DHT is working
  Blynk.begin(auth, ssid, pass);              // Connecting to blynk
  dhtA.begin();                               // Starting the DHT-22
  pinMode(RelayPin, OUTPUT);                  // Blynk reference D0
}

void loop() {
  Blynk.run();                                
  climateRoutine();                           // Climate routines
  delay(4700);                                // 4.7 sec between routines
}

void climateRoutine() {
    byte h1 = dhtA.readHumidity();            // f1 and h1 are celsius and humidity readings
    byte t1 = dhtA.readTemperature();         // from DHT/A
    Blynk.virtualWrite(V0, t1);               // Set Virtual Pin 0 frequency to PUSH in Blynk app
    Blynk.virtualWrite(V1, h1);               // Set Virtual Pin 1 frequency to PUSH in Blynk app

    if (isnan(h1) || isnan(t1)) {             // Check if there DHT is working
      Serial.println("Failed to read from DHT sensor!");
      return;
    }
}

Credits

Cmtelesann
5 projects • 15 followers
Keeping my head busy! Looking for challenges! Trying to keep up with evolution! IoT is the future!

Comments