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)
ESP32 vs Ardiuno - analogRead problem
Re: ESP32 vs Ardiuno - analogRead problem
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.
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.
Re: ESP32 vs Ardiuno - analogRead problem
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 32 guests