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.
The issue you're facing is due to GPIO38 being a floating input when not connected. This means it can randomly pick up electrical noise, causing unpredictable HIGH readings. To fix this, you should add a pull-down resistor (typically 10kΩ) between GPIO38 and GND. This keeps the pin LOW when it's not connected to 3.3V. Without the resistor, the pin is left "floating" and can behave inconsistently. Using a pull-down resistor ensures stable and reliable readings from G..