Thank you very much....I've gone thru over a thousand code / hardware videos and I must say i anm extremely impressed. You explained that circuit perfectly. All the other sites were losy to bad but yours is good. I will be looking at your other videos as time permits. This one is going to get me by writers block and back to being productive again. Good timing too because my ordered Nano and display just came in last night. So let's go to work.
Super simple, it's already working for me. My cheap aliexpress arduino uno had a different reference voltage as well. I also mapped my input to a different scale to output it onto an 8segment display to use as a tachometer for my car with the map() function. It will be a fun project and you did a great job explaining the adc of the arduino. I was also getting some weird values with no voltage applied but with 0v applied from my power supply it showed a 0v output.
Thx a lot for the hint that the reference voltage may not be exactly 5V. I just measured mine and found out that it is 4.99V when the Arduino is connected to the power supply and only about 4.86V when powered by usb. Of course I was only using USB and man I was wondering why the measurements were so off! :) Thx again!
@@AntonyCartwright could you make a video where you actually use the same battery or two in series to power the Arduino? I read if doing wrong, power can be backfed into a pin and through the rest of the chip destroying it. Thx.
@@Gallardo6669 Hi, unfortunately I can't make a video on that at the moment, however, I can answer it for you. The battery could wreck the Arduino if you fed it directly into a random pin, however, the VCC/RAW pins are exempt from this. These pins are designed to handle the current. If you wanted to power the 5v arduino using this 4.2v cell, it would work if you fed the VCC pin with it. If you are trying to power a 3.3v arduino with this cell, then use the RAW pin. The raw pin has a regulator behind it which makes higher voltage safer. Antony...
@@AntonyCartwright thx! I plan on using 2 18650 in series to power an 5volt Arduino uno. As the voltage goes down over some hours, the voltage regulator on the board would still get something over 6,4 volt in and it still regulates itself to 5v for the board. So far so good. But, can I now use a voltage divider to bring the 6,4 battery voltage down to use it for an analog pin? On top of that, to be safe, I could go off the voltage devider and go through a 10kohm resistor before going into the analog pin? I don't know if it's needed but someone mentioned it for a similar project, trying to prevent a too high current across the atmega...?
@@Gallardo6669 The 18650s have a capacity of sometimes near 3000mah and the Uno uses around 50ma, so your battery pack should probably last 60hrs. The cells shouldn't be discharged to less than 3.6v ideally. Both together would give you 7.2vnom, or 8.4vmax. That's ok for the raw pin but not the vcc pin. If you want to find the battery's voltage, then yes, you'd use a voltage divider. This splits the voltage down to an Arduino-friendly voltage for you so that you can read it. You can put the anode to the raw pin and the start of the divider. The battery would be 8.4vmax, so you could use a 50:50 divider to keep it simple. If your battery was fully charged, the Arduino would read in 4.2v (half) on the ADC. To make this happen, you could use any resistors which have the same value. You could theoretically use 1ohm and 1ohm, and the divider would work! However, in reality, you'd never do that because that's way too low resistance for what you're trying to d -, the battery would love to shoot electric through that circuit, the wires would get extremely hot, the divider itself would draw approx 4 amps and it would burn through anything in its way to ground! (Maybe burn through your computer's USB/motherboard or burn through the Arduino to get back to the negative of the battery. It would drain your battery pack in about 40 minutes! If you make the resistors 10k, then the divider would draw approx 0.4ma which is much, much safer! You could even use 20k resistors but the signal may be too weak. Basically, whatever you connect to the pins, make sure it stays below 20ma and 40ma in total for all pins... Oh, always remember: electricity always takes the path of least resistance and it has no emotions. 🤣🤣🤣
Great video, i thought the same about the resistor in series, because the lithium ion cell that im using is actually powering the arduino itself, thank you very much!
great tutorial, thanks, I am going to use it in my mini arduino project :) There will be GPS, GSM, temperature, pressure and humidity sensor and other things. But It will be in the 55x37x20mm box :D
Hello , Thank you for your great videos...iam new to arduino but learning...i have question please : The cell is connected in series with the resistor and then the resistor is connected to A0 and A0 is connected to ground , so how can the A0 pin reads the voltage across the cell ? . Thank you in advance
So this is a super helpful video and thank you very much for it! One question I do have...in the serial monitor, you were getting the voltage reading only every OTHER number. There was another much smaller number that alternated with it. What is that and why?
Why do you think a 10k resistor in series with the PSU (battery) is needed ? The ADC has an input impedance (resistance) in the range of MegaOhms. How can the ADC draw too much of a current ?
John Smith Hi Mr Smith, I used to think that too, but without the resistors, the cell can power the arduino! Try it if you like... Take the usb port out but have a few pins from arduino to the cell. The cell will power the arduino! :)
Am using stm32 so I need max 3.3v analog voltage & my step down transformer output voltage is 0 to 24V can you please suggest me resisters number to use.
Thanks for the Tutorial. I do have a question about some of this. The Delay messes with RC Cars because of the control Delay, is it possible to remove the Delay? Will that mess anything up? Or rather, is it possible to exclude this from the loop and make it it's own Void Function? Thanks for you time!
@@mydarkguy That's right. Sometimes, the Arduino can't cope of you try to do things too fast. The delay timing isn't necessarily thought through though. Maybe 1ms is enough - maybe too much. Maybe not...
Will this work on the ESP 8266 and ESP 32? I have a few Battery powered temperature and humidity sensors that i would like to monitor the battery voltage.
Hi Anthony, can you please tell me why the readings change constantly (821, 823, 823, 825, etc.) without any user interaction? Is it 823 or is it 821, 823, 825, 824, etc ? My digital Multimeter, car Speedometer, microwave clock/timer doesn't fluxuate, why does the reading change so much? Thanks. czcams.com/video/lec7kPv3VS8/video.html
BTW wouldn't changing the resistors to 100 Megs be better as we're going to be watching 24/7 and we don't want to drain the battery and "defeat the purpose" of which they exist
Yeah. It auto compensates for what ever the internal voltage is. The nice thing is you don't have to wire anything up to it, it can just do it. The only issue really is, you need to do a few blank readAnalog()'s afterwards to make sure it switches over before you use the value. At least, that's what the Arduino Dev site said. If you want to maintain your accuracy throughout the whole testing phase (referring back to your batter tester), you just put the call at the top of the loop() to update the global variable. If the value changed, then your calculations will be compensated for. This is nice considering, as you mentioned in this video, that the internal reference can fluctuate a little bit.
Hey Antony. U need really really a proper microphone. Its sooo annoying, that i cant hear u in one video - and if im watching a playlist - in another video u are toooo loud. thats not sooo cool. And the most important part is, that u dont said, that the measuring of voltages with arduino, depends on the input voltage. so if i change the input voltage of the arduino - the measurement is not correct.
Thank you very much....I've gone thru over a thousand code / hardware videos and I must say i anm extremely impressed. You explained that circuit perfectly. All the other sites were losy to bad but yours is good. I will be looking at your other videos as time permits. This one is going to get me by writers block and back to being productive again. Good timing too because my ordered Nano and display just came in last night. So let's go to work.
Thanks!
Super simple, it's already working for me. My cheap aliexpress arduino uno had a different reference voltage as well. I also mapped my input to a different scale to output it onto an 8segment display to use as a tachometer for my car with the map() function. It will be a fun project and you did a great job explaining the adc of the arduino. I was also getting some weird values with no voltage applied but with 0v applied from my power supply it showed a 0v output.
How , I also want to make tachometer so landed here , Can you please share what component used and code ?
I'm getting weird values too when no voltage is applied. with 2 arduinos.
Thx a lot for the hint that the reference voltage may not be exactly 5V. I just measured mine and found out that it is 4.99V when the Arduino is connected to the power supply and only about 4.86V when powered by usb. Of course I was only using USB and man I was wondering why the measurements were so off! :) Thx again!
FINALLY!!!!! SOMEONE WHO ACTUALLY CAN REALLY EXPLAIN THE PROBLEM AND THE CODE STEP BY STEP! T H A N K. Y O U !!!
Thanks!
@@AntonyCartwright could you make a video where you actually use the same battery or two in series to power the Arduino? I read if doing wrong, power can be backfed into a pin and through the rest of the chip destroying it. Thx.
@@Gallardo6669 Hi, unfortunately I can't make a video on that at the moment, however, I can answer it for you. The battery could wreck the Arduino if you fed it directly into a random pin, however, the VCC/RAW pins are exempt from this. These pins are designed to handle the current. If you wanted to power the 5v arduino using this 4.2v cell, it would work if you fed the VCC pin with it. If you are trying to power a 3.3v arduino with this cell, then use the RAW pin. The raw pin has a regulator behind it which makes higher voltage safer. Antony...
@@AntonyCartwright thx! I plan on using 2 18650 in series to power an 5volt Arduino uno. As the voltage goes down over some hours, the voltage regulator on the board would still get something over 6,4 volt in and it still regulates itself to 5v for the board.
So far so good. But, can I now use a voltage divider to bring the 6,4 battery voltage down to use it for an analog pin? On top of that, to be safe, I could go off the voltage devider and go through a 10kohm resistor before going into the analog pin? I don't know if it's needed but someone mentioned it for a similar project, trying to prevent a too high current across the atmega...?
@@Gallardo6669 The 18650s have a capacity of sometimes near 3000mah and the Uno uses around 50ma, so your battery pack should probably last 60hrs. The cells shouldn't be discharged to less than 3.6v ideally. Both together would give you 7.2vnom, or 8.4vmax. That's ok for the raw pin but not the vcc pin.
If you want to find the battery's voltage, then yes, you'd use a voltage divider. This splits the voltage down to an Arduino-friendly voltage for you so that you can read it. You can put the anode to the raw pin and the start of the divider. The battery would be 8.4vmax, so you could use a 50:50 divider to keep it simple. If your battery was fully charged, the Arduino would read in 4.2v (half) on the ADC. To make this happen, you could use any resistors which have the same value. You could theoretically use 1ohm and 1ohm, and the divider would work! However, in reality, you'd never do that because that's way too low resistance for what you're trying to d -, the battery would love to shoot electric through that circuit, the wires would get extremely hot, the divider itself would draw approx 4 amps and it would burn through anything in its way to ground! (Maybe burn through your computer's USB/motherboard or burn through the Arduino to get back to the negative of the battery. It would drain your battery pack in about 40 minutes! If you make the resistors 10k, then the divider would draw approx 0.4ma which is much, much safer! You could even use 20k resistors but the signal may be too weak. Basically, whatever you connect to the pins, make sure it stays below 20ma and 40ma in total for all pins... Oh, always remember: electricity always takes the path of least resistance and it has no emotions. 🤣🤣🤣
Great video, i thought the same about the resistor in series, because the lithium ion cell that im using is actually powering the arduino itself, thank you very much!
the difference voltage reader is because you add resistor on (+), to limit current, better to add resistor on (-)
great tutorial, thanks, I am going to use it in my mini arduino project :) There will be GPS, GSM, temperature, pressure and humidity sensor and other things. But It will be in the 55x37x20mm box :D
brillianttttt..... this code is the most easy and straightforward that ive found , cheers
THERE is an internal reference of 1V that can be used through code.
Hello ,
Thank you for your great videos...iam new to arduino but learning...i have question please :
The cell is connected in series with the resistor and then the resistor is connected to A0 and A0 is connected to ground , so how can the A0 pin reads the voltage across the cell ? .
Thank you in advance
How about using AREF pin for more generic solution?
So this is a super helpful video and thank you very much for it! One question I do have...in the serial monitor, you were getting the voltage reading only every OTHER number. There was another much smaller number that alternated with it. What is that and why?
The 0 to 1023 scale
Thank you, but I do not understand why doesn't the resistor you added decrease the neasured voltage?
Same question here!
Resistors restrict current, not voltage.
What does the low reading (800 and 300) every other reading mean?
Why do you think a 10k resistor in series with the PSU (battery) is needed ?
The ADC has an input impedance (resistance) in the range of MegaOhms.
How can the ADC draw too much of a current ?
John Smith Hi Mr Smith, I used to think that too, but without the resistors, the cell can power the arduino! Try it if you like... Take the usb port out but have a few pins from arduino to the cell. The cell will power the arduino! :)
a battery is indeed a device
Insstead of calculating a value, cant you get the value from the 5v pin on the arduino and use it in the calculation ???
Awesome!
I like it...
Thank you!
Brilliant
Am using stm32 so I need max 3.3v analog voltage & my step down transformer output voltage is 0 to 24V can you please suggest me resisters number to use.
Any tutoríal, how to measure, diode voltage drop?
thank you!
Thank you for this! Do you know how I could record weaker electrical signals? Up to 150 mV with a 0.1mV step? Any help is appreciated!!
You should certainly use a high gain amplifier. I would recommend using LM358 high gain amplifier module for millivolts. Hope this helps!
Thanks for the Tutorial.
I do have a question about some of this.
The Delay messes with RC Cars because of the control Delay, is it possible to remove the Delay? Will that mess anything up?
Or rather, is it possible to exclude this from the loop and make it it's own Void Function?
Thanks for you time!
I believe the delay's purpose is just for looking at the values, if there was no delay the numbers would flood in too quickly.
@@mydarkguy That's right. Sometimes, the Arduino can't cope of you try to do things too fast. The delay timing isn't necessarily thought through though. Maybe 1ms is enough - maybe too much. Maybe not...
Could this work for reading power generated with a simple hand crank generator?
Thank you a lot! Do you also know how chose the amount of amps I am outputting? @Antony Cartwright
Why is it fluctuating 10s of millivolts?
i want make voltage current monitor for solar charger on mobile can you wrte a code for me?
Will this work on the ESP 8266 and ESP 32? I have a few Battery powered temperature and humidity sensors that i would like to monitor the battery voltage.
Kevin Mac it will work the same way but you need to check the adc voltage of the modules...
Hi Anthony, can you please tell me why the readings change constantly (821, 823, 823, 825, etc.) without any user interaction? Is it 823 or is it 821, 823, 825, 824, etc ? My digital Multimeter, car Speedometer, microwave clock/timer doesn't fluxuate, why does the reading change so much? Thanks.
czcams.com/video/lec7kPv3VS8/video.html
oooor power through the vcc pin and read it directly from that
BTW wouldn't changing the resistors to 100 Megs be better as we're going to be watching 24/7 and we don't want to drain the battery and "defeat the purpose" of which they exist
do i need to use float, i want the program to be on a attiny85 and it has not that much memory...
the counts are integers
the voltages probably need to be floats though
Vitórias amigo
You measure voltages in Arduino with a volt meter
there I just save you 17 minutes
Save all the math and make your code quicker and cleaner.
float mV = counts / 5f; // change 5f to actual refV
One line of code instead of 4.
Any voltage ?, Can I try with 100v Ac ? 😜
max of 50 V DC i think
Awww, you didn't include the auto-adjust reference code 😜
Is that with the internal reference?
Yeah. It auto compensates for what ever the internal voltage is. The nice thing is you don't have to wire anything up to it, it can just do it.
The only issue really is, you need to do a few blank readAnalog()'s afterwards to make sure it switches over before you use the value. At least, that's what the Arduino Dev site said.
If you want to maintain your accuracy throughout the whole testing phase (referring back to your batter tester), you just put the call at the top of the loop() to update the global variable. If the value changed, then your calculations will be compensated for. This is nice considering, as you mentioned in this video, that the internal reference can fluctuate a little bit.
Korishan ok, maybe I'll add it to the capacity checker. :)
Hey Antony. U need really really a proper microphone. Its sooo annoying, that i cant hear u in one video - and if im watching a playlist - in another video u are toooo loud. thats not sooo cool.
And the most important part is, that u dont said, that the measuring of voltages with arduino, depends on the input voltage. so if i change the input voltage of the arduino - the measurement is not correct.