switchdoclabs / SDL_Pi_AM2315

Pure Python software for the SwitchDoc Labs AM2315 / Python 3
MIT License
5 stars 7 forks source link

breaks at line 88? #1

Open taisau opened 5 years ago

taisau commented 5 years ago

I am not very familiar with python. I get the error below and the best I can figure is that tmp is none, but I don't know how to fix that.

File "AM2315.py", line 88, in _read_data self.humidity = ((tmp[2] << 8) | tmp[3]) / 10.0 TypeError: 'NoneType' object has no attribute '__getitem__'

deweydb commented 5 years ago

The author does not handle exceptions in the proper pythonic way, they have done a catch all for any type of exception, and so that loop just runs the 10 times and fails each time. I had this problem too, the solution for me was correcting my wiring, i had not wired the sensor too the correct SDA and SDC pins. Double check your wiring.