Firmware reference

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.

功能

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)PA1TIM2 PWM
OLED displayPB6 / PB7I2C1
ESP-01S WiFi (NTP)PA9 / PA10USART1
ESP-01S resetPB0GPIO
Buttons (+/- UI Pwr)PA2 - PA5GPIO
Download Connection List (CSV)Download Source Code Framework (ZIP)