The Photon 2 does not have a fuel gauge chip, however you can determine the voltage of the LiPo battery, if present. The P2 does not include a LiPo battery connector, but if you connect your battery to VBAT_MEAS, this technique also works with the P2.
float voltage = analogRead(A6) / 819.2;
The constant is from the ADC range (0 - 4095) mapped to the voltage from 0 - 5 VDC (the maximum supported on VBAT_MEAS).
There is a CHG pin defined on the P2, however it does not work properly.
Show older information about CHG
The current Photon 2 hardware is unable to reliably read the CHG pin. In particular, if you have a Photon 2 powered by both
USB and battery and is charging, then unplug the USB power, the charge LED will turn off, but the CHG pin will not change
state. This is a hardware issue and cannot be fixed in software.
The charge indicator on the Photon 2 can be read using:
On the Photon 2, the CHG digital input is HIGH (1) when charging and LOW (0) when not charging, however you must set pinMode(CHG, INPUT_PULLUP). You only have to set pinMode once, such as in setup.