my battery fully charged voltage (4.5v to 5v)
my Arduino nano when powered from us from pc , reading well battery level. but giving A0=1023 , when run on battery by vin .
is it possible reading 5v battery voltage by nano with oled display??
or
Do i need to use battery great than 6v???
The A/D converter by default uses the input voltage as the reference . So in your case because of the diode Vcc is about .6 of a bolt below the battery voltage , so it always sees the battery a at a higher voltage than the supply - hence 1023.
You need to look at using the internal voltage reference and use a resistor divider on that analog input .
Google internal reference and voltage divider . This reference is very stable , but you will need to calibrate this voltmeter
BtW you risk damage having a higher voltage on the any pin than the supply voltage
Hey,
For the rest of us - Why is connecting "something" to Vin bad? Not clear on that. Thousands(millions, maybe?) run their Arduino Nanos on 9 to 12V, I've never heard anyone saying "bad, bad, bad".
Just curious
It’s not bad , they did put that pin there after all ; just that the on board regulator is small and can’t dissipate much power- so if you connect anything to the output lines of the Arduino you need to be careful about power dissipated in that regulator and do the sums .
What I figured. Yea, if you know much at all you know the onboard reg is sadly lacking. Leads many newbs into trouble. "What, I can't power six servos off the 5V out on my Nano? But, But, But! My project's ruined!" But that's a whole lot different from "Why are you connecting to..." which implies it's a dumb move. No, you just need to know what the heck you're doing.
Sheesh.
The default Arduino documentation and copycat "tutorials" suggest that operation from 12 V is in some way desirable. This is a completely outdated concept as I frequently go on to explain. It had some relevance in the distant past when two things applied.
Firstly that the commonly available power supply for the beginner was an unregulated 9 V plug pack or "wall wart", possibly reclaimed from a modem or network hub. The little problem with this is that such supplies actually rose to a substantially higher voltage when lightly loaded and it does appear as we often see here, that the regulators used on Nanos may not handle over 12 V.
The other thing is that the Arduino was basically a toy - an experimental system to teach programming - "coding" - and generate pretty patterns on a few LEDs limited to 20 mA each.
So under these limited circumstances, the on-board regulator arguably is usable. But to suggest that this is the most appropriate way to operate it, is grossly misleading and should have been removed over time in the documentation. But it has not.
"Feature creep" will bite the novice user - whom the Arduino is still marketed to. The first few projects flashing LEDs will work until the second relay module is added or of course, a servo. But it all worked before - what has gone wrong?
The point is - operating from "Vin" via the regulator is really the exception rather than the rule and this is what should be reflected in the documentation.