Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 6 months ago.
DTH21 interface with Nucleo L053R8
This is my first project on NucleoL053R8.
i have to take the temperature and humidity values from AM2301.
i tried using DTH22 code provided here. It is complied properly but giving me weird result on terminal
can you please explain me what can i really do
Question relating to:
1 Answer
10 years, 6 months ago.
Have you tried this library for that sensor? http://developer.mbed.org/teams/components/code/DHT/
Hello Raman! My only guess is the define ( #define BITREADTIME 3 ) in DTH22.h file needs to be changed. You will need to play around with the value on other platforms like the AM2301 that you are using. My code simply uses this define as a time constant value to wait and them read another bit from the dth22 sensor. At the time of making the library i could not come up with another reliable method to reading the devices other then a time constant measurement method. The method though has it's down sides that it is very platform dependent. The other library's i have seen and tested for the DTH sensors seem to use the DTH spec sheet timings but my scope shows that you can through those timing out the window. The sensor will always produce the 40 bits of data at a mostly constant rate so once you know that rate on your hardware setup my code will work every time! The error 2000 means the amount of transitions from low to hi on the dth22 data line are beyond what is expected of a good dataset. So if you play with that define value until that error does not happen you should be close to the final value! Hope this helps! PKS
posted by Philip Smith 11 Mar 2015