Daylight Wake Relay
RTC-driven mains controller firing a fixed-time circuit at astronomical dawn, holding ±2 s/yr drift on a battery-backed DS3231.
A — Problem
A grow-light timer running on a mechanical 24-hour dial was drifting by several minutes a week. In winter, that margin matters — the difference between triggering at civil and astronomical dawn changes spectrum exposure enough to affect germination timing.
B — Constraints
The replacement had to fit the existing DIN rail slot, switch a 230 V / 10 A load directly, run for at least five years on a CR2032 backup without mains, and be re-programmable without a laptop in the room. No cloud, no wifi, no dependencies.
C — Approach
The core is a DS3231 RTC — its temperature-compensated crystal keeps better than ±2 ppm, translating to under 2 seconds drift per year. An ATmega328P reads the RTC over I²C, compares against a lookup table of daily astronomical dawn times baked into flash at compile time, and drives an SSR through an optoisolator.
The enclosure started as a stock ABS DIN box; I added a 3D-printed faceplate for the seven-segment display and two tactile buttons that let me nudge the time offset ±15 minutes for seasonal adjustment without reflashing.
D — Result
Running since October 2023 — eleven months at time of writing. Total drift: 0.8 seconds against GPS reference. The design is documented so I can build a second unit in an afternoon.