-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestart_node.py
More file actions
28 lines (19 loc) · 798 Bytes
/
restart_node.py
File metadata and controls
28 lines (19 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## This script requires soldering wires from the Station G2 restart button traces to a relay
import RPi.GPIO as GPIO
import time
RESTART_BUTTON_PIN = 5 # GPIO5 for the restart button
# Setup GPIO
GPIO.setmode(GPIO.BCM) # Use BCM pin numbering
GPIO.setup(RESTART_BUTTON_PIN, GPIO.OUT)
GPIO.output(RESTART_BUTTON_PIN, GPIO.HIGH) # Relay off = HIGH for normally open
def restart_node():
try:
GPIO.output(RESTART_BUTTON_PIN, GPIO.LOW) # Press restart button (activate relay)
print("Restart button pressed.")
time.sleep(1) # Hold for 1 second
GPIO.output(RESTART_BUTTON_PIN, GPIO.HIGH) # Release restart button
print("Restart button released.")
finally:
GPIO.cleanup()
if __name__ == "__main__":
restart_node()