STM32 Smart Lamp Project - Clean Slate
A modular STM32 SPL firmware for a WiFi lamp: NTP-scheduled on/off, PWM brightness, and an OLED UI you toggle from the buttons. Built on a non-blocking AT state machine with retry and backoff, so the buttons and display stay responsive even when the network lags. Four source files, ready to drop into a Standard Peripheral Library project.
硬件警告:严禁使用 2N7000 驱动 5W 灯珠,请使用 AO3400/IRF540N/AOD4184 功率 MOSFET!
功能
01
NTP 网络对时
ESP-01S 联网后自动获取标准时间,按设定的开/关时间表点亮或熄灭灯,无需手动设时。
02
PWM 亮度调节
PA1 输出 1000 级 PWM 占空比,按键单击微调、长按连续调节,亮度即时生效。
03
UI 页面切换
OLED 在「时钟 + 亮度」与「WiFi / NTP 状态」页之间切换,电源键在自动 / 常开 / 常关之间循环。
04
非阻塞可靠架构
ESP-01S 采用非阻塞 AT 状态机,失败按指数退避重连并可发 AT+RST 复位;中断安全的环形缓冲、仅变化时写 PWM。网络延迟时按键与显示始终响应。
LED light (5V/5W)
OLED display
ESP-01S WiFi (NTP)
ESP-01S reset
Buttons (+/- UI Pwr)