[closed] ESP32 GPIO Preblems

Hi,

I'm working with ESP wroom-32 and I can't get some GPIOs working. I have the same circuit connected to GPIOs 5, 17, 18 and 19, but the only one working is the one connected to GPIO5. I tried both Arduino IDE and ESP IDF, but hte problem stays the same.

Here's my code from ESp IDF:

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"


#define RELAY1 17
#define RELAY2 5
#define RELAY3 18
#define RELAY4 19

void app_main(void) {
    gpio_reset_pin(RELAY1);
    gpio_reset_pin(RELAY2);
    gpio_reset_pin(RELAY3);
    gpio_reset_pin(RELAY4);
    gpio_set_direction(RELAY1, GPIO_MODE_OUTPUT);
    gpio_set_direction(RELAY2, GPIO_MODE_OUTPUT);
    gpio_set_direction(RELAY3, GPIO_MODE_OUTPUT);
    gpio_set_direction(RELAY4, GPIO_MODE_OUTPUT);
    
    while (1) {
        gpio_set_level(RELAY1, 1);
        gpio_set_level(RELAY2, 1);
        gpio_set_level(RELAY3, 1);
        gpio_set_level(RELAY4, 1);
        printf("on\n");
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        gpio_set_level(RELAY1, 0);
        gpio_set_level(RELAY2, 0);
        gpio_set_level(RELAY3, 0);
        gpio_set_level(RELAY4, 0);
        printf("off\n");
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

And here's the one from Arduino IDE:

int sw1 = 17;
int sw2 = 5;
int sw3 = 18;
int sw4 = 19;

void setup() {
  Serial.begin(115200);
    pinMode(sw1, OUTPUT);
    pinMode(sw2, OUTPUT);
    pinMode(sw3, OUTPUT);
    pinMode(sw4, OUTPUT);
}

void loop() {
  Serial.println("on");
  digitalWrite(sw1, HIGH);
  digitalWrite(sw2, HIGH);
  digitalWrite(sw3, HIGH);
  digitalWrite(sw4, HIGH);
  delay(1000);
  Serial.println("off");
  digitalWrite(sw1, LOW);
  digitalWrite(sw2, LOW);
  digitalWrite(sw3, LOW);
  digitalWrite(sw4, LOW);
  delay(1000);
}

The voltage at GPIO5 rises to 3v3 and falls back down as it should, but the other ones stay at 0v. I'm not sure if any other pins have problems, or it's just the three, but I can test them. Am I doing something wrong?

This will be no consolation to you, but testing your code with output to LEDs works perfectly

How much current does each relay take in your project ?

They take around 100mA each, but I use mosfets with gate resistors, so current shouldn't be problem.

Have you tried measuring the voltage of the pins with nothing connected and your sketch running ?

Which ESP32 board are you using ?
GPIO17 is not available on the WROVER module and GPIO18 and 19 are used by the SPI interface but can be used as GPIO pins

I'm using wroom and I have it soldered on so i can't really test it without being connected.

Did it work when you prototyped it on a breadboard ? :grinning:

That's the problem. I didn't prototype it. I don't have the dev module and it's just a home IoT thing so I just took the shot and I don't care if there are some wires for rerouting traces if necessary. (Yeah, I know I should have prototyped it. My only excuse is that I didn't want to buy the dev module because I'm on a budget and it's kina expensive)

Obviously not, hence my smiley !

Can you disconnect at least one of the MOSFET gates to test the bare pin ? What is the resistance measurement between each of the pins and GND/5V ? Is there any significant difference between them ?

At first sight there would seem to be no reason why it should not work apart from a hardware/wiring problem

ok, you got me. I removed the gate resistors from all four mosfets, the problem is still there. I tried measuring the resistance between the pins and both GND and VCC with the esp turn on and off and found this:

GPIO5 keeps oscillating between 0ohm and OL (that seems good)

The other three stay at OL when measuring with GND or VCC no matter what i do.

I was measuring at the highest setting so the OL ones have no connection.

It sounds very much as though the ESP32 module is busted

Oh don't even tell me that... guess i'm spending on another one. Thanks for all the help!