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

Battery-Powered Voltage Monitoring System with OLED Display using ATmega328P

View and Edit Project In Cirkit DesignerImage of Battery-Powered Voltage Monitoring System with OLED Display using ATmega328P

Circuit Documentation

Summary

This circuit is designed to measure and display voltage using an OLED display and a voltage sensor. The core of the circuit is an Arduino Nano 3.0 ATmega328P microcontroller, which reads the voltage from the sensor and displays it on the OLED screen. The circuit is powered by a 3.7V LiPo battery, which is charged using a battery charger module. A step-up boost converter is used to provide a stable 5V supply to the microcontroller and other components.

Component List

  1. Nano 3.0 ATmega328P Type-C USB CH340 Controller Board

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: D13, 3V3, REF, A0, A1, A2, A3, A4, A5, A6, A7, 5V, RST, GND, VIN, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, RX0, TX1, D12
  2. OLED 1.3"

    • Description: 1.3-inch OLED display.
    • Pins: GND, VCC, SCL, SDA
  3. Voltage Sensor DC 25V

    • Description: Sensor to measure DC voltage up to 25V.
    • Pins: +, -, output, gnd, vcc
  4. 2Pin Push Switch

    • Description: Simple push-button switch.
    • Pins: Input +, Output +
  5. 3.7v LiPo

    • Description: 3.7V Lithium Polymer battery.
    • Pins: +Ve, GND
  6. Battery Charger 4.2v

    • Description: Module to charge 3.7V LiPo batteries.
    • Pins: OUT+, OUT-, B+, B-, IN+, IN-
  7. Black Panel Mount 4mm Banana Socket

    • Description: Black banana socket for panel mounting.
    • Pins: Black_Pin
  8. Red Panel Mount 4mm Banana Socket

    • Description: Red banana socket for panel mounting.
    • Pins: Red_Pin
  9. 5v Type C Dc Socket

    • Description: Type-C DC socket for 5V input.
    • Pins: - Negative, + Positive
  10. Step Up Boost 3v-5v

    • Description: Boost converter to step up voltage from 3V to 5V.
    • Pins: Vi, GND, Vo

Wiring Details

Nano 3.0 ATmega328P Type-C USB CH340 Controller Board

OLED 1.3"

Voltage Sensor DC 25V

2Pin Push Switch

3.7v LiPo

Battery Charger 4.2v

Black Panel Mount 4mm Banana Socket

Red Panel Mount 4mm Banana Socket

5v Type C Dc Socket

Step Up Boost 3v-5v

Documented Code

void setup() {
  // put your setup code here, to run once:
#include "U8g2lib.h"

U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/U8X8_PIN_NONE);
int progress = 0;         // progress in degrees
int progress_inc = 2;     // progress increment
char string_buffer[10];   // helper buffer for converting numbers into c-style strings
float adjusted_progress;  // adjusted progress for smoother animation

void setup() {
  u8g2.begin();          // begin u8g2
  // Serial.begin(115200);  // begin serial communication

  u8g2.sendBuffer();
  delay(3000);
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_luBIS18_tr);
  char title[] = "Physics";
  char prof[] = "Prof. Ace Duque";
  int centerY = (u8g2.getDisplayHeight() - 24) / 2;
  int centerX = (u8g2.getDisplayWidth() - (strlen(title) * 14)) / 2;  // Center horizontally
  u8g2.drawStr(centerX, 30, title);

  // u8g2.setFont(u8g2_font_6x13_me);
  // u8g2.drawStr((u8g2.getDisplayWidth() - (strlen(prof) * 14) / 2), 50, prof);
  u8g2.sendBuffer();
  delay(2000);
  showMembers();
  u8g2.clearBuffer();
}

// those two functions (clamp and smoothstep) are used to add some easing to the animations of the main value
float clamp(float x, float lowerlimit = 0.0f, float upperlimit = 1.0f) {
  if (x < lowerlimit) return lowerlimit;
  if (x > upperlimit) return upperlimit;
  return x;
}

float smoothstep(float x, float edge0 = 0.0f, float edge1 = 1.0f) {
  // Scale, and clamp x to 0..1 range
  x = clamp((x - edge0) / (edge1 - edge0));

  return x * x * (3.0f - 2.0f * x);
}

#define MAX_VALUE 25  // Maximum value for the gauge
void showMembers() {
  const char* names[] = {
    "GROUP III", "",
    "Escarlan, Sherwin",
    "Lopez, Adrianna Rose",
    "Lopez, Mark Anthony",
    "Maigue, Hermie",
    "Manigos, Troy Mike",
    "Medio, Tuesday Smile",
    "Mingute, Agustin", "",
    "BS-IS 403",
    "A.Y 2024-2025"
  };
  const int num