C library for determining a battery’s state of charge (SoC) using the ADC (Analog-to-Digital Converter) on an ATmega328P microcontroller.
This project reads the battery voltage, calculates the state of charge, and displays the result on a 20×4 LCD display.
The ADC-battery-SOC library provides a simple and modular interface to:
- Measure battery voltage with the ATmega328P ADC
- Convert the voltage to a percentage representing battery SoC
- Display the result on a connected LCD module
It is designed for Arduino Nano over Atmel Studio, making it easy to integrate into embedded projects where battery monitoring is required.
- Accurate battery voltage measurement via ADC
- State-of-charge calculation (0–100%)
- Integration with 20×4 LCD displays
- Modular design for reuse in other projects
- Tested on Arduino Nano / ATmega328P
- Microcontroller: ATmega328P (Arduino Nano)
- Development environment: Atmel Studio
- Display: LCD 20×4 (HD44780-compatible)
- Power source: Single-cell battery (or equivalent)
- Connect the battery voltage to an ADC pin (with voltage divider if needed).
- Connect the 20×4 LCD to the microcontroller using the LCD library.
- Initialize the ADC and LCD in your project.
- Call the library functions to read the battery voltage and display the state of charge.
Refer to the source code for function definitions and example usage.
✔️ Stable — tested on Arduino Nano with 20×4 LCD.
This project is open-source and intended for educational and embedded development use.
