M. Abdul Akbar Al Aziz
Published © GPL3+

Control LED and Monitor Temperature & Humidity Using Blynk

This is a project where you can Controlling LED and Monitoring Temperature & Humidity with your Mobile

BeginnerFull instructions provided3 hours453
Control LED and Monitor Temperature & Humidity Using Blynk

Things used in this project

Hardware components

ESP32
Espressif ESP32
×1
LED (generic)
LED (generic)
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Breadboard (generic)
Breadboard (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Story

Read more

Schematics

Schematic Control LED and Monitor Temperature &Humidity (Screenshot)

The schematic diagram of Control LED and Monitor Temperature & Humidity. I use DHT11 4pins in Schematic diagram because i can't find DHT11 3pins.
LED
Pin Anode to Pin 4 in ESP32 (Yellow Cable)
Pin Cathode to Pin GND in ESP32 (Black Cable)

DHT 11
Pin Signal to Pin 5 in ESP32 (Green Cable)
Pin VCC to Pin 5V in ESP32 (Red Cable)
Pin GND to Pin GND in ESP32 (Black Cable)

Code

Code of Control LED and Monitor Temperature & Humidity

Arduino
This is the code i use it in Arduino IDE for Control LED and Monitor Temperature & Humidity
#define BLYNK_TEMPLATE_ID "TMPL6MNKgjWaA"
#define BLYNK_TEMPLATE_NAME "ESP32 DHT11"
#define BLYNK_AUTH_TOKEN "7VJCKzTYt63Al2tBZDie_JlQg9Jik9Wq"

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>


#include <DHT.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "    "; // Name of WiFi or hotspot
char pass[] = "    "; // Password of Wifi or hotspot 

#define DHTPIN 5          // Mention the digital pin where you connected 
#define DHTTYPE DHT11     // DHT 11  
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

BLYNK_WRITE(V2)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  if (pinValue == 1)
  {
    digitalWrite(4, HIGH);
  }
  else {
    digitalWrite(4, LOW);
  }
  // process received value
}


void setup(){
   Serial.begin(115200);
   pinMode(4, OUTPUT);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
  
  dht.begin();
  timer.setInterval(2500L, sendSensor);
}

void loop(){
  Blynk.run();
  timer.run();
}
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;
  }

  Blynk.virtualWrite(V1, h);
  Blynk.virtualWrite(V0, t);
  Serial.print("Temperature : ");
  Serial.print(t);
  Serial.print("    Humidity : ");
  Serial.println(h);


  if(t > 30){
   // Blynk.email("abdulakbaralaziz090703@gmail.com", "Alert", "Temperature over 28C!");
    Blynk.logEvent("temp_alert","Temp above 30 degrees");
  }
}

Credits

M. Abdul Akbar Al Aziz
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.