I have some trouble using the watchdog with python3.
I unpluged the wire betwen 6 & 7 (put a switch for convinience ).
The watchdog restarts the device, so that's fine at this point.
But when I want to control it in python that's a mess.
For instance, I want to get temperature and humidity (that's OK) and send them.
The wathdog should restart the device if the time is up for each call (assuming that the call is scheduled every 5 seconds and begins with a wd "restart" ).
But I don't get why it doesn't work: is "rpi.core.wd.value=True" the correct statement ?
The following piece of code worked perfectly when the watchdog wasn't enabled.
Thanks guys
Code: Select all
#!/usr/bin/env python3
import time
from timeloop import Timeloop
from datetime import timedelta
import revpimodio2
import requests
tl = Timeloop()
rpi = revpimodio2.RevPiModIO(autorefresh=False)
rpi.handlesignalend()
@tl.job(interval=timedelta(seconds=5))
def sample_job_every_5s():
rpi.core.wd.value=True
temperature = int.from_bytes(rpi.io.RS485Input_2.get_value(), "little") / 20
humidity = int.from_bytes(rpi.io.RS485Input_1.get_value(), "little") / 100
# r = requests.post('http://192.168.1.50:8080', data={'temperature': temperature, 'humidity': humidity})
print("ON : {}".format(time.ctime()))
if __name__ == "__main__":
tl.start(block=True)