24v Wireless Siren with 2 Raspberry Pi Zeros

Hello all,

I have built a 24v wireless siren with 2 raspberry pi zeros communicating over wifi.

I have a relay on the second pi using gpio pin 17 switching on a 24v siren.

I have a 24v signal from a line controller turning a relay on to a gpio pin 26 on the first pi.

The problem I am having is the siren stops working after a day or 2.

I have to power cycle to get it to work again.

I have tried a couple different python codes.

I do have them setup with static ip addresses.

Parts list:

2 – Raspberry Pi zero

1 – 5v Relay Module by Inland

1 – Solid State Relay (SSM1D26BD)

1 – TP-LINK AC1200 Wireless Daul Band Router (Model: Archer C50)

Below is the current code I am using:

from gpiozero import LED, Button

from gpiozero.pins.pigpio import PiGPIOFactory

from signal import pause

from signal import pause

import time

slavePI = PiGPIOFactory(host=‘192.168.0.20’)

siren = LED(17, pin_factory=slavePI)

relayON = Button(26, pull_up=False)

siren.source = relayON.values

pause()

Below is the code I first wrote:

from gpiozero import LED, Button

from gpiozero.pins.pigpio import PiGPIOFactory

from time import sleep

from signal import pause

import time

factory = PiGPIOFactory(host=‘192.168.0.20’)

siren = LED(17, pin_factory=factory)

voltage = Button(2)

voltage.when_pressed = siren.on

voltage.when_released = siren.off

pause()

I get the same result with both codes.

The siren stops working after a day or 2.

The temporary fix I came up with is to auto reboot the pi’s every 6 hours using:

sudo crontab –e

and adding this to that file

0 7 * * * /sbin/shutdown -r now

0 13 * * * /sbin/shutdown -r now

0 19 * * * /sbin/shutdown -r now

0 1 * * * /sbin/shutdown -r now

Please help me out here

Thank you

Kyle Eul

Something might be overflowing in your code, you might try a cron job that quits your sketch and restarts it every so often as a workaround.

YellowDog:
Something might be overflowing in your code, you might try a cron job that quits your sketch and restarts it every so often as a workaround.

Can you be a little more clear on "overflowing"??

from gpiozero import LED, Button

from gpiozero.pins.pigpio import PiGPIOFactory

from signal import pause

import time

slave_pi = PiGPIOFactory(host=‘192.168.0.20’)

siren = LED(17, pin_factory=slave_pi)

relay_on = Button(26, pull_up=False)

siren.source = relay_on.values

pause()

I changed my code to use snake case and I noticed I put “from signal import pause” twice so I remove one of those lines