Battery level readout?

zet23t · 4 · 5613

zet23t

  • Full Member
  • ***
    • Posts: 44
    • View Profile
Is it possible to read out the battery level of the lipo? Or what the power source is (battery/usb)?


Ben Rose

  • Administrator
  • Hero Member
  • *****
    • Posts: 392
    • View Profile
It's possible. Check the displayBattery function in the smartwatch demo at https://codebender.cc/sketch:91833 and the Arduino forum post it references. VCC of the microcontroller can be determined based on the internal 1.1V reference(which is unfortunately +/-10%), then you can infer the battery level based on that voltage- but keep in mind lithium batteries do not have a flat voltage curve- right now the example ignores that fact. If VCC is above 4.2V (5V minus a diode drop), USB power is probably attached. I'll try to update the demo with these things, but it may be a while.


zet23t

  • Full Member
  • ***
    • Posts: 44
    • View Profile
Thank you - that's good to know... though I probably can't integrate it into my game since I am getting slowly low on remaining flash memory :(


gmyu

  • Newbie
  • *
    • Posts: 3
    • View Profile
in the case of
      defined(ARDUINO_ARCH_SAMD)
the demo code set battery in red if the result < 325, or green otherwise.

Does this mean there is no level of scaling? I.e. result / 325 does not mean anything, unlike the case of defined(ARDUINO_ARCH_SAMD) ?

How can we get the rough % of battery for ARDUINO_ARCH_SAMD type of circuit (such as TinyScreen+) ?


 

SMF spam blocked by CleanTalk