Hi,
I have tried the new analogRead(BATTERY) function, but something seems to be wrong for me.
Have powered the Z-Uno on 5V pin with battery, and get values about 408 / 409 units.
This should be 3.3V for my understanding - right?
Same values if powered via USB.
How to use this function right?
Thanks!
Michael
[solved] analogRead(BATTERY)
Re: analogRead(BATTERY)
Z-Uno measures it's Vcc voltages against an internal reference ~1.21V. Once you power Z-Uno from 5V pin (or USB) or 7-18V pin, the Vcc on the chip is behind a voltage converter. So you are measuring pretty stable 3.3V.
If you need to measure your 5V battery, use voltage divider to normalize it to something lower than 3.3V and use normal ADC to measure it. Then use battery custom hander to report your own value for the battery level.
If you need to measure your 5V battery, use voltage divider to normalize it to something lower than 3.3V and use normal ADC to measure it. Then use battery custom hander to report your own value for the battery level.
Re: analogRead(BATTERY)
Right - this was the question. I know that I measure the voltage at the 3.3V pin.
But why the value is about 410?
https://z-uno.z-wave.me/Reference/analogRead/ say:
"This means that it will map input voltages between 0 and Vcc (about 3 V) into integer values between 0 and 1023."
So I thought it should be a value near 1000?
Even if the reference description is not correct - and Z-Uno measure against internal reference 1.21V, I can not understand the value 410 in this time
Thanks
Michael
Re: analogRead(BATTERY)
The doc is correct - Vcc = 1.21×1024÷value. In your case 1.21×1024÷410 = 3.022 V.
Note that 1.21 is not strictly accurate (from Z-Uno to Z-Uno it can change by 10% - you need to calibrate yours).
Note that 1.21 is not strictly accurate (from Z-Uno to Z-Uno it can change by 10% - you need to calibrate yours).
Re: analogRead(BATTERY)
Thanks,
I haven't noticed about the remark in the end of the reference:
" [!] If BATTERY is used, the reported value is the position of 1.21V..."
(was not visible at screen by default...)
Michael
I haven't noticed about the remark in the end of the reference:
" [!] If BATTERY is used, the reported value is the position of 1.21V..."
(was not visible at screen by default...)
Michael