Code: Select all
#!/bin/bash # Setup output pin 18 echo "18" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio18/direction # Loop every 5 mins while sleep 300 do # Reset failure flag FAIL=0 # Ping an address once ping -c1 google.com # If failure, set failure flag if [ $? -ne 0 ]; then FAIL=1; fi # Repeat ping and failure test lines for all addresses # Test fail flag if [ $FAIL -eq 1 ] then echo "1" > /sys/class/gpio/gpio18/value else echo "0" > /sys/class/gpio/gpio18/value fi done
AustinA2 wrote: ↑Wed Mar 13, 2019 5:48 pm@jbudd:
Is this something run through the pi?
my problem is this; I am new to both Pis and Python. I know this is possible because i have seen pieces of what i want to do in various instances but i am having trouble putting it together how i want to..
I want to tie 1 ip address to 1 pin and have a code that says hey this ping failed, send a HIGH or LOW. I understand that there is varying logic here, but i think it makes more sense for the pin to be "on" when it is working. that way when it is "off" we know either the ping failed or the devices has lost power.
i am having trouble putting it together how i want to..
I want to tie 1 ip address to 1 pin and have a code that says hey this ping failed, send a HIGH or LOW.