Comments (2)
Yep the DHT code is sensitive to other tasks taking too much CPU. It's bit-banging the GPIO on the Pi as fast as it can (and actually tries to increase the process' priority so the kernel gives it as much time as possible) so that it doesn't miss any of the relatively short pulses from DHT sensor (~50-80 microseconds long each). If something CPU intensive runs at the same time it will throw off the timing and give bad results that don't pass the checksum.
Yeah interesting idea to use SPI hardware to read the signal. It's a trade off though in that you could only use one DHT sensor at a time with SPI. I'm not super familiar with the Pi DMA support but perhaps there's a way to read GPIO very quickly and dump it to memory with a DMA timer too. That might make things more flexible, but could be a lot of work.
A third thing to look at too is that in the more recent Linux kernels (since ~3.18 IIRC) they actually added a native DHT sensor module to the kernel. I think there's a little more info in this thread: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=98543 Since it's being read by the kernel it might be a little more resilient to processor intensive tasks happening at the same time, but I wouldn't be surprised if by using the module you find mjpg streamer starts stuttering. :)
For now I think we like the simplicity and flexibility of bit-banging GPIO in the current implementation. If you have some hard real time tasks you need to do in addition to CPU intensive stuff on the Pi you might look at adding a small Arduino to talk to the sensor and then send data back to the Pi over a serial link.
from adafruit_python_dht.
Tony, Thanks for detailed answer. I found it extremely useful.
For now I stick with measuring with multiple retires after I will jump to proposed Arduino solution.
from adafruit_python_dht.
Related Issues (20)
- pip package looks broken HOT 4
- Installation failure on Windows 10 HOT 2
- hello...I try to install python library of dht11 on raspberry pi but it appear no route to host?what is the problem?please help me... HOT 2
- Semaphore not finding library HOT 4
- Cable Length Causes incorrect DHT11 Readings HOT 6
- import errors in setup.py HOT 1
- unknown platform due to very wrong detection mechanism HOT 1
- Specifiy Raspberry version when using pip3 install Adafruit_DHT HOT 3
- IOError: [Errno 24] Too many open files: '/proc/cpuinfo' HOT 2
- Can't install on RPI3 HOT 1
- Will this work in Ubuntu 16.04 with normal pc HOT 7
- Declare sensor dinamically HOT 2
- DHT22 humidity and temperature values are incorrect HOT 2
- setup.py fails to install with error "TypeError: __init__() takes exactly 2 arguments (4 given)" HOT 4
- Google Authentication Error HOT 1
- I can not install RaspBerry 3 and Raspbian Jessie Lite HOT 10
- Broken link in ez_setup HOT 4
- AdafruitDHT.py show higher temp HOT 2
- Problem witch installing HOT 5
- Failed pip Install of Adafruit_Python_DHT on Raspbian Stretch HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_python_dht.