Need help with a script.

cscool36

Full time elf
Joined
Jan 9, 2011
Messages
167
Location
Belrose NSW
Hi all,
See script below

#!/bin/sh
###########################################################
# GPIO-On.sh - Turn on one of the Pi's GPIO Outputs #
###########################################################

# Set the GPIO number (NOT the pin number)
GPIO="21"
TIMER="200"

# Make sure the pin is setup for output.
/opt/fpp/src/fpp -G ${GPIO},Output

# Turn on the pin
/opt/fpp/src/fpp -g ${GPIO},Output,1

# Timer

/opt/fpp/src/fpp -s ${Timer},clock
/opt/fpp/src/fpp -s ${Timer},1


# Make sure the pin is setup for output.
/opt/fpp/src/fpp -G ${GPIO},Output

# Turn Off the pin
/opt/fpp/src/fpp -g ${GPIO},Output,0

When I run this script. This is what I get.
2,1,Configuring GPIO,21,Output,,,,,,,,,
2,1,Setting GPIO,21,Output,1,0,,,,,,,
2,0,75,No playlist scheduled.,
2,0,75,No playlist scheduled.,
2,1,Configuring GPIO,21,Output,,,,,,,,,
2,1,Setting GPIO,21,Output,0,0,,,,,,,

I need some help with setting the timer code in red. I would like to turn on a relay
GPIO 21 and 90 minutes later it will turn off. The on/off part of the script works well, just need timer info to get the script to work.
Thanks
Colin
 

franky_888

Full time elf
Joined
Dec 31, 2013
Messages
160
Location
Medowie
Just to clarify, do you want it to turn off after 90 minutes or are you saying that's what's happening now?

"fpp -s" (According to the help page at least) prints the fppd status, there's no switch for timers.

You *could* just add a sleep command in here, so replace this:

Code:
# Timer

/opt/fpp/src/fpp -s ${Timer},clock
/opt/fpp/src/fpp -s ${Timer},1

with this:

Code:
# Timer
sleep 90m

BUT! This will make your script run for 90 minutes - if you run this from a command line for example it will sit there for 90 minutes before finishing.

Do you have a GPIO-Off.sh script somewhere? Can you make that and just schedule that 90 minutes later?
 

cscool36

Full time elf
Joined
Jan 9, 2011
Messages
167
Location
Belrose NSW
Thanks, Franky_888
The Sleep 90m worked just like I need to.
The relay turns on and sleeps for the time, and It still goes to the next playlist and starts.
Colin
 
Top