Analog inputs from ESP32 more than random generators?

rin67630
Posts: 141
Joined: Sun Mar 11, 2018 5:13 pm

Analog inputs from ESP32 more than random generators?

Postby rin67630 » Thu May 24, 2018 9:18 pm

I am very disappointed.

I have entered an absolutely stable voltage of 557,3 mV (verified with my 5 digits multimeter and absolutely clean according to my oscilloscope) on pin 37 of an ESP32 Wroom.
Here is my code:

Code: Select all

Setup:
...
    analogReadResolution(10); // 10Bit resolution
    analogSetAttenuation(ADC_0db);  // 0=0db (0..1V) 1= 2,5dB; 2=-6dB (0..2V); 3=-11dB
...
Loop:
...
    A0Raw = analogRead(37); // 1st read  0...1V = 0 ..1023
    delay(20);
    A0Raw += analogRead(37); // 2nd read
    delay(20);
    A0Raw += analogRead(37); // 3rd read
    A0Raw = A0Raw / 3;
    Serial.println (A0Raw);
...
Delay (970);
Here is, what came out:
392
469
455
454
464
451
458
455
453
440
451
450
477
460
469
446
443
450
453
450
450
466
440
452
467
440
384
447
445
...

That is NOT what I expected to get from a decent DAC!
Espressif, what did you do?
Have you got any way to fix that?
+- 2 LSB is acceptable, but not that random cr*p!

Franck
Posts: 7
Joined: Fri May 25, 2018 3:44 am

Re: Analog inputs from ESP32 more than random generators?

Postby Franck » Fri May 25, 2018 5:33 am

Hi,
I haven't tried the ESP32 ADC yet, but what you describe looks a lot like a hardware issue.
Your oscilloscope has a nice front-end amplifier with a high impedance. This is not the case of the ESP32 (and most MCU).
So depending on where and when you probe your analog signal, the oscillos and MCUs may see different signals.

Here are some tips to get a clean analog signal:
- Add a low pass filter as close as possible to the ADC input pin: 100nF ceramic capacitor and ~1k resistors
- GND and analog signal wires between the source and the ESP should be twisted
- The GND of your twisted wire should be connected as close as possible to the GND pin of the ESP

I hope it helps,
Franck.

rin67630
Posts: 141
Joined: Sun Mar 11, 2018 5:13 pm

Re: Analog inputs from ESP32 more than random generators?

Postby rin67630 » Fri May 25, 2018 8:27 am

Thank you. It helped to put a 22nF condensator to the the two adjacent analog inputs.

Archibald
Posts: 110
Joined: Mon Mar 05, 2018 12:44 am

Re: Analog inputs from ESP32 more than random generators?

Postby Archibald » Fri May 25, 2018 9:36 am

The issue is described here under "Minimising Noise" . . . .
http://esp-idf.readthedocs.io/en/latest ... alibration

It is really very poor. The Arduino Atmel processors are very much better. Beware also that I find linearity when the attenuation is set to 11dB is also very poor. There's no point using 11 or 12 bit resolution even if you average numerous samples.

Further down that documentation page, it describes routing the ADC reference voltage to a GPIO pin, using for example . . . .

Code: Select all

adc2_vref_to_gpio(GPIO_NUM_25);
I can't get that to compile (changing it to use ADC1). I was hoping to then put a decoupling capacitor on the GPIO to try to smooth the reference voltage.

kdiamond
Posts: 2
Joined: Thu Aug 01, 2024 9:18 pm

Re: Analog inputs from ESP32 more than random generators?

Postby kdiamond » Thu Aug 01, 2024 9:23 pm

I'm having the same problem. Any solution to this?

Thank you

Who is online

Users browsing this forum: No registered users and 84 guests