Closes the curtain in bright sun and opens it when the light drops.
Built and tested by Drisya K S · Industrial Robotics Institute
Arduino IDE, Blynk IoT app, ESP32Servo library
An automatic curtain for smart homes and offices. An LDR measures the light level; when sunlight is strong the ESP32 turns a servo to close the curtain, and when it gets dim the curtain opens again. The light level and curtain status are shown in the Blynk app.
| Component | Qty |
|---|---|
| ESP32 Dev Board | 1 |
| LDR (Light Dependent Resistor) | 1 |
| Resistor 10kΩ | 1 |
| Servo Motor (or DC motor with driver) | 1 |
| Jumper Wires / Breadboard | As needed |
| Power Supply | 1 |
| From | Connect to |
|---|---|
| LDR one leg | 3.3V |
| LDR other leg | GPIO 34 |
| 10kΩ resistor | GPIO 34 to GND |
| Servo VCC | 5V |
| Servo GND | GND |
| Servo signal | GPIO 13 |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP32.
#define BLYNK_TEMPLATE_ID "YourTemplateID"
#define BLYNK_TEMPLATE_NAME "Smart Curtain"
#define BLYNK_AUTH_TOKEN "YourAuthToken"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <ESP32Servo.h>
char ssid[] = "YourWiFiName";
char pass[] = "YourWiFiPassword";
int ldrPin = 34;
int servoPin = 13;
Servo curtainServo;
void setup() {
Serial.begin(115200);
pinMode(ldrPin, INPUT);
curtainServo.attach(servoPin);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop() {
int lightValue = analogRead(ldrPin);
Blynk.virtualWrite(V1, lightValue);
if (lightValue > 2000) {
curtainServo.write(0); // Close curtain
Blynk.virtualWrite(V2, "Curtain Closed");
} else {
curtainServo.write(90); // Open curtain
Blynk.virtualWrite(V2, "Curtain Open");
}
Blynk.run();
delay(1000);
}An automatic curtain for smart homes and offices. An LDR measures the light level; when sunlight is strong the ESP32 turns a servo to close the curtain, and when it gets dim the curtain opens again.
You need: ESP32 Dev Board (1), LDR (Light Dependent Resistor) (1), Resistor 10kΩ (1), Servo Motor (or DC motor with driver) (1), Jumper Wires / Breadboard, Power Supply (1). Software: Arduino IDE, Blynk IoT app, ESP32Servo library.
Yes. It is rated beginner and takes about 1–2 hours to build, using the ESP32. The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-146). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.