© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
DevHeads IoT Integration ServerDIIS
DevHeads IoT Integration Server•15mo ago•
6 replies
aymen ammari

How can I correctly measure battery voltage using the A0 pin on Arduino?

I want to know when the batteries of a model are getting low.
The 5 AA batteries are over 5 volts so I cannot check the end voltage.
I make a tap after the second AA battery and take it to pin A0.
Unfortunately a meter shows a voltage of 2.39 but A0 shows 1.18!!

What is the correct way to get a real reading?

void doshowvoltage()
  {
    adcValue = analogRead(A0); // Convert analog of pin A0 to digital
    voltage = adcValue * (5.0 / 1023.0); // Calculate voltage according to digital
    Serial.println(adcValue);
    Serial.println(voltage);
    matrix.beginDraw();
    matrix.stroke(0xFFFFFFFF);
    matrix.textFont(Font_4x6);
    matrix.beginText(0, 1, 0xFFFFFF);
    matrix.println(voltage);
    matrix.endText(0);
    matrix.endDraw();
  }

void doshowvoltage()
  {
    adcValue = analogRead(A0); // Convert analog of pin A0 to digital
    voltage = adcValue * (5.0 / 1023.0); // Calculate voltage according to digital
    Serial.println(adcValue);
    Serial.println(voltage);
    matrix.beginDraw();
    matrix.stroke(0xFFFFFFFF);
    matrix.textFont(Font_4x6);
    matrix.beginText(0, 1, 0xFFFFFF);
    matrix.println(voltage);
    matrix.endText(0);
    matrix.endDraw();
  }
file0.jpg
DevHeads IoT Integration Server banner
DevHeads IoT Integration ServerJoin
The DevHeads IoT Integration Server accelerates technology engineering by helping pro devs learn, share and collaborate.
2,984Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

The voltage of the RXD and TXD depends on the VCC pin, right?
DevHeads IoT Integration ServerDIISDevHeads IoT Integration Server / 🟩-pcb-and-analog
2y ago
What Module Can I Use to Measure DC Voltages Up to 40V, or Should I Build a Voltage Divider?
DevHeads IoT Integration ServerDIISDevHeads IoT Integration Server / 🟩-pcb-and-analog
2y ago
Can the analog input port of the Arduino Uno support a negative voltage from -5Vdc to 0Vdc?
DevHeads IoT Integration ServerDIISDevHeads IoT Integration Server / 🟩-pcb-and-analog
2y ago
Should I use a resistor voltage divider or dedicated voltage IC?
DevHeads IoT Integration ServerDIISDevHeads IoT Integration Server / 🟩-pcb-and-analog
2y ago