How to Monitor VUSB on the Electron?

I have a newer version of the code that work with chargers in this post:

Basically, using PG_STAT works better than VBUS_STAT, however that catch is that you can't tell the difference between a USB charger and powering by VIN.

		byte systemStatus = pmic.getSystemStatus();
		if ((systemStatus & 0x04) != 0) {
			// Bit 2 (mask 0x4) == PG_STAT. If non-zero, power is good
			// This means we're powered off USB or VIN, so we don't know for sure if there's a battery
2 Likes