Coop Door Progress

Firstly, R.I.P. to Biggie Smols aka The Notorious Ruth Bantam Ginsburg, the last surviving member of our “Bad Hen Records” crew consisting of Vanilla Ice, Suge White, and Puffy Combs. She was an adorable birb with a fantastic singing voice who absolutely loved hatching babies and is sorely missed.

Progress on automating the coop door has been a slog. My main problem is that I keep crashing CircuitPython. It seems to be related to asyncio and frequent i2c activity, but troubleshooting with the developers has been painful because it takes days to happen, CP has no native debugging capabilities, and they do not provide debugging builds.

Probably I need to throw in the towel on CircuitPython and switch to MicroPython or C.

I’ve also been experimenting with using Time-of-Flight sensors to track the door’s precise position.

The upside to that method, aside from the obvious, would be that it can be completely concealed by the frame and should be reasonably protected from water and dust.

I’ve gone through a bunch of sensors trying to avoid the VL53L4CD / VL53L4CX because they’re pricey @ +/- $4 for bare chips or $15 + S&H for a full board from Adafruit, but so far none of the lesser chips I can get on a board for $1-$3 on AliExpress have been suitable for the required minimum and maximum distance measurements. So I guess that is what it is.

I’ve also been researching how to do light control. The PCBs I had made have a provision for controlling 5v WS2812b LED strips but it wasn’t well thought out and I don’t believe it will deliver enough power. I need a MOSFET in there, power regulators, I want to support the Omlet accessory light, and being able to run PWM LED strips at 12v or 24v seems better than 5v WS2812b.

I also picked up some UART-based LoRa modules that I want to support. I have sufficient Wi-Fi coverage outdoors but I figure that could be a challenge for many people, and a differentiator from Omlet’s new Wi-Fi controller.

The final change I want to make is switching to an ESP board with more GPIOs and breaking out the excess ones so that someone could add hardware capabilities I haven’t considered yet.

Sometime next week I’ll be validating that the i2c bus / ToF sensor functions with 2-meters worth of cable, and then I’ll start designing a new revision of the PCB that incorporates all of that.

My First PCB

Over the weekend I attended an introduction to PCB building class at Freeside Atlanta. They are an exceptionally friendly and welcoming group with an awesome space full of all the goodies I could ever hope to have access to for electronics, metal, wood working, and even blacksmithing, but sadly I live much too far away and would use the space too little to justify the membership costs. 11/10, would recommend them to anyone living near the airport.

With a few more hours work the next day, I’ve constructed and ordered my first prototype PCB for the coop controller:

The v3 prototype is probably not going to make it to the coop because it really needs longer screws and spacers to fit comfortably in the outdoor enclosure, and that just feels wasteful to track down and buy for what was intended to be an extremely temporary solution, so hopefully when this PCB gets here it actually works 🤣

I also ordered Omlet’s new smart controller. For science.

It appears to be trivial to replace the firmware but trying to hack on that isn’t high on my priority list right now. I am curious if it has a real-time clock module — the “RTC” built-in to the ESP32-S3 is a clock that ticks, not a clock that follows and preserves Earth time after power loss like found in a typical computer — but the markings on all the ICs are obscured by a coating.

Progress on the Chicken Door

This is v3:

First with v2 I switched to an ESP32-S3 board, because the Wi-Fi on the Raspberry Pi Pico W… sucks. For several days I battle-tested the Pico W against an ESP32-C3 with the classic PCB trace antenna, an Arduino Nano ESP32-S3 with a fancy resonant cavity antenna (like the Pico’s), and two other ESP32-S3 boards with ceramic antennas in the location I need this to go, and while I’m not sure there’s a clear winner, the Pico W was the worst.

Then I worked on adding physical controls and a DS3231 RTC module. Cleaning up my garbage “Make it do something” code and migrating to asyncio coroutines. Learning things like: Sometimes the motor doesn’t start and doesn’t draw significant current, so monitoring that the current has risen above a certain threshold is a thing I needed to do.

This v3 is prepping a more suitable version to go outside. It’s nearly ready…

Just in time for Omlet to have released their own Wi-Fi controller 😂🤣😭

Tho it doesn’t sound like it does the things I want my controller to do.

It Takes a Tough Man to Make a Tender Chicken

The Pandemic of 2020 turned my family into chicken tenders. We presently have about two dozen chickens, down from a peak in the low 40s.

Many pets are troublesome when you want to be away from the home for more than the day. Chickens, especially so — I’ve been shocked at how many people I know who are scared of chickens. Our main chicken coop is a place for them to sleep that’s reasonably secure from predators, not a living space complete with food and water, so it is challenging to leave them mostly unsupervised for days when their care instructions are “Open the coop as close to sunrise as you can, come back to close them up very soon after sunset, and we’re pretty sure the rooster is harmless but watch him and don’t worry that we’ll be mad if you have to beat him to death.”

Thankfully, technology exists to help with this.

There are many automatic chicken coop doors. The one I chose is from a company called Omlet, as theirs is the only one I believe reasonably trustworthy to not maim a chicken — it has a kill switch along the entire side of the door frame and can otherwise detect that the door is obstructed, presumably by monitoring the motor current. Many other doors just use a beam sensor.

Universally, the controllers on automatic chicken coop door allow operation by time or light level. This is… Not Great. The light control on the Omlet doesn’t really work on my chickens’ schedule. Going by time sucks because I need to regularly adjust the schedule based on the length of daylight.

And in general these controllers suck because they’re not Wi-Fi or Zigbee or Z-Wave so I can’t control them remotely or verify their state. The Omlet will eventually give up and display an error if it can’t open or close. Some others aren’t even smart enough to detect that they’ve failed at their task.

Since I bought the Omlet a couple years back, I’ve found three newer doors that sport Wi-Fi and have cloud dependencies. One charges for their cloud, one does not (so far), and neither of them has public information about whether they can integrate with any home automation platforms. The 3rd is Tuya-based, which is probably a plus as far as owning cloud-dependent devices from random small companies goes, but this is a product class where I want official local control and no Cloud.

Since I can’t buy what I want, and I’d dismissed the idea of going full DIY back when I originally bought the Omlet, my plan has been to make the Omlet door smarter. Others have gone before me, usually by taking an ESP-based relay board and connecting the relays to the button leads on the controller board. I found one person who replaced the controller entirely but is naively operating it via relays with a timer for how long the motor should run. In either scenario, they’re using their home automation platform to control it.

I decided on a more comprehensive approach. I want to completely replace the Omlet controller, without losing anything that it does in operating the door — the crush switch needs to work, and the motor’s current needs to be monitored. I want my controller to integrate with my home automation platform but be operationally autonomous, so it needs a real-time clock module with backup power — you’ll find “RTC” in the datasheets for all those boards with common Wi-Fi microcontrollers, but that is just a clock that will reset when power is lost. And I want to do something to sense that the door is fully opened or closed — possibly add a pair of reed switches or a distance sensor. I don’t need a light sensor as sunrise/sunset can be calculated based on the time and latitude/longitude.

I’ve named my project Frittata. As of today, I have a proof-of-concept prototype using a Pico W running CircuitPython with an INA219 current sensor and DRV8833 motor driver. That leaves plenty more to do, and I’ll probably throw all the prototyping work away in favor of using an ESP32-based board and ESPHome or the Arduino framework, but despite this being the most complicated thing I’ve done with a microcontroller by a wide margin it is hardly rocket surgery. I think another 10-20 hours work gets me to something I’m comfortable unleashing upon my flock.