This repo now uses Arduino IDE workflow for STM8S boards.
- Main sketch:
arduino_lipo_charger.ino
- Mains adapter detection
- Battery voltage monitoring with ADC divider
- Boost enable control for backup mode
- Low-battery cutoff with hysteresis
- Status LED and buzzer alert
- MCU: STM8S103F3 (or compatible STM8S board)
- Programmer: ST-Link V2
- Power stage: 2S Li-ion + 2S BMS + 8.4V charger + 12V boost
- Install Arduino IDE 2.x.
- Open
File -> Preferences. - Add this Boards Manager URL:
https://raw.githubusercontent.com/tenbaht/sduino/master/package_sduino_stm8_index.json - Open
Tools -> Board -> Boards Manager, install STM8 core package. - Open sketch file
arduino_lipo_charger.ino. - In
Tools, select your STM8 board (example:STM8S103F3P6). - Select programmer as ST-Link V2 (name may appear as
STLink,STLinkV2, or similar). - Use
Sketch -> Upload Using Programmer(Ctrl+Shift+U).
- ST-Link
SWIM-> STM8SWIM - ST-Link
GND-> STM8GND - ST-Link
3V3/5V-> target VCC (as required by board) - Optional: ST-Link
RST-> STM8NRST
PB4: mains detect inputPD3: boost enable / Q3 gate driver controlPD4: buzzer outputPC5: status LED outputA2orPD2: battery ADC input
If your board mapping differs, edit pin constants at the top of arduino_lipo_charger.ino.
Edit values in sketch:
BATT_CUTOFF_MV(default6400)BATT_RECOVER_MV(default7000)LOOP_DELAY_MS