Add Raspi Code - network monitor and allInOne

This commit is contained in:
Thomas Fransolet 2020-04-08 18:34:06 +02:00
parent 139b6d86db
commit d770dd71f3
2 changed files with 16 additions and 3 deletions

View File

@ -8,11 +8,11 @@ import paho.mqtt.client as mqtt
import socket import socket
broker="192.168.31.140" broker="192.168.31.140"
username="mqtt" #username="mqtt"
password="mqtt" #password="mqtt"
mqttc = mqtt.Client("SmartGarden_PiZero1") mqttc = mqtt.Client("SmartGarden_PiZero1")
mqttc.username_pw_set(username, password) #mqttc.username_pw_set(username, password)
delayBetweenSending = 300 delayBetweenSending = 300
@ -201,6 +201,7 @@ mqttc.on_message=on_message
mqttc.loop_start() #start loop to process received messages mqttc.loop_start() #start loop to process received messages
mqttc.subscribe("SmartGarden_WaterRelay")#subscribe mqttc.subscribe("SmartGarden_WaterRelay")#subscribe
#mqttc.loop_forever()
print('Reading ADS1x15 values, press Ctrl-C to quit...') print('Reading ADS1x15 values, press Ctrl-C to quit...')
# Print nice channel column headers. # Print nice channel column headers.

View File

@ -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