GPIO38 state HIGH or LOW
If I connect GPIO38 from Crowpanel 7.0 inch ESP32 with 3.3 volts, the state is HIGH, without connection it is LOW. Unfortunately the port sometimes also becomes HIGH without connecting it to 3.3 volts. Does anyone know what I'm doing wrong? Please see the sketch below:
void setup() {
Serial.begin(115200);
pinMode(38, INPUT);
}
void loop() {
int gpioState = digitalRead(38);
if (gpioState == HIGH) {
Serial.println("GPIO38 is HIGH");
} else {
Serial.println("GPIO38 is LOW");
}
delay(1000);
}
Comments
Solved by adding a 2k2 resistor between GND and GIPO38.
When set the pinmode to input mode, it is usually floating mode. When nothing is connected, the pin state is unstable and may change due to external electromagnetic interference. This problem will not occur when connecting sensors or other modules.