1. Project Function Introduction
DIY a small portable flashlight, lithium battery, with OLED display, convenient display of brightness level, remaining power, remaining time, no more power anxiety.
Designed with a magic buckle handle, it can be easily hung on the backpack strap or belt, convenient lighting, freeing hands, it can be said to be a great tool for walking the dog and shoveling shit.
(1) The MCU uses the National Technology N32G430C8L7, which is cheap and powerful.
(2) The flashlight has 5 gears: moonlight, low brightness, medium brightness, high brightness, and extreme. The brightness of each gear can be set separately.
(3) The flashlight is designed with a fuel gauge function to display the battery charge and discharge current and battery capacity, and estimate the remaining usage time.
(4) The shell was painted, and it was the first time to try 3D printing. The resin shell was printed on 3D Monkey, and the effect was good.
2. Project Properties
This project is: first public, original.
3. Open Source Agreement
Open Source Agreement: GPL3.0.
4. Hardware
(1) TYPEC interface, commonly used TP4056 lithium battery charging chip, here set to 580mA current.
(2) IP3005 lithium battery protection IC. INA199A1 is connected to the high end to detect the current passing through the battery. The amplification factor is 50 times.
The REF of INA199 is connected to the 1.25V reference voltage generated by TL432. When charging, the current VBAT->BAT+ output voltage is 1.25V+(0.02R/I)×50.
When discharging, the current BAT+->VBAT output voltage is 1.25V-(0.02R/I)×50, so that bidirectional current can be detected.
Due to the internal resistance of the battery, the detection voltage cannot reflect the battery power very well, so it is more accurate to detect the current to count the power.
(3) Linear voltage regulator ME6119C30 generates a 3.0V voltage for MCU and peripheral use, and controls the power on through the EN pin.
When SW1 is pressed, EN gets high level, LDO is turned on, POW-KEY gets high level, and MCU can turn on the power after detecting it, and at the same time control POW_EN high level to self-lock.
After turning on the power, SW1 can be used as a normal button. When USB is inserted, VUSB gets power and the power is turned on.
When shutting down, control POW_EN low level to completely turn off the power.
(4) SGM3732 forms LED boost constant current driver with a maximum current of 400mA. PWM controls SGM3732 DC dimming, no flicker, and high efficiency filter.
(5) Analog detection part, in turn, NTC LED temperature detection, USB voltage, battery voltage, NTC PCB temperature detection, reference voltage 1.25V.
(6) MCU uses N32G430C8L7 from National Technology, which is cheap and powerful. (
7) The display uses 0.91-inch 12864OLED, I2C bus, and 24C02EEPROM (to save battery power information).
【1】PCB front

【2】PCB back

【3】Cut copper foil as heat sink
【4】Apply thermal grease, 2mm thick.

---------------------------------------------------------------------------------
Some notes:
The 3D printed shell can hold a battery of up to 30*40*10mm, taking into account the space for the wires.
The battery can hold up to 1500mAh, the current of the ultra-bright mode is about 1.2A, and the battery life is at least 1 hour. However, since the working temperature of the 3D shell (resin) cannot be too high,
the ultra-bright mode (500lm) can only work for about 3 minutes at a time, and it will overheat and downgrade. The high-bright mode (200lm) can be always on, and the brightness of the gear can be set freely.
(Postscript, the room temperature is 36 degrees, the shell is installed, and the ultra-bright mode will downgrade after 1 minute)

If conditions permit, you can print a nylon shell, which can withstand high temperatures. The downgrade temperature can be higher.
The LED lens I bought is 13*7mm acrylic, with a variety of divergence angles to choose from. Here I use a 10-degree smooth surface and two 30-degree beaded surfaces. TB is very cheap, 70 cents per piece.
The smaller the lens angle, the more focused it is, and vice versa.
OLED can be changed to a universal one by yourself, and the PCB size is reserved.
Don't ask, this screen is in stock.