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



  • 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/5

    Hopefully it helps!



  • 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?



  • @hukuzatuna, @digsatman Now when ADC is available in "machine" for the Wipy2/Lopy did you try to get battery voltage monitoring working?



  • not to the LoPy, but over-discharge will damage the battery.


  • Pybytes Beta

    Would low voltage cause any damage to the LoPy?
    Thanks,
    Joe



  • Awesome, thanks! I use a high resistance voltage divider on the ESP8266, so I know exactly how to build that. Much appreciated!

    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.


Log in to reply
 

Pycom on Twitter