Created
July 7, 2022 01:23
-
-
Save eddiewebb/3a347c82c5942a49ceefe6e5bdcec3dc to your computer and use it in GitHub Desktop.
Revisions
-
eddiewebb created this gist
Jul 7, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ ### What A 'fix' for the notoriously poor reading issues of DHT hygrometer sensors from Python / Raspberry Pis. ### Why 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. Super useful: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/monitoring_and_managing_system_status_and_performance/tuning-scheduling-policy_monitoring-and-managing-system-status-and-performance ### How 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%+**