I've got an Adafruit HUZZAH32 ESP32 feather board connected to my PC via USB and I'm trying to read from a voltage divider at ADC1 channel 0, powered by the 3V pin. For troubleshooting, I'm using two regular metal-film resistors to be sure the values don't change. What I'm doing in Arduino code is quite straightforward:

#include <Arduino.h>

void setup()
  Serial.begin( 115200 );

void loop()
  int raw = analogRead( A0 );
  Serial.println( raw );
  delay( 10 );

While I would judge the readings as rather noisy (RSD = +/-0.5%) I noticed periodic noise showing up (approx. every 7 seconds), with is quite high (RSD = +/-6%). I was suspecting that the powering via USB could be an issue, but what's strange to me is that on other boards (Arduino Uno, Due, a number of different ESP8622 boards) don't seem to have a problem, the ADC readings are constant.

Here is a plot of what the values look like over a period of 60 seconds: plot of 60 seconds ADC1 channel 0 reading of Adafruit Huzzah32 ESP32 feather board

I realize the ADC of the ESP32 is not perfect and I can furthermore reduce noise by supersampling, but jitter like this is too much to handle. Any ideas where this may be coming from and how to get rid of it?

  • 1
    I'm always suspicious of 60 (or 50) hz hum, but that is way too infrequent for that if your graph is over 60 seconds. Is your board in a shielded, grounded enclosure? Are the wires shielded? If not, you should probably add shielding. – Duncan C May 27 at 15:30
  • 1
    As a sanity check, an oscilliscope should be used to check whether the voltage on the ADC signal line actually changes or whether the ADC is hallucinating. If there is a visible voltage change, there must be a source of electromagnetic interference (EMI) somewhere. – Maximilian Gerhardt May 27 at 16:42
  • 2
    esp32 uses a lot more power than other MCUs, which would pull the "3v" pin down. Try an external voltage source and see if that improves things; it might be the Vcc that's unstable, not the ADC... – dandavis May 27 at 16:44
  • Thanks for the very helpful comments so far, I tried a few things in the meantime: putting the board into a shielded box did not gain anything, neither did using an external, stable power source for the voltage divider. Checking via Oscilloscope showed only minor noise, seems like the high-amplitude periodic noise is resulting from something internal. Any more ideas, maybe? – iko79 Jun 2 at 9:23

Your Answer

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

Browse other questions tagged or ask your own question.