Page 1 of 1

read different analog values?

Posted: Wed Aug 04, 2021 1:19 pm
by aleskramzar
Hello,

I am currently programing an ESP32 C3 devboard which has multiple ADC channels and i would like to read data from 3 different sensors.
The problem is that whenever i use analogRead() with any port it always only shows the measurment on GPIO1.
My question is how do i switch the current used ADC channel in arduino?

Re: read different analog values?

Posted: Thu Aug 05, 2021 9:05 am
by rbrakhya
I have posted the same question, but didn't get an answer. Tested with two boards, both only connected to gpio1 regardless of the analogRead setting.

Re: read different analog values?

Posted: Mon Aug 09, 2021 7:19 am
by aleskramzar
I have found a solution after much serching.

Instead of analogRead(pin);
you can use:
adc1_get_raw((adc1_channel_t)ADC1_CHANNEL_xxx); with xxx being the pin with the wanted adc channel.

This is for using ADC channel 1, if you want to use channel 2 (which isnt recomended since apperently it is used by wifi) you just replace it with adc2_get_raw((adc2_channel_t)ADC2_CHANNEL_xxx);