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

This DHT22 sensor reading class works with the mbed LPC1768. The code is time dependent but has been tested 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. BITREADTIME is the us time value used in a basic look for a wait value to get next reading. This may work simply on other platforms at other system speeds but it may not. 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(in fact i have not seen a read failure yet in testing). 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.

I have now added a member function for reading the DTH11 sensor as it is read the same way as the DTH22 sensor. The only difference is the final use of the retrieved bytes from the sensor for calculating the temperature and humidity. Note the DTH11 sensor has less range and less accuracy but it also can be found for less money!

History

Changed the class to now have the testing member function be public. Added the getDTH11TH member function for reading the DTH11 sensor. default tip

2013-12-08, by harrypowers [Sun, 08 Dec 2013 21:52:47 +0000] rev 10

Changed the class to now have the testing member function be public. Added the getDTH11TH member function for reading the DTH11 sensor.


changed the temperature sign calculation to use unary minus rather then a multiply with -1

2013-12-04, by harrypowers [Wed, 04 Dec 2013 03:17:51 +0000] rev 9

changed the temperature sign calculation to use unary minus rather then a multiply with -1


update to docs for pin connection

2013-12-04, by harrypowers [Wed, 04 Dec 2013 01:29:47 +0000] rev 8

update to docs for pin connection


final change to comments to get the auto documenting working... note to self put the #defines before example!

2013-12-03, by harrypowers [Tue, 03 Dec 2013 10:07:30 +0000] rev 7

final change to comments to get the auto documenting working... note to self put the #defines before example!


just formatting updates and small comment changes

2013-12-03, by harrypowers [Tue, 03 Dec 2013 09:58:19 +0000] rev 6

just formatting updates and small comment changes


small change to comments in DTH22.h

2013-12-03, by harrypowers [Tue, 03 Dec 2013 09:47:53 +0000] rev 5

small change to comments in DTH22.h


Basic documentation done for most users. Not sure what else i will do in this area!

2013-12-03, by harrypowers [Tue, 03 Dec 2013 09:42:35 +0000] rev 4

Basic documentation done for most users. Not sure what else i will do in this area!


first commit fully working and tested in mostly final form. all that is needed now is more documenting for auto library creation and completeness for readers.

2013-12-03, by harrypowers [Tue, 03 Dec 2013 09:14:49 +0000] rev 3

first commit fully working and tested in mostly final form. all that is needed now is more documenting for auto library creation and completeness for readers.


fully working class with test word available as public member.

2013-12-03, by harrypowers [Tue, 03 Dec 2013 09:09:07 +0000] rev 2

fully working class with test word available as public member.


got plans for how to get the final data but for now this produces the timing data to allow extraction of the 40 bits of data!

2013-12-02, by harrypowers [Mon, 02 Dec 2013 08:48:29 +0000] rev 1

got plans for how to get the final data but for now this produces the timing data to allow extraction of the 40 bits of data!