|
Post by SDL on Jan 10, 2019 19:49:58 GMT -8
Folks, I have updated the GroveWeatherPi code to Version 2.13 and uploaded the new version to the GitHub.com/switchdoclabs repository. This is addressing the issue brought up by Peter about the am2315 going to "None" after a while and the IO not being protected by an try:, except: block. From the README.md Version 3.13
www.switchdoc.com/
January 10, 2018 - Version 3.13 Added "None" detection to AM2315, added Try, Except loop on AM2315 read
December 19, 2018 - Version 3.12 Improved Blynk reliabilityI (and John) am a little nervous about this fix because we are addressing a symptom and not the root cause of the am2315 python error (object going to None). We will continue to investigate. Best regards, BP try: ToutsideHumidity, ToutsideTemperature, crc_check = am2315.read_humidity_temperature_crc() except: if am2315 is None: am2315 = AM2315.AM2315() print ("am2315 None Error Detected") crc_check = -1
|
|
|
Post by triggerfish on Jan 11, 2019 3:18:56 GMT -8
Why did you not put the exception trap in the AM2315 module for the actual read? That is where things have gone bad before. When I fixed that, I had a quite stable system...
# TELL THE DEVICE WE WANT 4 BYTES OF DATA self._device.writeList(AM2315_READREG,[0x00, 0x04]) time.sleep(0.09) tmp = self._device.readList(AM2315_READREG,8) self.temperature = (((tmp[4] & 0x7F) << 8) | tmp[5]) / 10.0 # check for > 10.0 degrees higher if (self.AM2315PreviousTemp != -1000): # ignore first time if (abs(self.AM2315PreviousTemp - self.temperature) > 10.0): # OK, temp is bad. Ignore if (AM2315DEBUG == True):
Now I just know for sure bad readings will occurr which result in "none" values... Why not put the suggested code in:
try: self._device.writeList(AM2315_READREG,[0x00, 0x04]) time.sleep(0.09) tmp = self._device.readList(AM2315_READREG,8) self.temperature = (((tmp[4] & 0x7F) << 8) | tmp[5]) / 10.0 except: time.sleep(0.09) # check for > 10.0 degrees higher and so on... And this 10 degrees temp check will still produce a wrong graph for me if the sensor gives back a faulty 0, when ambient temperature is between -10 and +10, which is relative common where I live
|
|
|
Post by triggerfish on Jan 11, 2019 3:46:00 GMT -8
And... this does not work at al At reboot, nothing happened, so I started fomr the command line: File "/home/pi/SDL_Pi_GroveWeatherPi/GroveWeatherPi.py", line 1709, in <module> sampleAndDisplay() File "/home/pi/SDL_Pi_GroveWeatherPi/GroveWeatherPi.py", line 1268, in sampleAndDisplay sampleWeather() File "/home/pi/SDL_Pi_GroveWeatherPi/GroveWeatherPi.py", line 1108, in sampleWeather if am2315 is None: UnboundLocalError: local variable 'am2315' referenced before assignment
|
|
|
Post by triggerfish on Jan 11, 2019 3:49:24 GMT -8
I'm back to 3.12
|
|
|
Post by SDL on Jan 13, 2019 9:32:13 GMT -8
Good grief! I screwed up in testing. 3.13 fails for me to now. I was testing 3.12 by mistake.
I'll get this fixed up and put up on the site. I read your other comments and I see what you are saying.
BP
|
|
|
Post by SDL on Jan 13, 2019 11:17:46 GMT -8
I've fixed the assignment error. I don't totally understand why I had to do the am2315 global in this manner, but I see why it was failing. My question was why did it work in 3.11.
However, I've got 3.14 up there for your perusal.
And now I have to go fix the Dryer. Sunday at home you know.
BP
|
|