Page 1 of 1

ESP32 ADC1 <-> WIFI Issue

Posted: Sat Mar 19, 2022 6:31 pm
by aktanara
I'm Using ESP32 ADC1 (not ADC2 that conflicts with Wi-Fi functionality) to capture some analog data received @IO36 (an ADC1 port). As soon as I uncomment WiFi.mode(WIFI_AP_STA) line (even when WiFi.begin() line is still commented out), analog readings go crazy!

SOME SIDE NOTES:
1- The hardware that processes input signal to make it suitable for ESP32 analog input uses the same power source as the ESP32 module.
2- A 100uF SMD capacitor is connected to the source line of ESP32 module just beside it to lessen impact of its power consumption ripples on other devices.
3- Tried adc1_get_raw which made no difference.
4- Tried this code on another ESP32 module, it also showed huge difference in adc1 readings before and after uncommenting WiFi.mode(WIFI_AP_STA).
5- using root APIs such as esp_wifi_init & esp_wifi_set_mode & esp_wifi_start instead of arduino wrappers like WiFi.mode didn't help.

In general anything related to WIFI function causes ADC get unstable. No matter which ESP32 board you use, you could simply serial plot any ADC1 channel before and after WIFI initialization command even with floating ADC1 pins you can see the difference.
Image
Image

Code: Select all

    #include <WiFi.h>
    
    void setup() {
        Serial.begin(500000);
    //    WiFi.mode(WIFI_AP_STA);  // uncommenting this line analogread goes crazy! even while following line is still commented...
    //    WiFi.begin();
        analogSetAttenuation(ADC_0db);
    }
    
    void loop() {
        Serial.println(analogRead(36));
    }

Re: ESP32 ADC1 <-> WIFI Issue

Posted: Mon Mar 21, 2022 1:43 am
by ESP_Sprite
FYI, floating ADC pins don't have a determinable value, so it's likely it'll be 'flapping in the breeze' with any disturbance, including those generated by the WiFi circuit. Best to have a low-impedance source connected to an ADC pin; perhaps even add a cap of a nf or so to smooth out any high-frequency ripple.