Does anyone have sample code that uses the FuelGuage data and sleep or any methods to conserve battery on the electron?
I am trying to find out if the electron is connected to the USB so I can relax power savings, once on the battery. I turn off LED and turn off the radio. Once an input is received the radio goes on and transmit changes and goes back off.
I am guessing this is not the best data efficient way since it has to handshake on every connect.
Has anyone attempted something like this that makes more data/power efficient use of the battery and the radio?
How does the Sleep command work for you with an ISR?
Sure, the system status register is 8 bits wide, and 4 of the bits are simple one-bit on-off values (DPM_STAT, PG_STAT, THERM-STAT, VSYS_STAT). However two of the fields are 2 bits wide, VBUS_STAT and CHRG_STAT. The one we’re interested in is VBUS_STAT, which is the two most-significant bits in the byte value. Those are bits with the values 0x80 and 0x40, but we want to check both bits, which is 0x80 + 0x40 = 0xc0, which we then check to see if they match 0x40.
Another way I could have written it is using a right shift 6 places to the right so those bits are in the least significant bit place.