(The following line applies just to the ESP32. It defines that we want to be able to read voltage in full range. This means we want to read voltage from 0 to 3.3 V.)
pot.atten(ADC.ATTN_11DB)
what is this equivalent commend for Arduino IDE?
Hi.
In the setup() try the following:
analogSetPinAttenuation(ADC_PIN,ADC_6db);
in which ADC_PIN corresponds to the GPIO you are getting the readings. The second argument can be one of the following:
(ADC_ATTEN_DB_0) 0dB attenuaton: gives full-scale voltage 1.1V
(ADC_ATTEN_DB_2_5) – 2.5dB attenuation gives full-scale voltage 1.5V
(ADC_ATTEN_DB_6) – 6dB attenuation gives full-scale voltage 2.2V
(ADC_ATTEN_DB_11) – 11dB attenuation gives full-scale voltage
Then, right after that add the following lines:
adcAttachPin(ADC_PIN); adcStart(ADC_PIN);
I hope this helps.
Regards,
Sara 🙂