The DHT11 is a temperature and humidity sensor with a maximum frequency of 0.5Hz (one read per 2 seconds). So speed is not the issue here!
Yes, data can be read only once every two seconds, but that's not the timing one needs to be concerned with. The real timing issue is in issuing digital signals to the device to inform it that we're about to read data from it. This is measured in microseconds. Perl, at best can reliably deal in milliseconds.
You can extract two formats of data from this device. First, you have to hold the signal pin LOW for 18us (microseconds) to tell it you want to read data, then set it back HIGH. For the first format that is returned, the device sets the data pin low for exactly 50us (microseconds), then immediately hold it high for 26-28us. For format two, holds low for 50us, then high for 70us. If you're off even marginally sending or receiving these signals, you'll possibly get the incorrect format, corrupt or no data at all.
So on a Raspberry Pi, even while using C, you can still get mis-timed events because of possible contention of the CPU. This is why microcontrollers are so much better for this. They operate instructions in a linear fashion and never have the overhead of other processes competing for CPU cycles.
Also, Perl can't manipulate hardware registers like this directly. Even if it could, the timing would be too unreliable to be effective.
In reply to Re: XS Modules - why and when?
by stevieb
in thread XS Modules - why and when?
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |