I've got a script running on my Raspberry Pi Pico W that works fine, until it doesn't. It has worked for a few days without a problem and now seems to just stop sometimes. It is hard to find out what goes wrong without logging. Is there a best practice to go about this? I'd like to (maybe?) just log all the exceptions or something. I'm running Micropython and using Thonny.
Context: I've made an automated door for my chicken coop. I've re-purposed and combined some scripts I found on the interwebs to make a clock that uses WiFi and NTP (every hour) to keep running on time. My script checks when it's time to open or close the door and then executes the open or close script that makes the 12V DC motor go. I even have limit switches checking if the door was completely opened/closed. I make the led blink every second, so I can see when it stops. It has been my very first project with Raspberry Pi, Micropython and electronics in general, so I'm actually quite surprised I got this far without messing up, so please go easy on me. I've already to content with four chicks that have sub-par service here :P
Really appreciate the help!