Author Topic: Battery Monitor  (Read 1609 times)

kwalkerk

  • NewMember
  • *
  • Posts: 36
  • Country: us
Battery Monitor
« on: August 28, 2018, 09:53:35 AM »
Does the M0 have a pin I can use for a battery monitor similar to pin A7 on regular Motion?

Thanks

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Battery Monitor
« Reply #1 on: August 28, 2018, 11:02:21 AM »
Yes, please see schematic, it's on A5, marked "Vmon" on silkscreen.

mbutki

  • NewMember
  • *
  • Posts: 1
Re: Battery Monitor
« Reply #2 on: August 31, 2019, 09:59:46 PM »
For anyone wondering, here's the formula for using A5 on the Moteino M0.

analogRead(A5) * 2 * 3.3 / 1024

The Moteino M0 uses two 1M resistors, so the output voltage of the voltage divider is just half the input. The first thing we do then is to multiply it by 2 to get back to the original voltage.

3.3v is the reference voltage. It's the max value that A5 is expecting.

We divide by 1024 (2^10) because by default the ADC is doing a 10 bit conversion. This was a little confusing for me at first, since the Moteino M0 page lists the ADC as 12 bit, which would be 4096 (2^12). With a little google-ing, it looks like 10 bit is the default, but can be changed to 12 bit if desired.

When I use this with USB power I get 4.8v, which is pretty close to 5v, and with my 3.7v LiPo battery I get 4.24v, which sounds about right for fully charged.
« Last Edit: September 01, 2019, 07:18:50 PM by mbutki »