Contributed by Shenye, organized by Ai-Thinker
Ai-WB2: Web-Based Control of WS2812 LED Strips (Pending Testing)
WLED for BL602
A WLED implementation based on the BL602 MCU, supporting web-based control of WS2812 LED strips.
Features
- 🌈 RGB color control
- 💡 Brightness adjustment (0-255)
- 🎨 Multiple lighting effects:
- Solid color mode
- Rainbow effect
- Color gradient
- Breathing effect
- Color wheel effect
- 🌐 Web interface control
- 📱 Responsive design, accessible from phones and computers
- ⚡ Real-time status updates
Hardware Requirements
- BL602 development board (e.g., Ai-Thinker WB2)
- WS2812 LED strip
- 1K-2K ohm pull-up resistor
Hardware Connection
BL602 GPIO11 ----[1K-2K resistor]---- VCC(3.3V) BL602 GPIO11 -------------------- WS2812 data input BL602 GND ----------------------- WS2812 GND External power ------------------ WS2812 VCC(5V)
** Note: WS2812 must use GPIO11, and an external pull-up resistor is required.
Software Configuration
1. WiFi Configuration
Edit the main/wifi_execute.c file to modify the WiFi connection information
Click to expand full code
#
define
STA_SSID
"Your_WiFi_SSID"
// 替换为你的WiFi名称
#
define
STA_PASSWORD
"Your_WiFi_Password"
// 替换为你的WiFi密码2. LED Count Configuration
Edit the main/wled_server.c file to modify the LED count:
Click to expand full code
#
define
LED_COUNT 46
// 修改为你的LED灯珠数量Compiling and Flashing
- Enter the project directory:
Click to expand: cd
cd
applications/iot-solution/demo_wled- Compile the project:
Click to expand: make
make- Flash it to the development board:
Click to expand: make flash
make flashUsage
- After power-on, the board automatically connects to the configured WiFi network
- Check the IP address obtained by the device via the serial port
- Access that IP address in a browser
- Use the web interface to control the LED strip
Web Interface Features
- Power switch: turn the LED strip on/off
- Brightness control: slider to adjust brightness (0-255)
- Color selection: color picker to set the RGB color
- Effect modes: select different lighting effects
- Speed control: adjust the effect playback speed
API Endpoints
The project provides RESTful API endpoints for third-party control:
Get Status
Click to expand full code
GET /api/stateControl Endpoints
Click to expand full code
POST /api/power # 切换电源状态
POST /api/brightness?value=128 # 设置亮度 (0-255)
POST /api/color?r=255&g=0&b=0 # 设置RGB颜色
POST /api/effect?value=1 # 设置效果模式 (0-4)
POST /api/speed?value=128 # 设置效果速度 (1-255)Effect Modes
- 0 - Solid color mode: displays a single color
- 1 - Rainbow effect: cycles through rainbow colors
- 2 - Gradient effect: fades between two colors
- 3 - Breathing effect: brightness breathes up and down
- 4 - Color wheel effect: rotating color wheel
Troubleshooting
LED Not Lighting Up
- Check the GPIO11 connection and pull-up resistor
- Make sure the WS2812 is powered properly
- Check that the LED count is configured correctly
Cannot Connect to WiFi
- Check the WiFi SSID and password configuration
- Verify the WiFi signal strength
- Check the error messages on the serial output
Web Page Not Accessible
- Make sure the device is connected to WiFi and has an IP
- Check the firewall settings
- Try a different browser
Development Notes
The project is built on the following components:
- FreeRTOS: real-time operating system
- LwIP: TCP/IP protocol stack
- WS2812 driver: implemented based on the IR module
- HTTP server: a self-implemented lightweight server
License
This project is open source under the MIT license.
Contributing
Issues and Pull Requests are welcome to improve the project.
PS: Current progress — it compiles. No errors. Whether it runs and works, I don't know.


