The issue is that occasionally I get an error. Here is the error stack with the last few 'working' lines of the terminal output while running. As you can see, the last value before the error and program crash is 25.4125, which is a humidity reading. The next reading was to be a pressure. The program quits on an error.
Code: Select all
21.4195
25.4808
1006.81
21.3937
25.4125
Traceback (most recent call last):
File "pibleuart_bme280.py", line 85, in <module>
get_and_send_pressure()
File "pibleuart_bme280.py", line 66, in get_and_send_pressure
aio.send_data(pressure_feed.key, str(pressure))
File "/usr/local/lib/python3.7/dist-packages/Adafruit_IO/client.py", line 154, in send_data
return self.create_data(feed, payload)
File "/usr/local/lib/python3.7/dist-packages/Adafruit_IO/client.py", line 254, in create_data
return Data.from_dict(self._post(path, data._asdict()))
File "/usr/local/lib/python3.7/dist-packages/Adafruit_IO/client.py", line 127, in _post
self._handle_error(response)
File "/usr/local/lib/python3.7/dist-packages/Adafruit_IO/client.py", line 108, in _handle_error
raise RequestError(response)
Adafruit_IO.errors.RequestError: Adafruit IO request failed: 422 Unprocessable Entity - request failed - Record invalid. Failed to save data to Rcayot/feeds/pressure, data missing required value
Code: Select all
# Handle all other errors (400 & 500 level HTTP responses)
elif response.status_code >= 400:
raise RequestError(response)
Code: Select all
Adafruit_IO.errors.RequestError: Adafruit IO request failed: 422 Unprocessable Entity - request failed - Record invalid. Failed to save data to Rcayot/feeds/pressure, data missing required value
The RPI Zero W does not 'print' the pressue value, (the print statement is before the 'send' command. So the error is in actually sending the data to AIO, not recieving the data from the nRF board via BLE.
Okay, now here is something else:
the error logged on AIO is as follows:
Code: Select all
MQTT ERROR: error saving data to Rcayot/feeds/pressure, data missing required value
Anyway, I want to be able to capture the error in an exception(?) and resend or re-connect to not drop out of the program. If anyone can help, it would be appreciated.
Also, and suggestions on troubleshooting the error so I can fix it would also be helpful. My internet connection is via satellite so, long latency times are not uncommon.
Roger Ayotte