Using the Arduino IDE, the ESP32-S2 ADC1 channels (GPIO 1 through 10) work fine and gives back the expected reading.
[Codebox]
// Read ADC (30V DC FSV - 0 to 8191 - 13bit)
uint32_t PCB_Voltage;
PCB_Voltage = ((analogRead(9) * 30 ) / 8191);
Serial.println(PCB_Voltage);
[/Codebox]
However, if I use any ADC2 channels (GPIO 11 through 20) ), I get an error:
[Codebox]
// Read ADC (30V DC FSV - 0 to 8191 - 13bit)
uint32_t PCB_Voltage;
PCB_Voltage = ((analogRead(17) * 30 ) / 8191);
Serial.println(PCB_Voltage);
[/Codebox]
E (4127) ADC: /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/driver/adc_common.c:476 (adc2_get_raw):WIDTH ERR: ESP32S2 support 13 bit width
PS. The below basic code does the same, only on ADC2, so excluding any value manipulation
[Codebox]
analogReadResolution(13);
Serial.println(analogRead(17));
[/Codebox]
Please does this error jump out at anyone?
Thanks in advance!
Dave
ESP32-S2 ADC2
-
- Posts: 831
- Joined: Mon Jul 22, 2019 3:20 pm
Re: ESP32-S2 ADC2
Looks like ADC1 can support RTC mode for 13 bit readings, but the ADC2 cannot. It is not clear whether this is a permanent restriction or an artifact of beta code, but it is what it is at the moment. You can ask at https://github.com/espressif/esp-idf/issues for more detail.
https://github.com/espressif/esp-idf/bl ... mon.c#L482
https://github.com/espressif/esp-idf/bl ... mon.c#L482
Re: ESP32-S2 ADC2
Many thanks for the thoughts. Seems to parallel mine but was not sure.
Will post a comment as per.
Take care
Dave
Will post a comment as per.
Take care
Dave
Re: ESP32-S2 ADC2
I found that using analogRead(1) on Arduino gives unexpected results out of the box. Connecting GPIO1 (ADC1_CH0) to VCC/2 (1.65V) results in a value of 8191 (instead of around 2047 as expected for a 12 bit result at half-scale).
After reading the documentation, I understand that after reset ADC1 is configured for 13 bits, with 0dB attenuation, which results in a full-scale range of 0 to Vref (which is nominal 1.1V, but can vary from chip to chip by as much as 20%), mapped to 0-8191.
See also: https://docs.espressif.com/projects/esp ... s/adc.html
After reading the documentation, I understand that after reset ADC1 is configured for 13 bits, with 0dB attenuation, which results in a full-scale range of 0 to Vref (which is nominal 1.1V, but can vary from chip to chip by as much as 20%), mapped to 0-8191.
See also: https://docs.espressif.com/projects/esp ... s/adc.html
Who is online
Users browsing this forum: No registered users and 23 guests