Measuring Power Supply

Hi, Good day. I am working on an Arduino bluetooth car, and I was wondering if my Arduino can read the voltage of its power supply and send a message back to my phone telling me to return and recharge.

I am using an Arduino Uno and 2-18650 3.7V rechargeable battery. Is this possible? If yes, how do I do it? Thanks!:grinning::grinning::grinning:


if (analogRead(battPin) < MinVoltage ) bt.println("Battery empty"); 

You can do it. There are several ways.
Give more details. Show your Arduino power plan. Are your batteries connected in series and do you supply 7.4V to the power jack or otherwise?

Hi, Edison. Is this a joke?

no, I call it pseudo code :nerd_face:

Then explain what a battPin is and where it is connected to.

Yes, my power supply is a seriesed 3.7V 18650, power supply total: 7.4 volts. It is connected to my "vin" pin. Side detail: I use the same power supply to power my l298n, but I think its not that important.

And side question: What function should I use to transfer strings from Arduino to my phone, Serial.Write() or Serial.print()? I used the tx rx pins of the Arduino, I did not use any SoftwareSerial library.

To sense battery voltage you'd use a resistor divider to bring the voltage down to a safe level for the ADC of your particular Arduino (here < 5V since its an Uno). With a 7.4V battery I'd suggest 10k:10k divider so you read half the true voltage, simple and able to handle upto 10V safely.

May I know an example of a 10k ohm resistor voltage divider? Can I have some schematics?

Did you try searching this site? Loads of examples of threads talking about dividers.

Do I need 2 resistors?

Because I power my Uno with 7.4V.

Yes you need two resistors to make a divider. 7.4V onto any arduino digital or analog pin will fry the chip instantly, you have to provide only safe voltages to pins.

Which one is correct?

        Analog pin


                   Analog pin    


Rather than coming back again and again with simple questions that wikipedia can answer, try wikipedia:

I have read it. But I can still direct 7.4v to my vin?

There are many important details to keep in mind.
You will probably use the 5V of the Arduino board as the reference for your ADC (AREF). Arduino Uno can work with Vin at least 6V.
In this case, the minimum battery voltage that you can measure will be about 6V (3V on each battery). At a lower Vin voltage, the AREF voltage will begin to decrease and the measurement error will be large.
You should also know the minimum allowable battery voltage.
If you want to "suck out" more from your batteries, for example up to 2.75V on each battery, you need to use a different AREF source with lower voltage or internal source 1.1V, but that's another issue.

Try looking for an answer on this forum, in the Arduino reference section Serial, or open a new thread with this question.

You can feed 7.4V (really 2 batteries give from 8.4 to 6V) to Vin of your Arduino Uno.

I already got the logic of the resistor divider. Accurate measurements don't relly matter in my case, all I need is for my Arduino to send me a message via bluetooth to tell me that I need to recharge my batteries. :grinning::grinning::grinning:

All you need to do is first determine when the battery needs to be charged.

I found this that might have helped.