ZTFNa

Bicycle RGB breathing light

 
Overview
 
 
Hardware Function:
 
       This hardware implements a function that displays different lighting effects based on the bicycle's movement status, illuminating the ground near the bicycle to achieve a cool, aesthetically pleasing, and warning effect. Currently, the effect is a blue breathing light effect during normal riding, acceleration, and gliding; the light turns red when braking, and returns to the blue breathing light effect after braking ends. When the bicycle is stationary, an RGB scrolling light effect is displayed for two seconds before turning off and entering sleep mode. It will re-enter working mode if the bicycle resumes movement within two minutes. If the bicycle remains stationary for more than two minutes, it will automatically shut down and require manual restart.
 
 
Implementation Idea:
 
 
Overall Idea: A six-axis gyroscope is used to identify the current acceleration of the bicycle's movement, dividing it into two states: stationary and moving. Then, based on the magnitude and sign of the acceleration (mainly the Y-axis), braking and normal riding states are distinguished. After determining the different states, the microcontroller executes relevant code to control the two RGB lights to change the lighting effects.
 
 
Hardware Selection:
 
Main MCU: N32G430C8L7 (similar to STM32)
Six-axis gyroscope: MPU6050 (module chip removed)
RGB LEDs: WS2812B
3.3V voltage regulator: ME6211C33M5G-N
5V to 4.2V charging chip: TC4056A
Battery: 600mA aluminum-pack battery
 
Software Protocol:
 
MPU6050 and N32 use IIC communication;
N32 and WS2812B use DMA communication
 
 
 
Implementation Details:
 
Power-on: The ME6211 voltage regulator chip has an EN pin. A high level is triggered by a button, and after the 3.3V voltage appears, the N32 powers on and operates, maintaining the ME6211's operation by generating a high level through GPIO, achieving power self-sustaining.
 
Power-off: After two minutes of inactivity, the EN pin is switched to a low level, and the chip shuts down. Alternatively, power-off can be triggered by a button.
 
Power Consumption: To minimize power consumption, this hardware has been tested and found to operate normally at system clock frequencies as low as 16MHz (N32 up to 128MHz). The MPU6050 has also been optimized for low power consumption, performing six-axis sampling at 50Hz. The WS2812 breathing light design further reduces power consumption. In actual testing, it only needed to be charged once every six months (light use, approximately half an hour of riding every two days, including two months without riding).
 
Waterproofing: Due to the nature of bicycles, especially the placement of this hardware, stability in outdoor operation is required. It must be waterproof, dustproof, and moisture-proof. The circuit board is sealed on both sides with conformal coating.
 
Board Shape: Because the bottom structure of each bicycle is different, the PCB board needs to be highly customized, with the shape designed according to the actual situation.
 
Structure: This device adopts a double-layer structure with three isolated PCB boards. The bottom board is the main board, with the LED lights below corresponding to the holes on the bicycle. The gap in the lower layer comes from the microswitch; with the middle board, the pressing device can be powered on. The upper layer houses the battery, which is led to the lower layer through holes on the PCB. The top panel is covered with a waterproof material (such as tape) for waterproofing and dustproofing. The gap between the upper and lower layers needs to be sealed to prevent water ingress; hot melt adhesive is used here. Hot melt adhesive is elastic and also makes it easy to press the switch. The Type-C charging port needs to be plugged with adhesive.
Debugging: The space under the bicycle is limited, making DAP debugging inconvenient. To debug the device on the bicycle, the SWD and SCK pins are connected to the Type-C port. A conversion PCB is designed to bring them to an easily accessible debugging location. (Connector)
 
 
 
Implementation challenges:
 

Due to the different bicycle structures, a custom design is required, resulting in varying PCB shapes. (However, it can be placed in other locations, such as the rear seat of the bicycle, which would greatly reduce the difficulty.)
The waterproof and dustproof structural design requires strong hands-on skills.
A certain understanding of coding is also necessary.

 
 
Production Process:
 
Bilibili video link;
 
 
Process images:
 
 
 
 
 
Random thoughts:
 
This project started last September. Initially, I was adjusting the IIC protocol of the MPU6050 and the DMA control of the WS2812B. I encountered many problems, such as incorrect gyroscope data (later discovered to be an IIC initialization issue), the breathing effect of the LED (involving HSV to RGB space conversion), how to solve the noise problem of the gyroscope module, how to design waterproofing and dustproofing, how to ensure portability (this device is now detachable), how to achieve extremely low power consumption, and soldering and assembly were minor issues. Later, due to the pressure of the postgraduate entrance exam, I temporarily put it aside. After finishing the exam and returning home, I picked up the project again and solved all the above problems. So, there are really many things to consider when making an engineering project. This device has been exposed to the elements on my bicycle for eight months now (experiencing both light and heavy rain), and has only been charged two or three times, indicating that my design is quite good.
 
Strictly speaking, this project is my first self-designed project (although the timeline is quite long), and the code was debugged bit by bit—it was arduous. The project still has 29 warnings after compilation... but it works, so it's fine.
 
My bicycle has been with me for four years; I couldn't bear to sell it after graduation, so I mailed it to my new school and continued riding it. Part of the reason is this hardware; I've poured a lot of effort into it, giving it a soul. The breathing light effect makes it seem like the bike truly has a life of its own.
 
I think this project was quite challenging to implement in various aspects, and the code structure might not be perfect, so I'm sharing it as a way. Feel free to message me privately if you have any questions, let's learn together.
 
 
 
 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-26 15:25:25
  • Bluetooth Sports Heart Rate Headphones
  • Method of Realizing Square Wave Output Using DSP Timer
  • [Question] Flash erase time is very strange
  • Nucelo-L432KC6 Development Board Hardware Analysis
  • Combined application of PLC and frequency converter
  • 【Show Time】Maker Robot PK Stage--EEWORLD University Hall

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号