Smart Home via Blynk Esp32

Starting from the emergence of my problem in turning on something at home, such as lights, fans, TV and others, and the creation of IoT made

BeginnerShowcase (no instructions)348
Smart Home via Blynk Esp32

Things used in this project

Hardware components

ESP32S
Espressif ESP32S
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
3 mm LED: Yellow
3 mm LED: Yellow
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Relay (generic)
×1

Software apps and online services

Blynk
Blynk
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Schematics

Wiring

Code

Code SmartHome

C/C++
#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_AUTH_TOKEN            "YourAuthToken"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


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

char auth[] = "Tyt2Zhm3SC_hVhlCZeqDMqvzs1geqYmC";
char ssid[] = "Aa";
char pass[] = "11111111";

#define DHTPIN 4          // What digital pin we're connected to
#define DHTTYPE DHT11     // DHT 11
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;


WidgetLED led1(V4);
WidgetLED led2(V3);
int lampu1 = 22;
int lampu2 = 23;
int lampu3 = 13;
int lampu4 = 12;

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;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

}

void setup()
{
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, "blynk-cloud.com",8080);
dht.begin();
  
pinMode(lampu1,OUTPUT);
pinMode(lampu1, LOW);
pinMode(lampu2,OUTPUT);
pinMode(lampu2, LOW);
pinMode(lampu3,OUTPUT);
pinMode(lampu3, LOW);
pinMode(lampu4,OUTPUT);
pinMode(lampu4, LOW);

  while (Blynk.connect() == false) {
  }
  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop() {
  Blynk.run();
  timer.run();
}

Credits

Dimas Amya Juliansah 28101
1 project • 0 followers
Aldhi Adytia Prasetio 24776
4 projects • 1 follower

Comments