GPIO32/33 input level affects on ADC1 values
Posted: Wed Feb 08, 2023 6:38 am
Look like External input signal to GPIO32 or GPIO33 have internal effect to ADC1_CHANNEL_0 or ADC1_CHANNEL_3 (IO36 or IO39).
I have wrote sample code to reproduce effect:
as result we can see next:
GPIO32 pulled up via 1k to 3,3V
GPIO36 connected via resistive divider (47k|91k) between VCC and GND.
Same situation with ESP-IDF framework. Not only on Arduino.
How one GPIO can take effect to other GPIO?!
I have wrote sample code to reproduce effect:
Code: Select all
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
//set the resolution to 12 bits (0-4096)
analogReadResolution(12);
pinMode(32, INPUT | OUTPUT | OPEN_DRAIN| PULLUP);
pinMode(33, INPUT | OUTPUT | OPEN_DRAIN| PULLUP);
}
void loop() {
static uint8_t state = 1;
Serial.printf("Switch GPIO32 GPIO33 to %s\n", (state)?"HIGH":"LOW");
digitalWrite(32, state);
digitalWrite(33, state);
for (uint8_t n=0; n<15; ++n) {
// read the analog / millivolts value for pin 2:
int analogValue = analogRead(36);
int analogVolts = analogReadMilliVolts(36);
// print out the values you read:
Serial.printf("ADC analog value = %d, ",analogValue);
Serial.printf("ADC millivolts value = %d\n",analogVolts);
delay(100); // delay in between reads for clear read from serial
}
state ^= 1;
}
External connections:Switch GPIO32 GPIO33 to HIGH
ADC analog value = 2224, ADC millivolts value = 3165
ADC analog value = 3787, ADC millivolts value = 3165
ADC analog value = 3825, ADC millivolts value = 3165
ADC analog value = 3886, ADC millivolts value = 3165
ADC analog value = 3925, ADC millivolts value = 3165
ADC analog value = 3985, ADC millivolts value = 3165
ADC analog value = 4023, ADC millivolts value = 3165
ADC analog value = 4051, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
Switch GPIO32 GPIO33 to LOW
ADC analog value = 1589, ADC millivolts value = 1208
ADC analog value = 283, ADC millivolts value = 378
ADC analog value = 240, ADC millivolts value = 343
ADC analog value = 208, ADC millivolts value = 313
ADC analog value = 176, ADC millivolts value = 289
ADC analog value = 145, ADC millivolts value = 265
ADC analog value = 119, ADC millivolts value = 244
ADC analog value = 97, ADC millivolts value = 225
ADC analog value = 77, ADC millivolts value = 207
ADC analog value = 59, ADC millivolts value = 191
ADC analog value = 42, ADC millivolts value = 178
ADC analog value = 25, ADC millivolts value = 160
ADC analog value = 14, ADC millivolts value = 153
ADC analog value = 0, ADC millivolts value = 142
ADC analog value = 0, ADC millivolts value = 142
GPIO32 pulled up via 1k to 3,3V
GPIO36 connected via resistive divider (47k|91k) between VCC and GND.
Same situation with ESP-IDF framework. Not only on Arduino.
How one GPIO can take effect to other GPIO?!