Hello I'm trying to read the voltage of a 18650 battery that is 3.7v on a analog pin 0. I'm using the normal example from the arduino ide.
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
}
When i hooked the 3.7v battery up and ground sense i know the arduino can go up to 5v on the input pins i tried it intead of displaying 3.7v it shows 3.92v Not sure why the difference can someone please help me?
You know that that code will not work when the battery is used to power the Arduino, right? Because in that case, the voltage on the battery will be the same voltage as the power supply, which is what it's using as the analog reference, so it will always read 1023.
Hello thanks all for the reply i looked more into this problem and what i found for a fix is a voltage monitoring circuit of some kind i will need to look into it more. If anyone haves any idea please let me know. Thank you.
When i hooked the 3.7v battery up and ground sense i know the arduino can go up to 5v on the input pins i tried it intead of displaying 3.7v it shows 3.92v
Hi,
Ditto post #4, how do you know it is 3.7V, I very rarely find batteries that have terminal voltages at the case quoted voltage.
The terminal voltage depend on temperature, state of charge, load of the measuring circuit.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Hello I'm not currently measuring the voltage with the arduino now the battery suppose to be 3.7v from the package but after charging i put on my meter and i get 3.9v from it.