1

I have a soil sensor that reports value once every 5 minutes, deepsleep in between. Is there a way to also report battery voltage (with ESP.getVcc())?

To get the battery voltage reading to work I need to set ADC_MODE(ADC_VCC); but that disables the reading of the sensor.

5
  • does the ADC_VCC use the same channel on the ADC that your sensor is using? Can you use another channel? – Chad G May 22 '18 at 20:06
  • can you set the mode to vcc after you take a sample and before you sleep? – dandavis May 22 '18 at 20:44
  • that disables the reading of the sensor ... so enable it after you read the voltage ... what is the problem? – jsotola May 23 '18 at 0:18
  • @ChadG esp8266 has only one analog pin – Juraj May 23 '18 at 5:06
  • you can use a digital pin and RC circuit to precisely measure voltage as a function of time – dandavis May 24 '18 at 18:42
3

to read VCC voltage, ADC pin must be kept unconnected. Additionally, the following line has to be added to the sketch: ADC_MODE(ADC_VCC);

The setting of a purpose of the analog pin of esp8266 is at low level and must be projected into the compiled binary. It can't be changed at runtime.

On esp8266 if you want to use the power sensing or to have more ADC you must use an external I2C ADC.

reference

1
  • Was afraid of that, but thanks for confirming. – hbruce May 24 '18 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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