The relay clicks briefly when the Pi boots and the irrigation valve opens. What state are the GPIOs in at boot?
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?
Bahçe sulaması için Pi Zero 2 W kullanıyorum. 4 kanallı bir röle kartı 24V AC vanaları sürüyor, Hermetry’den komutla vana açıp kapatıyorum, toprak nemi de oradan grafik oluyor. Gayet güzel çalışıyor ama bir sorun var: Pi her yeniden başladığında (elektrik kesintisinden sonra mesela) 1. vana birkaç saniye açılıyor, sonra script çalışınca kapanıyor. Bir gece kesinti olunca hattan su gelmesi komşuyu da şaşırttı.
Script’te en başta pini HIGH yapıyorum (kart aktif-low). Ama script çalışana kadar ne oluyor bilmiyorum. GPIO’lar açılışta hangi durumda oluyor?
Translated from Türkçe by AI ·
Which pins are you using? Do you notice it?
Hangi pinleri kullanıyorsun? Fark ediyor.
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.
Vana 1 GPIO22, vana 2 GPIO23, 3 ve 4 GPIO24, GPIO25. Hepsinde aynı şey oluyor aslında ama en çok 1. vanayı fark ettik.
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.
Güç kaynağı zayıf olabilir mi? Açılışta voltaj düşünce röle titrer diye okumuştum.
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.
Güç değil bence, tam tarif ettiğin durum. Pi açılışta GPIO0-8’i dahili pull-up ile (HIGH), GPIO9-27’yi pull-down ile (LOW) başlatıyor. Senin pinlerin hepsi 9-27 aralığında, yani açılıştan script çalışana kadar LOW. Kart aktif-low olduğu için LOW = röle çekik = vana açık. Bizim lab’daki deney düzeneğinde aynısını yaşamıştık.
İki çözüm var, ikisini birlikte yapmak en sağlamı:
1. /boot/firmware/config.txt dosyasına pinleri boot’un erken aşamasında çıkış + HIGH yapan satır ekle, script’i beklemez:
gpio=22-25=op,dh
Bu firmware aşamasında uygulanıyor ama yine de güç verildiği ilk anda çok kısa bir LOW kalabilir. O yüzden:
2. Her röle girişinden 3V3’e 10k pull-up direnci koy. Böylece Pi hiç sürmezken bile giriş HIGH kalır.
Bir de Hermetry tarafında script açılışta vana durumlarını valve1_open: 0 gibi telemetri olarak göndersin, kesintiden sonra panoda gerçek durumu görürsün.
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.
config.txt satırını ekledim, açılıştaki açılma neredeyse tamamen gitti, ölçünce ancak birkaç yüz milisaniye kalmıştı. Pull-up dirençleri de takınca o da kayboldu. Vana açılmadan önce su gelmiyor artık, komşu da rahatladı 😄 Teşekkürler Cansu.
- 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.

