New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

The relay clicks briefly when the Pi boots and the irrigation valve opens. What state are the GPIOs in at boot?

The relay clicks briefly when the Pi boots and the irrigation valve opens. What state are the GPIOs in at boot?

Solved 5 4

Translated from Türkçe by AI ·

I’m using a Pi Zero 2 W for garden irrigation. A 4-channel relay board drives 24V AC valves, I open and close the valves with commands from Hermetry, and the soil moisture is graphed from there too. It works really well, but there’s one problem: every time the Pi restarts (after a power cut, for example), valve 1 opens for a few seconds and then closes once the script runs. One night during an outage, water came through the line and surprised the neighbour too.At the very start of the script I set the pin HIGH (the board is active-low). But I don’t know what happens until the script is running. What state are the GPIOs in at boot?

♥ 0

Translated from Türkçe by AI ·

Which pins are you using? Do you notice it?

♥ 0

Translated from Türkçe by AI ·

Valve 1 is GPIO22, valve 2 is GPIO23, 3 and 4 are GPIO24, GPIO25. The same thing happens on all of them, but we noticed valve 1 the most.

♥ 2

Translated from Türkçe by AI ·

Could the power supply be weak? I read that the relay chatters when the voltage drops during startup.

Modbus sadece register'dır, ta ki olmayana kadar.
♥ 0

Translated from Türkçe by AI ·

I don’t think it’s power, it’s exactly the situation you described. At startup the Pi initialises GPIO0-8 with the internal pull-up (HIGH) and GPIO9-27 with pull-down (LOW). Your pins are all in the 9-27 range, so until the script runs they are LOW. The board is active-low, so LOW = relay energised = valve open. We had the same thing happen on the test rig in our lab.
There are two fixes, doing both together is the most robust:
1. Add a line to /boot/firmware/config.txt that sets the pins as outputs driven HIGH early in boot, without waiting for the script:

gpio=22-25=op,dh

This is applied at firmware stage, but a very short LOW may still occur at the very first moment of power-up. So:
2. Put a 10k pull-up resistor from each relay input to 3V3. That way the input stays HIGH even when the Pi is not driving it at all.
Also, on the Hermetry side, have the script send the valve states as telemetry such as valve1_open: 0, so after an outage you see the real state on the dashboard.

Accepted solution♥ 1

Translated from Türkçe by AI ·

I added the config.txt line, and the glitch at startup has almost completely gone; when I measured it, only a few hundred milliseconds were left. Once I also fitted the pull-up resistors, that disappeared too. The water doesn’t come on before the valve opens anymore, and the neighbour is relieved too 😄 Thanks Cansu.

♥ 0
Viewing 6 posts – 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Join the conversation

Sign in to ask and answer, like helpful posts and mark the reply that solved your problem. Every contribution earns points and levels.

Share