Ideaspark ESP32 problem reading Analog value

Hi guys.
Arduino and ESP32 are a completely new world for me :slight_smile:
I've read many thread about ESP32 and analog reading problems but none cover my issue.

I've bought a cheap ESP32, an IdeaSpark DEV Module V3


and I want to read a simple analog value.
I use GPIO 34 with two 22k resistor
(I've also used GPIO 32 and 36 with the same issue, it's ADC1, I know about ADC2 and WiFi problem):
3.3V --- 22K --- GPIO --- 22K --- GND in a breadboard

and this simple code (I use VSCode and PlatformIO):

#include <Arduino.h>
#define PROBE_GPIO 34

void setup() {
  Serial.begin(115200);
  delay(1000);
}

int value = 0;
void loop() {
  value = analogRead(PROBE_GPIO);
  Serial.print("Analog value: ");
  Serial.println(value);
  delay(1000);
}

I suppose to read a value around 2048 (4096/2).

But result sounds very strange for me. It looks as a very low frequency sin wave.
I've made a long output cut&paste here https://pastebin.com/zTVFivER

Any idea ? What's wrong ?
Thanks for any suggestions :slight_smile:

That is strange. It's obviously not random. I can't think what would cause the voltage on the ADC input pin to sit at zero for a while and then slowly rise to a peak, before dropping down to zero again.
Do you have a multimeter you can use to measure the voltage between the ADC pin and ground while to code is running.

Yes. Tested with a new UNI-T 890C multimeter

ADC vs GND
DC: change from 0.470V to 0.530V. it floats in about 1-2 seconds
AC: fixed about 0.870V

I've inserted a 100nF capacitor between ADC and GND without any changes.

But I'VE SOLVED !!! It's the breadboard !! It's new and, thanks to your suggestion (yes, I'm an idiot), I've tested all signals and the breadboard is broken. The "+" supply line is interrupted.
This is solved.

Now I read a value about 1850 (range from 1840 to 1860). Non-linearity of ADC ?

Probably, it doesn't even read the whole range from 0 to 3V3.

Great, I'm happy to hear you got it working.

That's caught me out too in the past. Now, my first check when something on a breadboard appears to be connected correctly, but doesn't work, is to actually check the connectivity between all the points which should be connected

I'm going crazy.
I believed that problem was power supply missing caused by a broken breadboard. Not.
For some days I was busy in other issues. Today I've restarted my little project.
THE SAME ISSUE and power supply is ok.

I've tried different main power supply and insert some different capacitors: the problem still here.
It's like a sin wave about 0,1 - 0,05 Hz.

Any idea ? :frowning:

I suggest going back to basics. Try grounding the ADC pin, does the noise go away and it reads consistently zero from the ADC (maybe a small value above zero). Similarly try connecting it to 3.3V and see if it consistently reads near 4095.

Thanks. Solved. Again a supply problem. Damn chinese breadboard !!!!!!!!!!!