Skip to content

relay_script_pulse

Pragmatismo edited this page Mar 13, 2023 · 3 revisions

pulse_relay.py

This script turns on and off a relay in a continual loop, this is useful for devices like water pumps in hydroponic systems.

The script should be called when the pigrow boots, in cron this will look like;

@reboot /home/<username>/Pigrow/scripts/autorun/pulse_relay device=<relay device name>

Each pulsing device requires it's own pulse_relay script running.

Pulse duration is controlled using settings in the pigrow_config.txt file, it requires a standard setup relay device with an added command for it's on and off period durations;

pulse_<device name>=<on period>:<off period>

For example a waterpump controlled by a relay on GPIO 21 could be turned for 30 seconds then off for 60 seconds with the settings;

gpio_waterpump=21
gpio_waterpump_on=low
pulse_waterpump=30:60

To temporarily pause pulsing the duration setting can be set to

1:0   steady on
0:1   steady off   

The script pulse_relay monitors pigrow_config.txt for changes so when pulse_= is changed in the config file the pulse frequency will update without requiring the script to be restarted.

Clone this wiki locally