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.
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.
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.
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
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. 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.
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