diff --git a/RPI Code/SmartGarden/allInOne.py b/RPI Code/SmartGarden/allInOne.py index a6a6e1a..50feb12 100644 --- a/RPI Code/SmartGarden/allInOne.py +++ b/RPI Code/SmartGarden/allInOne.py @@ -8,11 +8,11 @@ import paho.mqtt.client as mqtt import socket broker="192.168.31.140" -username="mqtt" -password="mqtt" +#username="mqtt" +#password="mqtt" mqttc = mqtt.Client("SmartGarden_PiZero1") -mqttc.username_pw_set(username, password) +#mqttc.username_pw_set(username, password) delayBetweenSending = 300 @@ -201,6 +201,7 @@ mqttc.on_message=on_message mqttc.loop_start() #start loop to process received messages mqttc.subscribe("SmartGarden_WaterRelay")#subscribe +#mqttc.loop_forever() print('Reading ADS1x15 values, press Ctrl-C to quit...') # Print nice channel column headers. diff --git a/RPI Code/SmartGarden/network-monitor.sh b/RPI Code/SmartGarden/network-monitor.sh new file mode 100644 index 0000000..29b53fd --- /dev/null +++ b/RPI Code/SmartGarden/network-monitor.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +while true ; do + if ifconfig wlan0 | grep -q "inet" ; then + sleep 60 + else + echo "Network connection down! Attempting reconnection." + sudo ifconfig wlan0 down + sudo ifconfig wlan0 up + sleep 10 + fi +done