How to set the analog attenuation?

torntrousers
Posts: 12
Joined: Mon Dec 21, 2015 9:30 am

How to set the analog attenuation?

Postby torntrousers » Sat Dec 10, 2016 2:14 pm

The code to set the esp32/arduino code to set the analog attenuation doesn't seem to work. Can anyone say how its supposed to be done? Or is there some bug in the SDK?

Code is here: https://github.com/espressif/arduino-es ... -adc.c#L69

Issue here: https://github.com/espressif/arduino-esp32/issues/87

Thanks for any help

WiFive
Posts: 2624
Joined: Tue Dec 01, 2015 7:35 am

Re: How to set the analog attenuation?

Postby WiFive » Sun Dec 11, 2016 9:35 am

Code: Select all

adc1_config_width(ADC_WIDTH_12Bit);//config adc1 width
adc1_pad_init(ADC1_CHANNEL_6);
adc1_config_channel_atten(ADC1_CHANNEL_6,ADC_ATTEN_0db);
int val=adc1_get_voltage(ADC1_CHANNEL_6);
adc1_config_channel_atten(ADC1_CHANNEL_6,ADC_ATTEN_11db);
int val2=adc1_get_voltage(ADC1_CHANNEL_6);
printf("ADC1 CH6 value: %d @ 0db, %d @ 11db\n", val, val2);
fflush(stdout);

Code: Select all

ADC1 CH6 value: 1828 @ 0db, 448 @ 11db

torntrousers
Posts: 12
Joined: Mon Dec 21, 2015 9:30 am

Re: How to set the analog attenuation?

Postby torntrousers » Tue Dec 13, 2016 1:49 pm

Thanks!

TESTTHISONE
Posts: 9
Joined: Tue Dec 20, 2016 7:24 am

Re: How to set the analog attenuation?

Postby TESTTHISONE » Wed Jan 04, 2017 8:35 am

I have a question.
In order to call this function - adc1_pad_init(...),
what header file did you include?

Who is online

Users browsing this forum: No registered users and 14 guests