View Single Post
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2021-05-28, 17:33

So this needs to run every roughly 10 seconds?

Consider getting rid of the loop altogether and instead making a systemd unit that calls the script at an interval. Something like:

Code:
[Unit] Description=Read DHT sensor [Service] User=%I Restart=always RestartSec=10s ExecStart=#!/usr/bin/python3 /path/to/your/script.py
Put that in /etc/systemd/system/read-dht-sensor.service and then do systemctl enable read-dht-sensor --now (I think).

I'm assuming this is on Raspbian and/or that you have systemd.
  quote