India Automation Challenge 2021
You’d be surprised at how much curtains matter in the house! Aside from keeping the peeping Toms out (especially in a crowded place like India, where flats are stacked window to window), they play an important role in décor by creating ambiance and pulling the room together—kind of like rugs. When comes to décor, curtains play an important role in automation. Very few have thought of this area. When thinking of home automation no one thinks of these, but this will add some extra stars to show off. My attempt is to create a prototype version of Smart Curtains using ESP 32. I’ve used basic sensors and actuators, but you can scale it up if you want. With my approach you can control your room lighting to your need, setting customized light intensity as your mood, or even while you’re away. I’ve used servos to represent stepper motor which would be used to draw the curtains or window panels. I’ve used two LDR(light-dependent resistors) to take feedback of outdoor and indoor lighting conditions and set servo in such a level to let that much amount of light enter the room. I’ve used ESP32 as the main microcontroller, it connects to the network and listens for any change of servo position, and reports indoor and outdoor lighting to the network. I’ve used the Blynk IOT platform here, it acts as a middle man between the user phone and actual hardware. It sends data to the phone and takes input from the user. Different people have their own preferences, some prefer more light, while some prefer darkness. GitHub Repo: https://github.com/xevozen/Smart-IoT-Curtain
ESP32 x1, LDR x2, 10kOhm Resistor x2, Servo x1, Some Jumpers, Power Adapter, Breadboard, Common hardware tools
Arduino, Blynk IoT platform
ESP32 is just the right hardware to go for. Considering its price, it offers some serious advantages over any other IoT board in the market. For demo purposes, I've used Servo in place of Stepper Motor. Two LDR are used as feedback for the system to act accordingly. Users can control the percentage of light entering from any part of the world at a comfort. Different users have different preferences, so gives customization. Programming ESP32 using the Arduino platform is a breeze, it's open-source and already has a wide user base. At any point in time if you're stuck you can just search it online. For DIY projects, open-source is the way to go.
The circuit is very simple. Any kid will also be able to make it. You just need basic breadboard skills. Connect wires as per circuit shown. I've connected the servo to pin 13. Indoor LDR to pin 34, since it's an analog pin. Outdoor LDR to pin 35 since it's also an analog pin. Just these basic wiring will get up and running. Very easy. Make a voltage divider using LDR and 10kOhm resistor. This voltage divider will give different output voltage for different lighting exposed. Make the voltage divider by referring to the circuit. Connect all ground wires together and connect it to the power supply. Same for power line also.
// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud #define blinds 13 #include <ESP32Servo.h> char auth = BLYNK_AUTH_TOKEN; // Your WiFi credentials. BlynkTimer timer; // This function is called every time the Virtual Pin 0 state changes void setup() Blynk.begin(auth, ssid, pass); // Setup a function to be called every second void loop()
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "xxxxxxxxxxxxxxxxx" //Paste your template ID here
#define BLYNK_DEVICE_NAME "MyIOT" //Paste your device name
#define BLYNK_AUTH_TOKEN "xxxxxxxxxxxxxxxxx" //Paste your Auth Token
#define indoor 34
#define outdoor 35
// Comment this out to disable prints and save space
//#define BLYNK_PRINT Serial
// Set password to "" for open networks.
char ssid = "xxxxxxxxx"; //Enter your credentials
char pass = "xxxxxxxxx";
// Set incoming value from pin V0 to a variable
int value = param.asInt();
myservo.write(map(value, 0, 100, 0, 180));
// This function sends Arduino's uptime every second to Virtual Pin 2.
// You can send any value at any time.
// Please don't send more that 10 values per second.
// Debug console
myservo.setPeriodHertz(50); // standard 50 hz servo
myservo.attach(blinds, 1000, 2000);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
#define blinds 13
char auth = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// This function is called every time the Virtual Pin 0 state changes
Blynk.begin(auth, ssid, pass);
// Setup a function to be called every second