I made this little project to automate switches in my house using Arduino ESP32's, so lights can turn on/off on a schedule while I'm away.
The arduino code will first acquire the current time (using NTP servers), then load the switch schedule from a file hosted in the internet. The schedule is polled every 10 minutes.
The main loop will try matching the current time against the schedule, accurate to the second (format HH-MM-SS). If it matches a switch time, the servo will actuate to either on or off.
There's many improvevements that could be made, but this worked perfecly for a few weeks out of the house.
The build is very simple, using an Arduino ESP32 and 9g servo hot-glued to a little wooden base. I fed the servo through the VBUS pin from the Arduino. Here's what it looks like:
switch720p.mp4
There's minimal observability, which I can use to know if the switches are working. Its simply a Firebase real time database, which can be updated with Firebase API calls. It currently logs the times the switch started (e.g. maybe the power went out), and the last time the schedule was polled:
Some links that were useful for this project: