ESP32 Power on Issues

Hello to everyone,

I search in the forum and webs but I have not found the solution. If there is any topic already open that I missed, I’m sorry and feel free to redirect it to it.

I’m creating my auto watering system and the circuit is divided in two parts. The first one is controlled by and ESP-32 that provides power to a relay and 4 buttons (that control the relay) and a second circuit that provides power to the water pumps.

The issue that I’m having (all the circuit is still on protoboard) is that if I turn off and back on the ESP-32 is not doing anything (seems to be stuck or “overcloking” and also doesn’t connect to the WiFi) but if I remove the 5V connection with the relay and put it back it start working.

I think that the issue is that at startup something happen that overclocks the ESP-32 and doesn’t allow it to fully complete the startup procedure and when I remove the 5V connection it allows it to do so.

Can anyone help me? Is there any option to delay the 5V output to provide power on startup (as this maybe and remove the issue)?

This is a picture of how I’m connecting all the cables (sorry for the quality):

This is the code that I’m currently using:

esphome:
  name: esp-riego-comedor-test
  friendly_name: ESP-Riego-Comedor-Test

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "HsoB2OOD8OR2ZDd9PZT5NHQAlTapmPjleEN8OzV9/wY="

ota:
  password: "092e0969db4149ed3b9d83d71295d481"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "ESP-Riego-Comedor-Test"
    password: "XXXXXXXXXXX"

captive_portal:

web_server:
    port: 80


sensor:

switch:
  - platform: gpio
    name: "Bomba Agua Coleo (Roja)"
    id: relay_1
    pin: GPIO13
    restore_mode: RESTORE_DEFAULT_OFF
    inverted: true
  - platform: gpio
    name: "Bomba Agua Potus (Blanca)"
    id: relay_2
    pin: GPIO12
    restore_mode: RESTORE_DEFAULT_OFF
    inverted: true
  - platform: gpio
    name: "Bomba Agua Mostera"
    id: relay_3
    pin: GPIO14
    restore_mode: RESTORE_DEFAULT_OFF
    inverted: true
  - platform: gpio
    name: "Bomba Agua Estafilo"
    id: relay_4
    pin: GPIO27
    restore_mode: RESTORE_DEFAULT_OFF
    inverted: true

binary_sensor:
  - platform: gpio
    name: "Botón Agua Coleo"
    id: button_1
    pin:
        number: GPIO25
        mode: INPUT_PULLUP
        inverted: True
    on_press:
      - switch.toggle: relay_1
  - platform: gpio
    name: "Botón Agua Potus"
    id: button_2
    pin:
        number: GPIO33
        mode: INPUT_PULLUP
        inverted: True
    on_press:
      - switch.toggle: relay_2
  - platform: gpio
    name: "Botón Agua Mostera"
    id: button_3
    pin:
        number: GPIO32
        mode: INPUT_PULLUP
        inverted: True
    on_press:
      - switch.toggle: relay_3
  - platform: gpio
    name: "Botón Agua Estafilo"
    id: button_4
    pin:
        number: GPIO15
        mode: INPUT_PULLUP
        inverted: True
    on_press:
      - switch.toggle: relay_4```

Hi Juan,

I’m not a total expert but I believe some of your pins may not be the best choice to use - have a look at this pinout page and scroll down to " Which ESP32 GPIOs are safe to use?" - pins 12 and 15 may be an issue in your setup.

You could try with a few other pins instead of those and see if that fixes it.

Again, not a total expert but I’ve always tried to stay away from pins that aren’t marked green in the pinout.

The relay board may also be drawing too much power.

The ESP32 draws a lot of power when starting WiFi. If your power supply cannot provide enough current, the supply voltage will drop and the ESP32 will reboot.

You may need to power the relay board separately.

1 Like

Thanks to both for the responses.

@berniedp I’ll try to change the pins as they are in protoboard it’s easy, I can also only remove them for testing purposes and see. I’ll try this afternoon and let you know.

@agk1190 Do you know if there is any way to delay the send of the 5V on powering on, so that this issue can be avoided? Do you think that the same 5V power supply that I’m using for the water pumps could power on the relay or is better to sue a different one?

Thanks again!

From the schematic above, the relay power is coming from VIN. VIN is not controlled by the ESP32, it comes from the USB-C port. If you are connecting the board to a USB port on your computer, then you may not be supplying enough power on boot.

Try using a good phone charger (5V, 2A) to power it, or power the relay board independently from the water pump supply.

I think @berniedp is also right, D12 must be low during boot and the relay board may be pulling it high.

Sorry for the delay in the response, but it has been a very busy week and I was not able to play with the ESP.

Checking I saw that at startup the relay 1,2 were activated. So as suggested by @berniedp the issue was solved by a change of pins.

I’ll try now also to add some leds! Let’s see if I made it!

Thanks again for the help!

Glad it worked out!