For my web controlled robot project how do I read the battery condition of a battery connected to an Arduino Nano?
I found this code from another project that prints to the serial monitor but it returns values around 1.53, I have a Lithium Poly 2 Cell 7.4v battery? I guess the formula needs changing??
Just thinking about my question, the Nano is being supplied from a 5v Regulator on an L298N Motor Drive so it would only ever be able to read its own voltage without some additional hardware??
Sure, assuming that 7.2V at the battery does actually produce 5V at the analog input... and yes, you should calibrate it. Please end the confusion and tell us what kind of voltage divider you have.
"Just thinking about my question, the Nano is being supplied from a 5v Regulator on an L298N Motor Drive so it would only ever be able to read its own voltage without some additional hardware??"
The "additional hardware" would consist of a piece of wire.
You can't read your 5v power, by referencing it to the 5v rail. If one changes, the other one will also.
To measure your own 5v power, you need to change your analog reference to a different value (like 3v3). analogReference(type)
Apart from the L298N Motor Driver which also provides a regulated 5v output which I am using to power the Nano I have no other voltage divider setup. So I am not sure if this is possible without adding some resistors?
So add a couple of resistors connected to A0, one going to the V+ on the battery and the other to Gnd. And as you suggest a Ceramic Capacitor between A0 and Gnd? Then the software should work?