After more than 5 years, I still get an occasional Email from Makers who ask questions about the Aosong AM2315 temperature/humidity sensor. I got one this week asking why my AM2315 python code did not work with Python3.
This nudged me to take a look at my code and figure out what it would take to get it to work with Python3. Next thing you know, I decided to remove the underlying dependency on any C code libraries and ensure my sample Python code works in both Python2.7 and Python3 without modifications.
To do this, I rely on two Python modules. The first is the great code written by our friends over at Adafruit. They have created a Rapsberry Pi GPIO code module written in pure Python. The second module is from the innovative folks over at SwitchDoc Labs.
I have updated the AM2315 Implementation Guide with the new changes. I also modified the SwitchDoc code so that it will work with Python3.
Now it is time for a rant. If you are a Python programmer, it is time for you to get serious about Python3 if you are still clinging to your Python2.7 worldview. All new code you write should be written in Python3. Python2.7 has an End Of Life date on January 1, 2020. There is a lot of 2.7 code out there that will work in Python3 with just a few changes. In fact, the only changes I made to get the SwitchDoc code to work was putting parenthesis around the print statements. EOR. (End of Rant)
You can download the updated implementation document with a code sample here. Thanks to Adafruit and SwitchDoc Labs for being a part of the Open Source community.