ESP ZeroCode AI · Community
Fish Tank Light
the light over my fish tank. instead of clunking on and off I want it to fade up slowly in the morning like a sunrise and fade down in the evening, and I want to control it from Apple Home as a normal dimmable light too
What it does
- Dimmable light — controlled from Apple Home as a standard Matter light
- Sunrise fade-up — fades on starting 8:00, ~20 min ramp
- Sunset fade-down — fades off starting 20:00, ~20 min ramp
- Matter over Wi-Fi — commissions into Apple Home via QR code
- Fixed schedule — times set at build time, no user configuration needed
- Flicker-free fades — high-resolution smooth PWM so fish are never startled
- Wall-clock time via Matter time sync (Apple Home), SNTP fallback — schedule runs on local time
- 12V LED bar driven by a low-side MOSFET dimmer (PWM on GPIO4)
- Status LED on GPIO5 — shows connection state (pairing vs connected)
- Manual override — brightness set in Apple Home sticks until the next scheduled event
- Physical button on GPIO10 — on/off toggle and long-press factory reset
- Single enclosure — ESP32 + dimmer together, placed away from splashes
- Single 12V mains adapter — powers the LED bar and the ESP32 (12V→5V buck)
Manual
Device Type
A retrofit smart controller for a white LED aquarium light. Replaces the clunky on/off switch with a Matter light that fades up like a sunrise each morning and fades down each evening, and behaves as a normal dimmable light in Apple Home.
Hardware
chip: esp32c3 — board: ESP32-C3-DevKitM-1 — gpios: PWM_dimmer: GPIO4 (LEDC, high-res PWM) — status_LED: GPIO5 — button: GPIO10 — peripherals: part: White LED bar (12V, built-in driver) — user-built, sits over the tank — drive: Low-side N-channel logic-level MOSFET (e.g. IRLZ44N / AO3400-class, sized to 3A) switching the 12V feed; gate from GPIO4 via ~100Ω–1kΩ series resistor · part: Connectivity status LED — drive: GPIO5 via series resistor (~330Ω–1kΩ) · part: Momentary button — drive: GPIO10, active-low with internal pull-up · part: Power — drive: Single 12V mains adapter; 12V feeds the LED bar through the MOSFET; 12V→5V buck regulator feeds the devkit 5V pin (onboard 3.3V LDO) — notes: GPIO8/9 avoided (boot-strapping, must sit high at reset); GPIO18/19 USB and GPIO20/21 console UART not usable. If the LED bar's driver exposes its own dim input, prefer that over PWM-switching the 12V feed.
Inputs
kind: button — label: Physical button on the box — hardware: GPIO10 — behavior: Short press toggles the light on/off; long press (~10s) factory-resets (wipes Matter pairing) · kind: controller — label: Apple Home — hardware: Matter over Wi-Fi — behavior: Standard on/off and brightness control; commands apply immediately and stick
Outputs
kind: light — label: Tank light — hardware: 12V LED bar via MOSFET PWM (GPIO4) — behavior: Dimmable 0–100%. Fades run as ~20-minute linear ramps executed in many small steps (e.g. every 100ms) so motion appears perfectly smooth. PWM at 10–20kHz with 12–13 bit resolution to eliminate visible flicker and stepping. · kind: led — label: Status LED — hardware: GPIO5 — behavior: Breathes while pairing/commissioning; solid once connected to Apple Home; off when unpowered
Connectivity
stack: Matter 1.4 — transport: Wi-Fi (ESP32-C3) — purpose: Apple Home control (on/off, brightness); BLE used only during commissioning
Commissioning
method: Matter QR code + manual pairing code — instructions: Power the box, scan the Matter QR (printed on the enclosure) with the Apple Home app; the status LED breathes during pairing and goes solid when connected. No extra steps.
Business Logic
powerOnBehavior: On power-up, restores the last on/off + brightness state from Matter storage; the schedule then runs from wall-clock time. — automationRules: name: Sunrise — schedule: Daily at 08:00 — action: Fade from current level to 100% over ~20 minutes (stepless) · name: Sunset — schedule: Daily at 20:00 — action: Fade from current level to 0% over ~20 minutes · name: Manual override — schedule: Anytime — action: Any manual on/off/brightness from Apple Home or the button sticks exactly where set until the next scheduled event; the next fade then resumes from the current level — dayToDayOperation: Normal use is entirely from Apple Home (scenes, schedules, Siri). The box sits beside the tank; the button is a backup. The daily schedule is fixed at build time (08:00/20:00, 20-min ramps) and requires a firmware rebuild to change.
Factory Reset
trigger: Long-press the button ~10s, or Matter 'reset to factory defaults' — effect: Wipes Matter commissioning (device must be re-paired to Apple Home). The schedule itself is fixed in firmware and unchanged.
Failure Modes
scenario: Wi-Fi down / router off — behavior: Apple Home control unavailable, but the daily schedule still runs — time comes from Matter time sync with SNTP fallback; if neither is reachable, the device uses its last known time · scenario: Cloud unreachable — behavior: No dependency — control is local-network only (no cloud account required) · scenario: Power blip — behavior: On reboot, restores the previous on/off + brightness state · scenario: Button held during boot — behavior: No effect — button is on non-strapping GPIO10, so boot mode is never affected
Power Management
batteryPowered: false — note: Mains-powered via a single 12V adapter; no sleep mode (Matter light must stay reachable). Idle current is modest.
Custom Behavior
Fade engine: 20-minute ramps executed as many small PWM steps so brightness changes are imperceptible per step — no sudden jumps for the fish. High PWM frequency (10–20kHz) with high resolution avoids visible flicker. Schedule and fade parameters are compile-time constants.
Published 18 Aug 2026
Built with ESP ZeroCode AI — describe a device, get production firmware.
Terms of Service · Privacy Policy