A 'fix' for the notoriously poor reading issues of DHT hygrometer sensors from Python / Raspberry Pis.
I've used the cheap DHT sensors on a few projects and always find the "yeah they're unreliable, just keep trying" and that sucks. How do opther devices work using these sensors? Priority.
So these process changes have, for me, worked to give my python process the realtime CPU & IO access to meet the strict timing requirements of a DHT sensor.
Just add these cpu & io priority settings to your systemd file.
You may be able to lower priority but since I use dedicated zeros I want all the priority possible.
[Service]
...
#give cpu scheduling priority to help timing issues reading DHT sensor
CPUSchedulingPolicy=fifo # fifo or rr are 2 realtime options
CPUSchedulingPriority=99 #highest
Nice=-20 # highest
IOSchedulingClass=realtime # only realtime option
IOSchedulingPriority=0 #highest
[Install]
WantedBy=multi-user.target
Even when using read_retries for the DHT Adafruit library I saw success rate jump from ~60% to 90%+