IoTBeginnerPRJ-146

IoT Smart Curtain Controller Using ESP32

Closes the curtain in bright sun and opens it when the light drops.

Built and tested by Drisya K S · Industrial Robotics Institute

ESP32

Arduino IDE, Blynk IoT app, ESP32Servo library

LevelBeginner
Build time1–2 hours
BoardESP32
Parts6 components

What is the IoT Smart Curtain Controller?

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.

How it works

  1. The LDR and 10kΩ resistor form a voltage divider read on GPIO 34.
  2. The ESP32 sends the light value to Blynk V1.
  3. Above 2000 (bright), the servo turns to 0° to close the curtain.
  4. Below that, the servo turns to 90° to open it; the status goes to V2.

Parts list

ComponentQty
ESP32 Dev Board1
LDR (Light Dependent Resistor)1
Resistor 10kΩ1
Servo Motor (or DC motor with driver)1
Jumper Wires / BreadboardAs needed
Power Supply1

Software

  • Arduino IDE
  • Blynk IoT app
  • ESP32Servo library

Wiring and connections

FromConnect to
LDR one leg3.3V
LDR other legGPIO 34
10kΩ resistorGPIO 34 to GND
Servo VCC5V
Servo GNDGND
Servo signalGPIO 13

How to build the IoT Smart Curtain Controller

  1. Build the LDR voltage divider: LDR from 3.3V to GPIO 34, and 10kΩ from GPIO 34 to GND.
  2. Connect the servo signal to GPIO 13 and power it from 5V.
  3. Attach the servo arm to a curtain cord or a model curtain.
  4. In Blynk, create datastreams V1 (light) and V2 (status).
  5. Install the ESP32Servo library, add your Blynk details and Wi-Fi, and upload.
  6. Shine a torch on the LDR to test, and adjust 2000 for your room.

IoT Smart Curtain Controller code

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);
}

Real-world uses

  • Smart homes
  • Offices and classrooms
  • Greenhouse shading
  • Energy-saving buildings

Frequently asked questions

What is a IoT Smart Curtain Controller?

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.

What components are needed for the IoT Smart Curtain Controller?

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.

Is the IoT Smart Curtain Controller project good for beginners?

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.

Where can I get the code for the IoT Smart Curtain Controller?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the IoT Smart Curtain Controller?

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.

Industrial Robotics Institute
Logo