ESP32-GATEWAY / ESP32-EVB to control 5v relay

Started by oleole, October 22, 2020, 02:43:20 AM

Previous topic - Next topic

oleole

Hi,
so I need to control 8 channel 5v Relay Module via board connected with Ethernet.
My question is: would you suggest to use ESP32-GATEWAY / ESP32-EVB for this purpose? Or maybe some other board (INDUSTRIAL)?

I need to run it with no external power connected to relay other than 5v output pin. The board would be powered with usb/power socket.
Will that work?

LubOlimex

#1
Sure it would work. Depending on the relays typical problems with relays should be expected. Whether you get industrial or commercial version would depend on the temperature around the module. We even have ESP32 evaluation design with relays already on-board, maybe use as a reference:

https://www.olimex.com/Products/IoT/ESP32/ESP32-EVB/open-source-hardware

We have published some relay examples for both ESP32-GATEWAY and ESP32-POE. For the ESP32-POE the relay demo uses Olimex MOD-IO extension board that has a four relays. The MOD-IO board is here:

https://www.olimex.com/Products/Modules/IO/MOD-IO/open-source-hardware

and the ESP32-POE + MOD-IO example here:

https://github.com/OLIMEX/ESP32-POE/tree/master/SOFTWARE/ARDUINO/ESP32_PoE_WebServer_MOD_IO

Technical support and documentation manager at Olimex

oleole

#2
Thank you LubOlimex for your reply.
In the end I bought both ESP32-Gateway and ESP32-EVB for my evaluation purposes.

The problem I have now is that it's not exactly working as I expected:

ESP32-EVB
I managed to get relay to work with a few some of GPIOs (2, 4, 12) but not all. I need 8 of them - which else can I use?.
Built in relays and GPIOs (32 & 33) work as expected.

ESP32-Gateway
I tried to use many of them, but found none working (GPIO 2,4,12,32 etc.). Which of the GPIOs should I use (no SD card in use) - I need 8 outputs to relay in total.

I power it from USB 5V, 2.1 A.
Any advice will be appreciated, thank you.

LubOlimex

For ESP32-GATEWAY there are probably 8 free GPIOs if you don't use the SD card, refer to this document to locate them:

https://www.olimex.com/Products/IoT/ESP32/ESP32-GATEWAY/resources/ESP32-GATEWAY-GPIOs-Rev.F-up.pdf

If you have trouble setting these free pins - maybe something in the hardware connection of the relay, use the schematic of ESP32-EVB as a reference on how we have connected the relays. Consider that the relays you use might be different compared to the ones we used. If the hardware connections are similar maybe it is something in the software.

I am not sure if there are 8 free GPIOs on ESP32-EVB, the board is already packed with a lot of hardware and it is meant for evaluation of the ESP32's capabilities.
Technical support and documentation manager at Olimex

oleole

#4
Ok. Let's focus on ESP-32 GATEWAY then.

My setup: 5v output, GND in hole no 2.
GPIO: 4

Code:

int relay = 4;
int light = 33;
void setup() {
pinMode (relay, OUTPUT);
pinMode (light, OUTPUT);
;
}
void loop() {
digitalWrite(relay, HIGH);
digitalWrite(light, HIGH);
delay(1000);
digitalWrite(relay, LOW);
digitalWrite(light, LOW);
delay(1000);
}

Unfortunately not only relay is not activated but also it loses PWR when GPIO is High. https://photos.app.goo.gl/yxMZYtPbrD6nbQtR9

I have checked it with two ESP32-Gateways and 2 different relays.
Testing similar code on Arduino - all works.

LubOlimex

Well, thanks for the video - the issue seems clear - in ESP32-GATEWAY, the +5V_EXT pin is only input (e.g. to power the board using it); it is not output - you can't power things from it.

Try with the ESP32-EVB, the +5V there can be used to power boards.
Technical support and documentation manager at Olimex

LubOlimex

Also even if the powering works I would not recommend powering 8 relay board via any ESP32 board... This would lead to some major glitches during switching and might influence the onboard wifi and whatnot other typical problems when using electromechanical relays.

Consider powering the relays from another source.
Technical support and documentation manager at Olimex

oleole

Thank you for both, that makes sense.
I will check with external power source once I find it.

In a meantime - EVB works (checked few pins).

Many thanks for your support LubOlimex!

And last question - how can I understand from schematics that 5V in Gateway is intended for input only?

Greetings

LubOlimex

#8
It is easily traceable even in the PDF here:

https://github.com/OLIMEX/ESP32-GATEWAY/blob/master/HARDWARE/Hardware%20revision%20G/ESP32-GATEWAY_Rev_G.pdf

Download the PDF and you find on the page 5V_EXT and see it goes at the wrong side of the FET2 - top left corner of the schematic.

Make sure to compare that power part of the schematic of ESP32-GATEWAY and ESP32-EVB to see the differences. You see in ESP32-EVB's schematic signal +5V goes to the other side of the transistor.

It is also mentioned in the pinout diagram, albeit a little bit convoluted, under the top header (where powering options are described):

https://www.olimex.com/Products/IoT/ESP32/ESP32-GATEWAY/resources/ESP32-GATEWAY-GPIOs-Rev.F-up.pdf
Technical support and documentation manager at Olimex

oleole

Thank you LubOlimex for your your kind and quick support.
I do understand the schematics now. Also, I'm confirming using external power source for relay solved the issue for me.