Introduction: Battery Tester With Arduino Nano

About: My projects, my passion.

Battery tester with Arduino Nano

🔋 In this project, I take you into the world of creative electronics by building a custom Battery Tester, using Arduino! From the initial design with CAD drawing and 3D printing, through detailed assembly and programming, I show you every step of this exciting project.


🌟 Don't miss the technical details, the creative moments and, above all, the final test where our Battery Tester is put to the test. This video is perfect for electronics enthusiasts, makers and anyone who loves DIY.

Supplies

Step 1: Programming the Arduino Nano Module

/*
  Channel Name: Romano Giuseppe - Electronic & CNC LAB
  Channel Link: https://www.youtube.com/@Electronic.CNCLab
  Project Description: Battery tester with Arduino Nano
  In this project, I take you into the world of creative electronics
  by building a custom Battery Tester, using Arduino! From the
  initial design with CAD drawing and 3D printing, through
  detailed assembly and programming,
  I show you every step of this exciting project
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd(0x27, 16, 2);
const int batteryPin = A0;
const int batteryPin9V = A1;  // Pin aggiuntivo per la batteria da 9V
const int switchPin = 2;      // Pin per lo switch
// Definizione deifattori di correzione
const float FATT_CORR_AA_AAA = 0.926;
const float FATT_CORR_9V = 0.924;
// Caratteri personalizzati
byte customChars[5][8] = {
  { B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000 },
  { B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000 },
  { B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100 },
  { B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110 },
  { B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111 }
};


void setup() {

  lcd.init();
  lcd.backlight();
  pinMode(batteryPin, INPUT);
  pinMode(batteryPin9V, INPUT);      // Imposta il pin per la batteria da 9V come ingresso
  pinMode(switchPin, INPUT_PULLUP);  // Configura lo switch pin come input con pull-up


  // Carica i caratteri personalizzati nell'LCD
  for (int i = 0; i < 5; i++) {
    lcd.createChar(i, customChars[i]);
  }
  //  analogReference(EXTERNAL); // Imposta la tensione di riferimento a quella fornita al pin AREF
}


void loop() {
  // Leggi lo stato dello switch
  bool switchState = digitalRead(switchPin);


  float voltage;
  if (switchState == LOW) {  // Se lo switch è in una posizione
    // Leggi la tensione della batteria standard
    voltage = analogRead(batteryPin) * (5 / 1023.0) * FATT_CORR_AA_AAA;
  } else {
    // Leggi la tensione della batteria da 9V
    voltage = analogRead(batteryPin9V) * (5.0 / 1023.0) * 2 * FATT_CORR_9V;
  }


  // Calcola i segmenti per la barra grafica
  int barSegments = map(voltage * 1000, 0, (switchState == LOW) ? 2000 : 10000, 0, 80);


  // Visualizza la barra grafica e la tensione
  lcd.setCursor(0, 0);
  for (int i = 0; i < 16; i++) {
    if (barSegments > 5) {
      lcd.write((uint8_t)4);  // Carattere completamente pieno
      barSegments -= 5;
    } else {
      if (barSegments > 0) {
        lcd.write((uint8_t)(barSegments - 1));
      } else {
        lcd.print(" ");
      }
      barSegments = 0;
    }
  }

  lcd.setCursor(0, 1);
  lcd.print("                ");  // Pulisci con spazi vuoti
  // Stampa il nuovo valore di tensione
  lcd.setCursor(0, 1);
  lcd.print(voltage, 2);  // Mostra il valore di tensione con 2 cifre decimali
  lcd.print(switchState == LOW ? " V*[1,5V] " : " V*[  9V]");


  delay(1000);
}


Step 2: 3D Printed Parts

Step 3: Details of the Assembly Phase

Details of the assembly phase

Step 4: Practical Implementation

Step 5: Wiring Diagram and Practical Diagram

For easier reading, here is the wiring diagram.