I am trying to test the ADC function in the ESP32-S3. Below is my test code. I am using GPIO4. When I try to run 0V into GPIO4, I am read a value of approximately zero for a while and then I read a raw value of approximately 400 for a while and then back to zero and this behavior repeats. Does any one have any idea have any idea what is going on here? Here is the serial output:
3
3
3
3
0
391
373
412
415
409
411
416
407
416
405
408
402
409
391
413
432
412
5
3
7
9
4
5
2
3
0
7
5
3
5
9
5
3
9
4
404
414
425
397
384
ARDUINO CODE:
#include <esp_adc_cal.h>
#include <esp32-hal-adc.h>
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
analogReadResolution(12);
pinMode(4, INPUT); //GPIO4
adcAttachPin(4); //GPIO4
}
void loop() {
int RawADC= adc1_get_raw(ADC1_CHANNEL_3); //GPIO4
Serial.println(RawADC,0); // Print Raw ADC Value
delay(200); // delay in between reads for clear read from serial
}
This behavior continues as I increase the voltage. for example, when I raise the voltage to where I am reading a raw value of 1000, it bounces between 1000 and 1400 and contiunes all the way up.
If you have such hardware it is of course the prime suspect. Post a schematic and/or images. Have you metered the input with a DMM while it is producing those readings?
The hardware is fine....at the pin to the ESP32-S3 I get a solid voltage through my resistor divider network. so the lower value is always spot on the correct value, but then for a short time it reads this offset of approximately 400 higher than the actually value then goes back to the correct value.
Yes, but it's intermittent, right? So you can only be sure if you are simultaneously measuring externally and also with the ADC. Is that the case?
Please post the schematic. "the hardware is fine" ... we don't know you, we don't know your skill level or how you have constructed the circuit. It's important.
It should show the power source that is driving the divider circuit...
Your schematic is not complete. It does not show where +5V comes from, or the resistance value of the potentiometer.
The schematic alone isn't sufficient in this case anyway, but the missing information and also photos of your actual hardware would eliminate another 25 posts, or a thread that peters out without any solution...
So, I am 99.9% sure there is no hardware issue here. I am suspecting a driver configuration issue. I would assume that the ADC function is a well vetted feature, but not sure how many people have tested on the S3 version of the chip yet.
Why? I suggested some troubleshooting steps. Have you performed them all? You didn't provide any clear feedback to my inquiries.
API config issue could be, but then I would ask whether you have read and run any ADC examples. Like this one in the IDE examples for the S3:
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
//set the resolution to 12 bits (0-4096)
analogReadResolution(12);
}
void loop() {
// read the analog / millivolts value for pin 2:
int analogValue = analogRead(2);
int analogVolts = analogReadMilliVolts(2);
// print out the values you read:
Serial.printf("ADC analog value = %d\n",analogValue);
Serial.printf("ADC millivolts value = %d\n",analogVolts);
delay(100); // delay in between reads for clear read from serial
}
I see you've marked a random post as a solution and ghosted us. Good luck with your project.