It is possible to programmatically recognize when the power from the USB port is removed and the system switches to battery power on the Electron? My project will be plugged in 24/7 but it will also have a Lipo battery (which should always be fully charged via the wall power) and when the power goes out I would like to publish an event that notes that wall power is gone.
I believe if power is withdrawn from the USB port, the Electron automatically switches to battery power if available. But is there someway of detecting in code when that switch occurs so an event can be fired? Does VIN go to zero or switch to the value being provided by the battery? If the latter, I guess I could check for sudden changes in the VIN value but that seems fraught.