Mechatronics LAB
Published © GPL3+

Smart Home Temperature & Humidity Monitor with ESP32 and Bly

Smart Home Temperature & Humidity Monitor with ESP32 and Blynk

BeginnerProtip1 hour385
Smart Home Temperature & Humidity Monitor with ESP32 and Bly

Things used in this project

Hardware components

esp32
×1
dht22
×1

Story

Read more

Schematics

1_dht22_-_digital_temperature_and_humidity_sensors_DaOdkh88w1.png

Code

Code

Arduino
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>

// Blynk Auth Token (from Blynk App)
char auth[] = "YourAuthToken";

// Wi-Fi credentials
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

// DHT Sensor Setup
#define DHTPIN 4 // Data pin connected to GPIO4 (D4)
#define DHTTYPE DHT11 // DHT11 sensor type

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  dht.begin();
}

void loop() {
  Blynk.run();

  // Read temperature and humidity values
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  // Check if readings are valid
  if (isnan(temperature) || isnan(humidity)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Send data to Blynk
  Blynk.virtualWrite(V5, temperature); // Virtual pin V5 for temperature
  Blynk.virtualWrite(V6, humidity);    // Virtual pin V6 for humidity

  delay(2000); // Delay between readings
}

Credits

Mechatronics LAB
75 projects • 47 followers
I am Sarful , I am a Mechatronics Engineer & also a teacher I am Interested in the evolution of technology in the automation industry .
Contact

Comments

Please log in or sign up to comment.