Olimex Support Forum

Microcontrollers => ESP32 => Topic started by: sebr on August 22, 2023, 11:38:10 PM

Title: ESP32-POE and relay
Post by: sebr on August 22, 2023, 11:38:10 PM
Hi
I bought your super ESP32-POE card to control 2 relays for home automation on Home Assistant and ESPHome.
To control my garage doors I found this code at the following link:
https://digiblur.com/wiki/ha/esphome-garage-opener/ (https://digiblur.com/wiki/ha/esphome-garage-opener/)
Impossible to switch a relay, I tested on GPIO14 and 15 then GPIO0 and GPOI1 (Is it an error on the PDF on the name of the GPOI1?)
I don't see why I can't switch the relay on.
Thank you for your help.
Title: Re: ESP32-POE and relay
Post by: LubOlimex on August 23, 2023, 08:14:13 AM
There can be a lot of reasons for that. What are the relays exactly? Can they be controlled via 3.3V signal? GPIO14 and GPIO15 should be alright if you don't have SD card. Maybe also try using GPIO32. Maybe check the Arduio relay code for ESP32-EVB, it is our board with two on-board relays: https://github.com/OLIMEX/ESP32-EVB/blob/master/SOFTWARE/Arduino%20IDE%20examples/RELAY/RELAY.ino maybe also inspect the schematic of ESP32-EVB to see what relays we use and how we have connected it to the ESP32 chip.
Title: Re: ESP32-POE and relay
Post by: sebr on August 23, 2023, 06:52:06 PM
Hi,
Thank you for the quick reply. The relay and one from AZ Delivery:
https://www.az-delivery.de/fr/products/kf-301-relais-modul-mit-low-level-trigger (https://www.az-delivery.de/fr/products/kf-301-relais-modul-mit-low-level-trigger)
When I put it in contact with a GPIO the relay switches well as we can hear in this video:
With Home assistant it's not coded like arduino, the relay is controlled like this:
  - platform: gpio
    pine:
      number: GPIO22
      inverted: false
Title: Re: ESP32-POE and relay
Post by: sebr on August 23, 2023, 09:59:19 PM
I just did the test with my multimeter, if I play with the buttons of my Home Assistant, the GPIOs go well to 0v on OFF and 3v on ON.
My relay must not be compatible with this type of installation.
Title: Re: ESP32-POE and relay
Post by: sebr on August 23, 2023, 10:56:21 PM
I was able to progress thanks to the following topic: https://community.home-assistant.io/t/5v-relay-and-esphome/366110/13
I put in 3v relay and it works. I don't know why in 5v the relay always remains active even if the GPIO goes from 0 to 3v.
I think the relay is not very good. I have to test another piece of code.
Thanks for your help.
Title: Re: ESP32-POE and relay
Post by: KeviNH on September 26, 2023, 08:37:10 PM
GPIO pins cannot supply high-current loads such as to drive even a 3V relay coil, thus the mention above of a "low-level-trigger" relay (usually opto-isolated).

I'm building a garage-door triggering system with ESP-32, I ordered a set of "DC 5V Relay Module High/Low Level Trigger with Optocoupler" from Amazon.   I soldered pins to get both 5V and GND from the contacts on the edge of the ESP32-POE, and for the control signal I used GPIO5 from that same row.

Worth noting that you get what you pay for, you can get one fully-QA-tested relay module for ten bucks, or five factory seconds off Amazon/Ali for the same price.   Choose wisely!