SparkFun ESP8266 find out when on battery power and when charging
You can implement this software if the voltage is different in both cases.

The voltage from the power supply should be higher than the voltage of the battery, but do not exceed the permissible values.

Then you can use ESP.getVcc() :


  ESP.getVcc() may be used to measure supply voltage. ESP needs to
  reconfigure the ADC at startup in order for this feature to be
  available. Add the following line to the top of your sketch to use
  getVcc:
  
  ADC_MODE(ADC_VCC);
  
  TOUT pin has to be disconnected in this mode.
  
  Note that by default ADC is configured to read from TOUT pin using
  analogRead(A0), and ESP.getVCC() is not available.