Go Down

Topic: Make Arduino Measure Its Own Voltage From Vin (Read 635 times) previous topic - next topic

JArias

Hello, I am doing an Arduino project using Arduino Mega and a 5V cellphone powerbank. I need to make the Arduino measure its Vin voltage in order to print the powerbank's battery percentage. How can I do this? How should the circuit and code be? I have read about voltage dividers but I don't know what they are or how to build them. Please help me.

Thank you very much.

jremington


wvmarle

The output of a 5V power bank will be 5V regardless of battery level, until the battery is empty.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

JArias


MarkT

powerbanks internally have a 3.7V lithium battery and 5V boost converter.  The state of charge is
indicated by a row of LEDs.  If you want more sophisticated you may have to roll your own...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Idahowalker


freaklabs

You would actually need a voltage reference that is independent of the power supply you are trying to measure. You can't measure a power supply when it's also the reference. Hence you would need a voltage reference and a voltage divider with the power supply voltage at the top. the divider output would then go into the ADC and the ADC should be configured to use the external voltage reference. In this way, you can measure your battery voltage.
FreakLabs
Wireless Technology for the environment, wildlife, and agriculture
https://freaklabs.org
https://hackerfarm.jp
Twitter: @freaklabs

wvmarle

Isn't it great that Atmel has thought of that and provides us with the fixed 1.1V reference?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

zoomx

Take care that is not always exactly 1.1V, you should measure it.

freaklabs

Actually that's true. I forgot about the bandgap reference internally in the AVR chip. This can also be used. As mentioned, it's not as accurate as a precision reference, but if you're just measuring battery voltage, it can probably give you the voltage with around tens of mV precision.
FreakLabs
Wireless Technology for the environment, wildlife, and agriculture
https://freaklabs.org
https://hackerfarm.jp
Twitter: @freaklabs

wvmarle

It's stable - you just have to measure the actual voltage once (for each individual chip), and then you can use that number.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up