Detect if Photon uses micro USB or Battery


I am relatively new with the Particle Photon but managed to set up my first project.
This project uses the MPR121 touch sensor and some neopixel RGB LEDs. I have powered this project with the Sparkfun Battery Shield and a 500mAh battery.

My device has a “charging” dock that works with a magnetic Mini-USB charger. (
I would like to detect wheither it is powered through that mini-usb (and thus charging) or if it’s not connected and uses the battery.

I have read I can use the VIN-port for this, but I don’t see how.
Any suggestions / help would be greatly greatly appreciated.



You could get the status of the charge from the board itself. There is a STAT pin for that, which is used to activated the LED, but unfortunately the pin is not connected to the Photon.
Another way to detect is by connecting a voltage dividers with resistors between VIN and an analog entry of your Photon, let’s say A1. Careful that maximum voltage for A1 is 3.3v
When powered by USB, VIN=5v => you will read 3.3v on A1.
When powered by battery, VIN=0v (that is my understanding, you can measure it with a voltmeter).