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?

  • 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
    Commented Jun 14, 2021 at 0: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
    Commented Jun 14, 2021 at 0: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?
    – Milliways
    Commented Jun 14, 2021 at 0: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 sainsmart.com/products/16-channel-12v-relay-module (2) Show us a photo of your wiring.
    – tlfong01
    Commented Jun 14, 2021 at 1:55
  • (3) This is the schematic of the relay linked in (1) imgur.com/gallery/M7bQp5C. (4) Please show us the photo asked in ((2).
    – tlfong01
    Commented Jun 14, 2021 at 2:07

1 Answer 1


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.

  • 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
    Commented Jun 19, 2021 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.