SALES INQUIRIES: 1 (888) 767-9864

Basic Battery Voltage Reader with Arduino :: Student Project

When you’re just getting started with programming Arduino, sometimes the simplest projects can be very instructive.

This basic battery voltage reader put together by Pierce Harvey, a customer of Programming Electronics Academy since April of 2018, is an example of just that, a simple project designed to help him make sure he had some basic programming concepts down.

Electronics Bench with Arduino, wires and batteriesPierce, why the heck did you build a/the Basic Battery Voltage Reader?

I built this as a stepping stone to incorporate into my next project which will be a battery level indicator using LED’s to indicate battery strength.

I needed a simple project to help understand things before I progressed.

How does your project work?

It takes the input from a AA or AAA or rechargeable battery or any voltage source 5 volts and below, calculates it into a value the Arduino can understand and displays it on the serial monitor.

Sorta like a voltmeter but different.

What was your biggest struggle as you worked through this project?

For me, it was fairly easy thanks to a previous lesson in the series “Using analogRead()” in “The Bread and Butter of Microcontrollers:” module.

Then I just had to figure out how to hook up the circuit.

Then, I took the GND pin on the board and plugged it into the negative rail on the breadboard, next I plugged the positive battery lead into the A0 pin slot and the negative lead to the negative breadboard rail.

I could have just plugged it into the Arduino but since it was the first step in my project I just used the breadboard.

Did the project end up as you expected?

Yes it turned out as I hoped showing “Voltage = 1.9” from a rechargeable Battery.

Looking back on this project, what can you say you have learned about programming and/or electronics through the creation process?

I learned to use the basic programming process and put it to real world use.

How do you power your project?

Via USB from my computer

Was the training at Programming Electronics Academy able to help you build your skill?

Absolutely helped me to get my head around this programming Arduino stuff.

Arduino Code:

Basic Voltage Reader

byte voltPin = A0; //assigns the voltage input pin
Int readValue; //value received from the voltPin
float voltage; //declare the voltage variable

void setup() {
  pinMode(voltPin, INPUT); //input variable dc voltage
  Serial.begin(9600); //start serial port

void loop() {
  int readValue = analogRead(voltPin); //read pin A0 value
  voltage = readValue * (5.0 / 1023.0); //calculates real world voltage
  Serial.print(“Voltage = “); //show “voltage before value on serial monitor
  Serial.println(voltage); //show value on serial monitor
  delay(250); //250ms delay

About Pierce:

Pierce is retired and has been into electronics for quite a while, but now finally feels like he has some more time to tinker with stuff like Arduino.  He is brand new to programming.

Leave a Comment