5

I'm trying to get the hydrosys4 open source irrigation control software to work with my 16 channel relay board and raspberry pi zero w.

When the pi boots up the relay is triggered multiple times, rapidly ( this is not good, the relays will have AC loads in the final setup ).

Below shows my current wiring to the 16 channel relay board. Here's a link to a document I could find showing the relay board schematic. Sainsmart relay schematic

Wiring Diagram

Is there any hardware/wiring I can add to prevent the relays from triggering during the pi boot?

tlfong01
  • 4,384
  • 3
  • 9
  • 23
D A
  • 61
  • 4
  • 1
    i think that this question has been asked before ... it has nothing to do with the relay board ... search `state of GPIO pins at boot` – jsotola Jun 14 '21 at 00:03
  • 1
    I have searched this issue and I can find several posts where its mentioned but then there's the statement (It is safest to find a hardware solution if you have hardware which could be incorrectly triggered at system startup.) I'm looking for help with that hardware solution. – D A Jun 14 '21 at 00:12
  • 1
    It is unclear what is connected, why you have multiple 5V, Gnd connections. The module is unsuitable See [Can you use a 5V Relay Module with the Pi?](https://raspberrypi.stackexchange.com/a/118117/8697) – Milliways Jun 14 '21 at 00:41
  • (1) Your link is broken. Is it this one? 16-Channel 12V [Low level trigger] Relay Module SKU: 101-70-103 US$119 - Sainsmart https://www.sainsmart.com/products/16-channel-12v-relay-module (2) Show us a photo of your wiring. – tlfong01 Jun 14 '21 at 01:55
  • (3) This is the schematic of the relay linked in (1) https://imgur.com/gallery/M7bQp5C. (4) Please show us the photo asked in ((2). – tlfong01 Jun 14 '21 at 02:07
  • (5) Imgur does not allow me to upload pictures too often. So I am uploading them as an answer. (6) Please let me know if you know how to use a multi-meter. I can show you the steps to troubleshoot. – tlfong01 Jun 14 '21 at 02:33

1 Answers1

6

You could use an IO expander module (e.g. PCF8575 or MCP23017) between the Pi and the relay board: those modules don't change pin states unless they receive a valid I2C/SPI command, so they will not be affected by sporadic pin toggling at boot.

You'll have to enable the correspoding interface (I2C or SPI) on the Pi to be able to talk to the expander.

Another solution is to use an Arduino or a similar controller, which would receive commands from the Pi and in turn control the relay board. The advantage here is flexibility: you can program the Arduino exactly the way you want it to behave, implement whatever interface you like with the Pi (if I2C and SPI cannot be used, you could use a UART or even a GPIO pin which has to be toggled in a specific sequence to activate the relay). The Arduino could also implement safety features, e.g. turn off AC loads if the Pi was not sending any commands for a long time, probably due to a SW crash.

Dmitry Grigoryev
  • 26,688
  • 4
  • 44
  • 133
  • Can you recommend a way to keep the power off of the relay board during boot up? I have decided to power the relay separately and use an npn transistor from the gpio to trigger the relay pin. – D A Jun 19 '21 at 13:34