All projects

Project 06 · Embedded systems · 2024

Car Battery Monitor

An embedded system that reads a car battery’s voltage in real time and shows its health on an LCD — before a flat battery surprises you.

Top-down illustration of an electronics workbench: a breadboard with jumper wires, an LCD module, a bench power supply, a multimeter and a car battery

Overview

A PIC16F877A microcontroller measures the battery through a voltage divider, converts the reading with its 10-bit ADC and prints both the voltage and a health status on a 16 × 2 LCD. I designed the divider circuit and wrote the firmware in embedded C.

The photo is the working prototype on the bench, reading 13.3 V — Status: OK.

The prototype on a breadboard: a PIC microcontroller wired to a 16×2 LCD reading ‘Battery: 13.3V, Status: OK’, powered from a bench supply
the prototype on the bench

How it works

  1. ScaleA 1 : 4 voltage divider brings the battery voltage into the ADC’s 0–5 V range on pin RA0/AN0.
  2. MeasureThe 10-bit ADC samples the input against VDD/VSS and the firmware multiplies the result back by four.
  3. ClassifyThe reading is mapped to one of six health states (table below).
  4. DisplayVoltage on the first LCD row, status on the second — refreshed every second and redrawn only when the value moves by 0.1 V or more.

Health states

Battery voltageLCD status
above 14.8 VHIGH
14.4 – 14.8 VCHARGING
13.8 – 14.4 VGOOD
12.6 – 13.8 VOK
11.5 – 12.6 VLOW
below 11.5 VCRITICAL

What’s in the source code

A single C source file for Microchip’s XC8 compiler.

  • voltage-monitoring-sys.cADC setup, 4-bit LCD driver on PORTD, the status thresholds and the main loop
  • README.mdSystem overview and hardware description