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.
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));
}