I am currently developing with ESP32-Cam.
I need to read an analog input, which is the problem according to many and me now.
What I found out:
people say that if you doesn't need SD card reader, you can use it's pins which are
however none of it works even thought I'm not using SD card.
Then I read that ADC2 is used by wifi, so I need to disable wifi in order to analogRead. I can confirm that. When I don't start wifi, I am able to read by setting pin input and read it:
pinMode(VOC_ANALOG_PIN, INPUT);
return analogRead(VOC_ANALOG_PIN);
it's GPIO2 for example when wifi is disabled.
Now my question is: how do I disable and re-enable wifi?
I am using tzapu/WiFiManager
and it works well for me. However when I issue esp_wifi_stop();
from #include <esp_wifi.h>
it stops the wifi, but erases AP credentials from ESP32 so I can not just re-connect with WifiManager
's autoConnect(..)
.
Can somebody advice on how to temporarily disable WiFi and reconnect it back after an analogRead, please? Is is really the only way (which it seems to me) to read analog input with WiFi on?
Thanks!