This ESP32 driven project simulates daylight shining through a window, and it does it super well. At the beginning of each day,
the times for dawn, sunrise, sunset, and dusk for the current location are retrieved using the SunriseSunset API
in UTC format, and offset for the current location.
At dawn, the light produced by the WS2812B lightstrip fades in gradually as a warm orange and increases in brightness as the current time approaches sunrise.
Using a custom FastLED color palette defining 256 color indices, golden hour is simulated in both the morning and evening, with the light fading from orange-to-white, and white-to-orange respectively.
The ESP32 connects to the provided wifi network, opens an http instance, and connects to Network Time Protocol server to access the current time in unix format.
This is done only once on boot to avoid unneccesary network usage.
Accurate sunlight-cycle data for the current day is retrieved from SunriseSunset API in unix format.
These retrieved times are used to define important time-markers through the day that begin various processes.
The current time from the NTP is leveraged against these dynamic "checkpoints" - the "percentage" of which the current time has progressed
through the currently active time "section" (e.g. [sunrise -> noon]) is a component of the calculation for the current brightness and color of the light.
The microcontroller and lightstrip are powered independently using separate power supplies. An inline switch
rests between the positive line for the lightstrip and the power supply itself. This allows you to turn the lights off without affecting
the program running. Otherwise, the microcontroller would need to connect to the network and make various requests any time you want to turn the lights off.
The current time is accessed only once to avoid redundancy. The sunlight cycle data for the current day is accessed on boot, then the data
for each subsequent day is accessed at midnight. To access the data, the microcontroller connects to wifi, then terminates its connection when it
has successfully retrieved the necessary data.
Parts:
1. ESP32 Microcontroller
2. WS2812B Lightstrip
3. 20AWG Wire
4. 5V DC connectors (Male & Female)
5. Inline 5V DC switch
6. 16V 1000uf Capacitor
7. Diffuser sheet recylced from monitor
8. 2x Picture frame & hinges