Hello to all my smoke-eating Maker friends. O’l Sopwith has a story to tell. In my February 1st post, I posted the pure Python source code and updated the implementation documentation for the ever-so-popular AM2315 temperature sensor.
I did this after receiving an Email from a fellow Maker who wanted to know why my sample AM2315 code did not work with Python3. The day after I published that blog entry, a comment was posted stating they could not get their sensor working. The AM2315 was visible in the i2cdetect test, but it would not return any data. The Python code crashed and burned.
About a week of communicating back-and-forth to troubleshoot the problem, this is what we did:
- Turned on Debug mode in the python script
- Made sure the device was wired correctly
- Made sure the correct software was installed
- Disconnected all other devices from the Pi
- Ran the SwitchDoc Labs test script (same stack trace)
- Ensured the Pi had a 2.0 amp power supply
About the same time this was going on, the mate who asked about the Python3 port downloaded and tested the new code. He could not get it to work either. Thinking he had a bad sensor, he set up a test harness and tested his sensor on an Arduino. It worked fine. After some fiddling around, he determined the MAXREADATTEMPT = 3 on line 23 was too small a value. He changed it to 10, and his sensor worked fine.
Continue reading