ESP32 diy 32 relays

I am trying to develop a relayboard for my house. I want to use the ESP32 as a controller so i can connect it via wifi.

I think i need to use the ESP32 with 4 x 74HC595 shift registers to have the 32 outputs. Do i need to add 32 optocouplers after the shift registers to control the relays?

Also i think the relays are 5v relays, i am not sure if i can find 3.3v relays. Do i need level shifters after the optocouplers or can it be done differently, i made 2 tinkercad projects but it is with an arduino, and not on 3.3v ESP32.

Any help would be handy since i don't know the best way to approach this.
Thanks

What is your power supply ? 5V or 12V ?

I assume that you power the ESP32 board with 5V.
Then you can use 5V for the relays.
Are you going to use relay modules or the bare relays ?

It depends on your ground wiring and the coil current if you can make it work. Optocouplers prevent a number of problems, but if you have all the GNDs connected anyway, then optocouplers might not be needed.

I'm not sure if the 74HC595 should be used to drive the relay coils. I'm thinking about those very old ULN2803 drivers.

I prefer to make my own pcb and use the ESP32 Wrover (3.3v) so i don't use the 5V board. (i can use a esp32 board with 5v, but are the gpio still 3.3v tolerant and not 5v?)

I plan on using bare relays, no relayboards. I still have to design the pcb so i can design it as "good" as needed. If needed i can use mosfets to drive the relays?

Hi

You will need to provide some form of driver for the relay coil.
595 and MOSFET drivers would work.
The MOSFET would have to be logic level MOSFETs.

Tom.... :grinning: :+1: :coffee: :australia:

Thanks, so if i am correct, the 74HC595 output goes to the mosfet (FDN337N for example?) which drives the 3v relay?

Will relays like these work:

Then use the TPIC6B595 instead of the 74HC595.
Same function, but with power outputs that can drive a 5volt relay directly.
Leo..

Thanks but it needs a minimum of 4.5v which i don't have, i have a 3.3v ESP32 and 3v relays

Yep, forgot. TPIC is 5volt only.
You could use a level translator between ESP and TPIC.

I would stay away from 3volt relays (high coil current). 32 5volt relays already use about 2.5A.
5volt supplies are more common, and you can easily drop that to 3.3volt for the ESP with a linear regulator.
Leo..

But then i need 32 voltage regulators as well, or how do i connect it?

Hi,
What will you be using for your 3V3 supply?
Having a 5V supply just for the relays is not a bad thing, it will ensure relay noise does not get back into the controller supply.

Tom... :grinning: :+1: :coffee: :australia:

I was thinking about this power supply but if i need something else, i am open to change

Mean Well IRM-02-3.3

If i need 12v (or 5v) for the relays, and i need to bring the voltage back to 3.3v only for the esp32 that would be fine as well, but for simplicity i thought it would be better to use 3.3v to everything

After seeing this, i think this will be easier and probably better than designing it myself

The obsolete ones?

But why do it the hard way?

That may be the case, but you will require four of them to control your 32 circuits.

I am proposing to use 32 relays for my home control. Mind you, the project has been delayed for some 25 years. :woozy_face: I will be using 24 V relays as that minimises the current requirement. The relays I have however are the proper ones for mains control, socketed to DIN rail mounts on a panel in a control box, so the relay driver board is separate.

To control 32 relays, you use four of the TPIC6B595 as Wawa pointed out. While the datasheet recommends a more strict logic level to drive them they would probably work just fine on 3.3 V logic. In any case, you just use a 74HCT14 to convert the levels - two cascaded gates for each of the three control lines to drive the chain of four TPIC6B595s.

You require a 5 V supply for all the logic circuitry including your ESP32 module with its own 3.3 V regulator. If you use 12 V or 24 V relays, then you need a supply for that as well, no great problem. There would never be a reason to consider using 3.3 v relays.

since you are planning on making your own boards and you only have to control the coil of the 24V relays... and.... 24 v relays are most commonly AC coil voltage, why make so many different steps between devices ?

There are devices that can control AC voltage and can be controlled by DC signals.

Personally, I would make modules of groups, 4 or 8 and not only large board with 32.
also, I would add at least 20% more space for instant control if a failure occurred.

and I would also highly recommend you look at SSR relays. much less power.
magnetic relays will fail over time, make a noise when changing state and can hum if manufacturing is not perfect or age is creeping up.

Thanks for all the replies.

I prefer solid state relays but i don't think i have the knowledge to make the pcb the right way. I understand i need 4 of those relayboards but that is not a problem. I am not sure how to exactly make a PCB where i need 3.3v for the ESP but also 3.3v signals for the GPIO, probably it is simple but still not for me. I was planning on making multiple pcb's for 8 relays and use just signal lines from pcb 1 till 2 for the shift registers (not sure if that is possible) so board 1 is the "master" board and all the next are just "slave boards" who get the values from the previous shift register.

I think making my own pcb would be a better solution for my problem but i am not sure if i am able to do it properly.

The noise from the relays is not a problem. I have a server rack on the top floor with all the servers and logic for home domotica but ofcourse solid state relays would be better

Hi,

Where is the fun, the feeling of accomplishment? ? ? :grinning:

Tom... :grinning: :+1: :coffee: :australia:

You could use a 16 relay board.
Well two of them anyway.

If it were my project.
I would make the control logic board and buy relay modules

Note that most of them have a design fault.
No user selectable opto isolation, despite of opto couplers.
Better to stack four 8-channel boards (with JD-VCC jumper).
Leo..

I would buy/design an 2-relay board with ESP8266 first (ESP-32 is overkill for that).
Then, with the gained experience, you might be able to design a large project like this.
Leo..

There used to be small 74HC595 boards available that plugged directly onto a common 8-relay board. Easy shift register expansion. Not sure what happened to those.
Leo..