DTH22, RHT03 and DTH11 sensors can be read with this code!

You are viewing an older revision! See the latest version

Homepage

This DHT22 sensor reading class works with the mbed LPC1768. The code is time dependent but i have not put that in the code so it would only work with mbed LPC1768 currently. I may add timing defines for other platforms if needed but i currently only use the mbed LPC1768 platform. Please feel free to import the code and modify it for other platforms if needed. BITREADTIME define and STARTTRANSBITSIZE define would be the main items to change for any other platform to operate properly. A more general solution maybe to add another calculation that generates these defines based on some platform speed value. At this writing the code performs very well with little to no read failures. The issues that i have seen with other classes and this sensor is the fact that the sensor always produces the correct Temperature and Humidity output values on the io pin but the class reading these values miss many reading causing errors. This class avoids this because it reads the output from the DTH22 sensor completely and then processes the values from a run length bit measurement perspective that i feel is far more accurate. Anyways the results speak for them self.

Note i have tested this now with DHT11 sensor and it does produce the correct values! I will look into this and report once i get time! DHT22 sensor works fine and i have not tested with RHT03 sensor as i do not have one!


All wikipages