TazwellJ / Pico_GardenWaterer_v2

Contains code for an automated garden watering system using a Raspberry Pi Pico and Chirp moisture sensors
0 stars 0 forks source link

Add logging to determine why data stops uploading to ThingSpeak #3

Closed TazwellJ closed 1 year ago

TazwellJ commented 1 year ago

At random times, the data stops uploading. Need to determine if it's a network connection issue or a code crash. Log everything to a file I can pull

TazwellJ commented 1 year ago

After enabling logging of all console output I found out what was causing the error. It was an OS error caused by the call to urequests. Since the upload to ThingSpeak isn't actually a critical part of the function of the project I simply added a try-except function around the upload code. Now, rather than crashing the whole program, the code simply skips the failed upload and resumes. In testing, the next upload went fine so it successfully recovered after a failed upload.