NOTE: This content of this page is no longer relevant. Please go here for the latest AM2315 implementation “How-To.”
——————————————————————————————————————–
I was quite surprised by the number of comments and emails I received about the AM2315 humidity sensor. This confirms two things. First, it appears this sensor is quite popular. Based on my experimentation with the device, it is also quite accurate. Secondly, there are a lot of folks hacking this sensor but struggling with the am2315-python-api code.
It was really great of Joehrg Ehrsam to publish the code and make it available to all of us. Unfortunately, the code is poorly formatted and not commented. Also, the code has some timing issues that can result in bogus data. If you look at the below screenshot you can see the sensor is sending garbage.
The AM2315 datasheet warns about this:
“Send read/write command, the host must wait at least 1.5ms, and then send a read sequence, to read back the data…” (pg15).
Failure to get this timing right means you can get inaccurate data from the sensor. I have written Joehrg twice and did not receive a response. So, I decided to write a new Python class to read the sensor data accurately. You can download the code here:
Be sure to read the README.txt file and I suggest you run the test_aosong_am2315.py script to be sure the sensor is wired correctly.
Sopwith