ESP32 vs Ardiuno - analogRead problem

guest808
Posts: 1
Joined: Thu Jun 27, 2019 3:36 pm

ESP32 vs Ardiuno - analogRead problem

Postby guest808 » Thu Jun 27, 2019 3:47 pm

Hi

I have Esp32 devkit board, when i connected potentiometer to pin 34, set analogReadResolution(10) and use analogRead function values vary, for example (430-450). The same potentiometer connected to Arduino UNO give me stedy value (439-440)

12345PJ
Posts: 2
Joined: Fri May 03, 2019 6:14 pm

Re: ESP32 vs Ardiuno - analogRead problem

Postby 12345PJ » Fri Jun 28, 2019 10:47 am

The ADC samples the Voltage from the potmeter and the "loading" can vary from mcu to mcu especially from brand to brand.
If you like to have a steady reading, you must use a buffer circuit between the potmeter and the mcu to provide the Voltage to be meassured with a low impedance at the ADC input.
Also the sample time and sample frequency can change the Voltage/ADC reading when not using a buffer.
If the Voltage you want to meassure is not changing fast (DC), you can lower the impedance by adding a good capacitor parallel to the ADC input (E.g. 1uF or higher) but remember not to change the potmeter to fast, the capacitor must be charged/discharged when you change the potmeter position.
If you meassure with an oscilloscope on the ADC pin and set the potmeter at 50% you will see ripple at the same frequency as the ADC samplefrequency.
Normally a mcu will have some kind of calibration function to optimize the ADC precission/linearity, I am not 100% certain ESP32 does but I believe it does.
Sorry I could not give specific info for the ESP32 and Arduino, normally I work with STM32 mcu's and some c programming in IAR Workbench.

TomWS1
Posts: 21
Joined: Wed May 01, 2019 2:50 pm

Re: ESP32 vs Ardiuno - analogRead problem

Postby TomWS1 » Sat Jun 29, 2019 3:20 pm

Besides buffering, a simple technique to lower the impedance of the Analog source (if its slowly varying, like a Pot), is to add a capacitor between the analog input and ground. Typically a 100nF cap is more than enough to help stabilize the readings.

Who is online

Users browsing this forum: No registered users and 74 guests