0

For one of my projects I use the SparkFun ESP8266 board with an additional LiPo battery in cases power supply goes down.

Now I would like to communicate the power loss - or the fact that the board is running on battery power via WiFi.

Is there a way to find out (in code) when the board switches from mains power to battery and back?

1
  • Can I connect ADC pin to ground in order to make this method work? Otherwise what is the easiest way to disconnect ADC pin on esp8266 thing dev board ?
    – Ahmed
    Jun 28, 2018 at 8:08

1 Answer 1

1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.