I have a pi 3B and a relay board – “5V relay module is active LOW, meaning that LOW level will activate the relay on and HIGH level will deactivate it.” .
I have connected 5V to Vcc on the relay, ground to gnd and another pin and Pin 12 to ch1.
This setup works as the relay will turn on with movement but the relay goes straight off.
I am using motioneye to “run a command” and “run an end command” in the movement notification section.
I need the space on the SD card so didn’t want to install Python although I can if required. It also seems a bit OTT for a simple GPIO output.
My two bash scripts are below and they have bee given 755 permissions.
lightOn.sh ( run a command )
#!/bin/bash
echo "18" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio18/direction
echo "0" > /sys/class/gpio/gpio18/value
# I have tried adding sleep 60s here
exit
lightOff.sh ( run an end command )
#!/bin/bash
echo "18" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio18/direction
# I have tried adding sleep 60s here
echo "1" > /sys/class/gpio/gpio18/value
exit
I have no experience with bash and have no idea why the above will not work; I have added sleep 60s without success in different places.
Can somebody point out what I am doing wrong?
Note: If I swap the values around the relay never goes off.
Categories: Uncategorized

.END