DIY Smart Chicken Coop Door Controller: Success and Challenges

I recently embarked on a fun DIY project to create a smart chicken coop door controller for my parents. The goal was to automate the door opening and closing based on sunrise and sunset times, ensuring the chickens have access to the coop when needed. I wanted the system to be as self-sufficient as possible, anticipating potential Wi-Fi issues, so I decided to handle the automations locally using ESPHome instead of relying on Home Assistant (HA) for everything. This way, even if the connection to HA or Wi-Fi was lost, the door would still operate as programmed.The setup involved a Raspberry Pi Pico W, a rotary encoder for manual control, and a motorized system to open and close the door. I integrated a screen to display real-time information such as the current time, Wi-Fi signal strength, and temperature inside the coop. The door is controlled using a limit switch to ensure it doesn’t overextend, and the motor is powered through GPIO pins on the Raspberry Pi.Initially, everything seemed to work perfectly during testing. The door opened and closed smoothly, and the screen displayed all the necessary information. However, when I installed the system at the coop location, I encountered some unexpected behavior. The screen would flicker on and off, and the buttons wouldn’t respond consistently. After some time, it started working again, but only when it connected to a very weak Wi-Fi signal (~-80dB). It stayed connected for a few days but then dropped offline, causing the door to stop working as intended.I suspect the issue might be related to the device being at the limit of the Wi-Fi range. The frequent connect-disconnect cycles might be disrupting the normal program cycle, leading to the erratic behavior. I’m curious if others have experienced similar issues with devices operating at the edge of their Wi-Fi range and how they resolved them.To mitigate this, I added some API and Wi-Fi timeout settings to handle disconnections more gracefully. The system now attempts to reconnect periodically, which has improved reliability. However, I’m still looking for ways to make the connection more stable without having to physically move the device closer to the router.Overall, I’m happy with how the project turned out. It’s been a great learning experience, and the chickens seem to appreciate the automated door! If anyone has tips on improving the Wi-Fi stability for devices operating at the edge of their range, I’d love to hear them. Here’s the ESPHome YAML configuration I used, focusing on the relevant sections that address the issue.