The rule that opens the pump relay at sunset makes the Pi restart every time it runs
Translated from Türkçe by AI ·
I built a setup for a garden irrigation and tank filling pump, not at work but at my own home.Raspberry Pi 3B, with a 4-channel ready-made relay board on top (SRD-05VDC, the board says optocoupler on it). The relay drives the coil of a 230 V contactor, and the contactor switches the 1.1 kW pump. The Pi is connected to Hermetry over MQTT. The profile has a command called pump.set. I set up a trigger on the Rules card based on sunset, and it turns off after 20 minutes. The command arrives, the relay pulls in, the pump runs.The problem: when the relay releases (sometimes also when it pulls in), the Pi resets or SSH freezes. In Hermetry’s Log tab for the device, I see keepalive_timeout at the same time every evening, and then Connected a minute later. An SD card has also failed once.The board is wired like this: Pi 5V to board VCC, Pi GND to board GND, GPIO17 to IN1. The JD-VCC jumper stays in place. The contactor coil is powered from an extension cord on the same outlet as the Pi.Why does this happen when the relay board is isolated? Could it be something in software, like the Python script crashing when it receives the command?
Bahçe sulama + depo dolum pompası için kurduğum düzenek var, iş yerinde değil, kendi evimde.
Raspberry Pi 3B, üstünde 4 kanallı hazır röle kartı (SRD-05VDC, üstünde optokuplör yazıyor), röle 230 V’luk bir kontaktörün bobinini sürüyor, kontaktör de 1,1 kW’lık pompayı. Pi Hermetry’ye MQTT ile bağlı, profilde pump.set diye bir komut var, Rules kartında gün batımına göre tetikleyici kurdum, 20 dakika sonra kapatıyor. Komut geliyor, röle çekiyor, pompa çalışıyor.
Sorun: röle bırakırken (bazen çekerken de) Pi resetleniyor ya da SSH donuyor. Hermetry’de cihazın Log sekmesinde her akşam aynı saatte keepalive_timeout ve bir dakika sonra Connected görüyorum. Bir kere SD kart da bozuldu.
Kart şöyle bağlı: Pi 5V → kart VCC, Pi GND → kart GND, GPIO17 → IN1. JD-VCC jumper’ı takılı duruyor. Kontaktör bobini Pi ile aynı prizdeki uzatmadan besleniyor.
Röle kartının izolasyonu varken bu neden oluyor? Yazılımsal bir şey mi acaba, komutu alınca Python betiği çöküyor olabilir mi?
Translated from Türkçe by AI ·
I think it’s software. If an exception occurs in the command handler, the script may be crashing. Have you looked at the systemd log?
Bence yazılım. Komut handler’ında exception olunca betik düşüyor olabilir, systemd log’una baktınız mı?
Translated from Türkçe by AI ·
I checked journalctl, the script is not throwing any errors, the Pi itself is resetting, the uptime is going back to zero.
journalctl’e baktım, betik hata vermiyor, Pi’nin kendisi resetleniyor, uptime sıfırlanıyor.
Translated from Türkçe by AI ·
Shouldn’t there be a diode in parallel with the contactor coil? In class we learned that a reverse voltage appears across the coil terminals.
Kontaktör bobinine paralel bir diyot koymak lazım değil mi? Derste bobin uçlarında ters gerilim oluşur diye görmüştük.
Translated from Türkçe by AI ·
I had almost the same thing happen at home; an electrician friend solved it and I learned from him. There are two problems.First, the JD-VCC jumper. As long as it is fitted, the optocoupler on the board isolates nothing: the relay coil is also powered from the Pi’s 5V and the grounds are common. The pulse produced when the relay coil releases goes straight onto the Pi’s supply. To do:
- Remove the jumper.
- Power JD-VCC and the coil-side GND of the board from a separate 5V adapter (a cheap 5V 1A is enough).
- From the Pi to the board, only VCC (3.3V works too, for the optocoupler LED) and IN1 should go. Do not connect the Pi GND to the coil-side GND.
Second, the contactor coil. The diode Ayşe mentioned is for DC coils; yours is 230 V AC, so a diode won’t work there. Put an RC snubber across the coil terminals (100 Ω + 0.1 µF X2, sold as a ready-made module) or a varistor. The arc when it releases causes noise on the relay contacts, and if the wires run past the Pi it leaks in there too.Even once these are done, keep the Pi 20-30 cm away from the relays, and do not run the 230 V wires in the same channel as the Pi’s GPIO wires.And on the Hermetry side: after sending the pump.set command, have the device report the pump’s actual state (wire the contactor’s auxiliary contact to an input and send it as pump.running). That way, even if the Pi is reset, the rule shows what the device reports rather than what was “sent”.
Evde neredeyse aynısını yaşadım, elektrikçi bir arkadaş çözdü, ben de öğrendim. İki sorun var.
Birincisi JD-VCC jumper’ı. Takılı olduğu sürece kart üzerindeki optokuplör hiçbir şeyi ayırmıyor: rölenin bobini de Pi’nin 5V’undan besleniyor ve toprak ortak. Röle bobini bırakırken oluşan darbe doğrudan Pi’nin beslemesine biniyor. Yapılacak:
- Jumper’ı çıkar.
- JD-VCC ve kartın bobin tarafı GND’si ayrı bir 5V adaptörden beslensin (ucuz bir 5V 1A yeter).
- Pi’den karta sadece VCC (3.3V da olur, optokuplör LED’i için) ve IN1 gitsin. Pi GND’sini bobin tarafının GND’sine bağlama.
İkincisi kontaktör bobini. Ayşe’nin dediği diyot DC bobin için; seninki 230 V AC, ona diyot olmaz. Bobin uçlarına RC snubber (100 Ω + 0,1 µF X2, hazır modül olarak satılıyor) ya da varistör koy. Bırakma anındaki ark röle kontağında parazit yapıyor ve kablolar Pi’nin yanından geçiyorsa oraya da sızıyor.
Bunlar bitince bile Pi’yi rölelerden 20-30 cm uzağa al, 230 V kabloları Pi’nin GPIO kablolarıyla aynı kanaldan geçirme.
Bir de Hermetry tarafında: pump.set komutunu gönderdikten sonra pompanın gerçek durumunu cihazın raporlamasını sağla (kontaktörün yardımcı kontağını bir girişe bağla, pump.running diye gönder). Böylece Pi resetlense de kural “gönderdim” diye değil cihazın söylediğine göre görünür.
Translated from Türkçe by AI ·
Selim thanks, it turned out to be both at once. I removed the jumper and connected a separate 5V adapter, and fitted an RC snubber module next to the coil. For a week now the relay has been clicking on and off every evening, and there is no single keepalive_timeout on the Log tab. I never really understood what JD-VCC is for; I thought there was isolation because the board has optocouplers. I also applied the auxiliary contact idea, and now the panel shows whether the pump is actually running.
Selim teşekkürler, ikisi birden sorunmuş. Jumper’ı çıkarıp ayrı 5V adaptör bağladım, bobine hazır RC snubber modülü taktım. Bir haftadır her akşam röle çekip bırakıyor, Log sekmesinde tek bir keepalive_timeout yok. JD-VCC’nin ne işe yaradığını hiç anlamamışım, kartta optokuplör var diye izolasyon var sanıyordum. Yardımcı kontak fikrini de uyguladım, artık panoda pompanın gerçekten çalışıp çalışmadığı görünüyor.
Translated from Türkçe by AI ·
I didn’t know there would be no diode on the AC coil, thanks 🙏
AC bobine diyot olmayacağını bilmiyordum, sağ olun 🙏
- 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.

