Main Content

Sunset Switch - Overkill

Over engineered sunset switch for exterior LED lights. Gets time of day and sunset time updates from web. Ode to the Wemos D1 Mini.

Motivation
We eventually got tired of the generic solar recharged lawn lights that light the edge of our driveway at night (they all eventually fail) and replaced them with a string of mains powered LED lights.

Now we needed a sunset driven switch to automatically turn them on for a few hours after sunset every day. Time for some Wemos D1 Mini love and some overkill.

Philosophy
If it worked yesterday and you didn’t touch it, then it should work today. Forever. No updates. No “have you tried turning the power on and off again”.

Also, when building something, first try using the parts on hand before buying new bits and pieces.

Wemos LOLIN D1 Mini
In case it wasn’t obvious, I like these microcontroller boards a lot. I’ve tried to migrate to newer shinier ones but I just keep coming back to this old favorite for one reason: it just works.

Key features:

- small enough form factor
- powerful enough with enough storage
- relatively cheap
- always trivial to program from the Arduino IDE
- old and mature enough to have good drivers for 3rd party peripherals
- reliable built-in WiFi with good client and server drivers

Features
Here’s what I want the device to be capable of:

- Lights on at sunset for a configurable amount of time
- Override mode to easily turn them on at other times (like 3am for example)
- Automatically keep time (none of this flashing 12:00 rubbish)
- Automatically adjust sunset time through the year
- Simple browser web interface to use the override, inspect and configure
- Tap to display IP address (for when it inevitably gets re-assigned in future)
I won’t give paint-by-numbers instructions. Instead, I’ll just supply a full schematic and the source of my Arduino sketch along with some notes on the implementation each of the features. I suspect nobody will build this exact device but may well benefit from copying one or more of the features for some other purpose.

Web Interface
I take advantage of the built-in Wifi and web functionality of the D1 mini. I’ve used both the server and the client parts in other projects so I already had code to get past most of the common gotchas. I leave the serial output in the live version so I can easily hook up a USB cable and diagnose initialization when it fails in future.”

Link to article