Monitoring battery voltage?
-
Is there a way to monitor the connected battery voltage from within MicroPython? I'd like to write some code that monitors the voltage levels and generates an alert when the battery is reaching its low-voltage cutoff level so I can go fetch the LoPy from outside and charge it (I'm currently using the si7021 library I wrote to monitor outside temperature and humidity).
I searched the forums and tried Google, but I didn't find anything clear cut.
Cheers,
Phil -
Don't think this is possible at the moment but as soon as ADC is available in "machine" for the Wipy2/Lopy, you would be able to use an ADC pin to read a value from the battery. You would need a couple of resistors to form a voltage divider to ensure that the 3.3V from the battery is reduced to below the maximum voltage that the ADC pin can handle. This is nominally 1.4V with an absolute maximum of 1,8V . The ADC input draws minimal current so you could use high resistance values to minimise any load through the resistor voltage divider.
-
Awesome, thanks! I use a high resistance voltage divider on the ESP8266, so I know exactly how to build that. Much appreciated!
Cheers,
Phil -
Would low voltage cause any damage to the LoPy?
Thanks,
Joe -
not to the LoPy, but over-discharge will damage the battery.
-
@hukuzatuna, @digsatman Now when ADC is available in "machine" for the Wipy2/Lopy did you try to get battery voltage monitoring working?
-
According to this picture: https://www.pycom.io/wp-content/uploads/2016/11/expansion_v02_pinout.pdf
The battery signal is at P16. I have tried reading it and the first time i read the value (After defining ADC to the correct Pin) it shows a number (52 or 44) then any other read attempts returns 0. I am not sure what this means but I know this is the correct pin also because without the battery the value returns 1023.Maybe i am interpreting this incorrectly?
-
All,
I am cross-posting from another thread some progress I've made on battery measurement. See:
https://forum.pycom.io/topic/226/lopy-adcs/5Hopefully it helps!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login