Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Solar-Powered Battery Monitoring System with Arduino Nano and OLED Display

View and Edit Project In Cirkit DesignerImage of Solar-Powered Battery Monitoring System with Arduino Nano and OLED Display

Circuit Documentation

Summary

This circuit is designed to manage and monitor the charging of a 18650 Li-ion battery using a solar cell. The circuit includes a LiPo battery charger module, a PowerBoost 1000 Basic Terminal USB for voltage regulation, an INA219 sensor for current and voltage measurement, an Arduino Nano for control and data processing, and a 0.96" OLED display for visual feedback.

Component List

  1. Solar Cell

    • Description: Converts sunlight into electrical energy.
    • Pins: +, -
  2. LiPo Battery Charger Module

    • Description: Manages the charging of the Li-ion battery.
    • Pins: B-, B+, OUT-, OUT+
  3. PowerBoost 1000 Basic Terminal USB

    • Description: Boosts the battery voltage to a stable 5V output.
    • Pins: VBAT, GND, ENABLE, LBO, 5.0V
  4. 18650 Li-ion Battery

    • Description: Rechargeable lithium-ion battery.
    • Pins: +, -
  5. INA219

    • Description: Current and voltage sensor.
    • Pins: VCC, GND, SCL, SDA, VIN -, VIN +
  6. Arduino Nano

    • Description: Microcontroller for control and data processing.
    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
  7. 0.96" OLED

    • Description: Display for visual feedback.
    • Pins: GND, VDD, SCK, SDA

Wiring Details

Solar Cell

LiPo Battery Charger Module

PowerBoost 1000 Basic Terminal USB

18650 Li-ion Battery

INA219

Arduino Nano

0.96" OLED

Code Documentation

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <INA219.h>

// Initialize with default I2C address (0x40)
INA219 ina219(0x40);

LiquidCrystal_I2C lcd(0x27, 16, 2);

// Battery specifications
const float BATTERY_CAPACITY = 2000.0;  // in mAh
const float FULL_VOLTAGE = 4.2;
const float EMPTY_VOLTAGE = 3.2;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  
  if (!ina219.begin()) {
    Serial.println("Failed to find INA219 chip");
    while (1) { delay(10); }
  }
  
  lcd.init();
  lcd.backlight();
}

void loop() {
  float voltage = ina219.getBusVoltage_mV();
  float current = ina219.getCurrent_mA();
  
  float batteryPercentage = map(voltage * 100, 
                               EMPTY_VOLTAGE * 100, 
                               FULL_VOLTAGE * 100, 
                               0, 
                               100);
  batteryPercentage = constrain(batteryPercentage, 0, 100);
  
  float chargingRate = (current > 0) ? current : 0;
  
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Batt: ");
  lcd.print(batteryPercentage, 1);
  lcd.print("%");
  
  lcd.setCursor(0, 1);
  lcd.print("Chrg: ");
  lcd.print(chargingRate, 1);
  lcd.print("mA");
  
  Serial.print("Battery: ");
  Serial.print(batteryPercentage);
  Serial.print("% | Charging Rate: ");
  Serial.print(chargingRate);
  Serial.println("mA");
  
  delay(1000);
}

This code initializes the INA219 sensor and the OLED display, reads the battery voltage and current, calculates the battery percentage and charging rate, and displays this information on the OLED display and the serial monitor.