This circuit is designed to monitor the voltage of a 12V battery and display the voltage and charge percentage on an LCD screen. It also uses an Arduino Nano to control multiple LEDs and a piezo buzzer. The Bluetooth HC-06 module is used for wireless communication, allowing the battery status to be sent to a remote device.
Arduino Nano
Bluetooth HC-06
Piezo Buzzer
LED: Two Pin (red)
LED: Two Pin (green)
LED: Two Pin (blue)
LED: Two Pin (yellow)
LED: Two Pin (orange)
Resistor (220 Ohms)
Resistor (10k Ohms)
Resistor (2k Ohms)
12V 200Ah Battery
LCD screen 16x2 I2C
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
// Initialize the LCD with I2C address 0x27, 16 columns, and 2 rows
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Bluetooth module connections
SoftwareSerial BTSerial(0, 1); // RX, TX
// Define pin numbers
const int ledPins[] = {2, 3, 4, 5, 6};
const int buzzerPin = 7;
const int batteryPin = A0; // Analog pin to read battery voltage
void setup() {
// Initialize LED pins as outputs
for (int i = 0; i < 5; i++) {
pinMode(ledPins[i], OUTPUT);
}
// Initialize buzzer pin as output
pinMode(buzzerPin, OUTPUT);
// Initialize serial communication for Bluetooth
BTSerial.begin(9600);
// Initialize serial communication for debugging
Serial.begin(9600);
// Initialize the LCD
lcd.begin();
lcd.backlight();
}
void loop() {
int batteryLevel = analogRead(batteryPin);
float voltage = batteryLevel * (5.0 / 1023.0) * ((10.0 + 2.0) / 2.0); // Convert to voltage
// Map voltage to percentage (assuming 20V to 28V range)
int percentage = map(voltage, 20, 28, 0, 100);
Serial.print("Battery Voltage: ");
Serial.print(voltage);
Serial.print("V, Percentage: ");
Serial.print(percentage);
Serial.println("%");
// Send data over Bluetooth
BTSerial.print("Battery Voltage: ");
BTSerial.print(voltage);
BTSerial.print("V, Percentage: ");
BTSerial.print(percentage);
BTSerial.println("%");
// Display data on LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Voltage: ");
lcd.print(voltage);
lcd.print("V");
lcd.setCursor(0, 1);
lcd.print("Charge: ");
lcd.print(percentage);
lcd.print("%");
// Determine LED states based on percentage
for (int i = 0; i < 5; i++) {
if (percentage > (i + 1) * 20) {
digitalWrite(ledPins[i], HIGH);
} else {
digitalWrite(ledPins[i], LOW);
}
}
// Sound buzzer if battery level is below 30%
if (percentage < 30) {
for (int i = 0; i <