mirror of
https://bitbucket.org/myhomie/mycorerepository.git
synced 2025-12-06 09:41:19 +00:00
Add Raspi Code - network monitor and allInOne
This commit is contained in:
parent
139b6d86db
commit
d770dd71f3
@ -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.
|
||||||
|
|||||||
12
RPI Code/SmartGarden/network-monitor.sh
Normal file
12
RPI Code/SmartGarden/network-monitor.sh
Normal 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
|
||||||
Loading…
x
Reference in New Issue
Block a user