TinyCircuits Forum

TinyCircuits Products => TinyDuino Processors & TinyShields => Topic started by: zet23t on April 07, 2015, 04:21:54 AM

Title: Battery level readout?
Post by: zet23t on April 07, 2015, 04:21:54 AM
Is it possible to read out the battery level of the lipo? Or what the power source is (battery/usb)?
Title: Re: Battery level readout?
Post by: Ben Rose on April 07, 2015, 12:54:14 PM
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.
Title: Re: Battery level readout?
Post by: zet23t on April 07, 2015, 02:22:34 PM
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 :(
Title: Re: Battery level readout?
Post by: gmyu on April 03, 2017, 01:04:35 AM
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+) ?