How to use Arduino to read Voltage.

preview_player
Показать описание
This video will help you in using Arduino UNO to measure voltage of battery. (less than 5V). The voltage is measured in the units Volt.

Arduino Code:

/*
* Display5vOrless sketch
* prints the voltage on analog pin to the serial port
* Warning - do not connect more than 5 volts directly to an Arduino pin.
*/

const float referenceVolts = 5.0; // the default reference on a 5-volt board
const int batteryPin = 0; // battery is connected to analog pin 0

void setup()
{
}

void loop()
{
int val = analogRead(batteryPin); // read the value from the sensor
float volts = (val / 1023.0) * referenceVolts; // calculate the ratio
delay(500);
}
Рекомендации по теме
Комментарии
Автор

thankyou. this helped me alot today and taught me why PWM is so important.

psyolent.
Автор

It actually works. But I would suggest that you have a multimeter to measure and set the divider value by your calculation. For me, it works at 203.56.

vestkok
Автор

it is great and clear explanation. exactly what I need.

darkmare
Автор

have you tried while charging a battery

freytube
Автор

This is a clear explanation but could you by chance tel me why my Serial Monitor Shows 2.56 Volts even when nothing is connected?

ProJektCarModz
Автор

Thank you, I was afraid it would short and fry the board somehow

Patyx
Автор

Can you do this but instead of a battery use a DC motor as a generator and measure how many volts it produces?

hedgy
Автор

Thx for video but i have question, how can i read a negative voltage i have a piezo sensor and with arduino i can only read the postive signal but i want to be able to read the neagtive signal too anyone can help?

muhammedhamdan
Автор

how much of a voltage can it measure ?

twentyoned
Автор

Hi!
What is that value 1023.0?
And why do you use the reference of 5-volts?

gugasevero
Автор

Thanks for the tutorial 😊 .
Is there any way to get the reading of the battery to show 0(zero) while disconnected?

אריאלדרטץ
Автор

thank you for sharing this useful idea

pockeybearmilk
Автор

Can we read till 18V, using any component combination to monitor voltage fluctuation in a circuit?

anujvats
Автор

Is there software that can interface with a Visual Basic form to display the values on a VB form? It would be nive to control t he Arduino with VB to do the sampling, run the code, and maybe do some calculations like you need when using the gas sensors.

toml.
Автор

Can I use Arduino Nano 328p instead of Arduino Uno ?

dhananjaybhong
Автор

I am pretty to Microcontrollers, I need to learn for fun. I ordered two Arduino one NANO and other UNO R3 OEM made in Italy. The Arduino UNO can't read any voltage on Analog input. While the chinese copy I am able to reproduce this experimente. Did I get a bad board? I am able to upload the code on both, get the ID board. But this board simple can't read any analog input. How to test if it is in good condition hardware?

svsv
Автор

can Arduino read 2 different voltage sources at once?

muhamadsyaifulanwar
Автор

I have 2 rechargeable batteries joined in parallel from a laptop .Can I do the same trick to read voltage from a 5v arduino uno?When charged, the batteries are 4.2V with a total of more than 6000mAh.

lotgames
Автор

bro great job but need some correction, your integer value is causing real voltage value, its should 948.0

HASIBSTECHS
Автор

helo...is there any way to measure voltages nearly 20 volts
plse answer.
thank you

santoshm