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?
read different analog values?
Re: read different analog values?
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.
-
- Posts: 5
- Joined: Wed Jul 14, 2021 12:43 pm
Re: read different analog values?
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);
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);
Who is online
Users browsing this forum: No registered users and 48 guests