Cat Superpower: Opening Doors

Does your cat have superpowers? Ours can open a door just by looking at it (well walking close to it in reality, but he always looks where he’s going).

If not then here’s a massively over-engineered project to allow a cat to open a regular door!

Why is this necessary?

Ollie (our beloved moggy) is free to roam using an electronic cat flap. But unfortunately for Ollie the cat flap only gets him into the conservatory. And the conservatory is a useless glass box with bad insulation that was stuck to the side of our house when we bought it. When the weather is mild we leave the door to the conservatory open and Ollie is a happy cat – but most of the time it is cold outside (because we live in Scotland!) and we have to close the kitchen door – which consigns Ollie to the icy glass box!

Over-engineering to the rescue

Never let it be said that I miss an opportunity to overengineer a solution to a simple problem! What I have come up with involves five separate boxes of electronics to provide:

  • a mechanism to open and close the door
  • in and out PIR detection of the cat’s presence on one side of the door or the other
  • a button for humans to get in from the conservatory when the door is shut
  • a control panel to set whether in and/or out directions are valid

Mechanism to open/close the door

I’m now on the third iteration of this mechanism.

  • The first attempt was a gate-opener (you’ll find lots if you google it) but the problem was that it was too powerful and would have hurt Ollie if he’d tried to dart through at the last moment (which he does all the time with normal doors!) and gotten stuck.
  • The second attempt was in a PLA 3D printed box which was part of the mechanical design of the opener – and it kinda melted in the heat of the summer sun (due to Climate Change it seems Scotland can have hotish days now too!). In this version I attempted to measure the motor current as an indication of someone (or some cat) being in the way of motion (or pushing the door) – but I couldn’t get this to work well enough – probably because of the high gearing of the mechanism.
  • The third attempt (which has a magnetic rotation sensor for door position and a strain gauge built into the arm for interference detection) has been running for a year or so now without issues so that’s the one I’m going to talk about.

The chosen approach (third time lucky)

The current version is much calmer, much safer, and hasn’t melted yet.

At the heart of the system is a geared stepper motor which opens and closes the door via a simple lever mechanism that pushes and pulls on the door. An advantage of this mechanism is that it can move freely when the motor is not powered, so simply disabling the motor ensures that Ollie can’t get his head trapped. This is in contrast to gate-openers which generally use a lead-screw and cannot (easily) be driven from the actuator end.

The stepper is driven by a controller board of my own design using a Trinamic TMC2209 motor driver. These drivers are excellent—quiet, efficient, and very well behaved—and they allow current limits tio be accurately set so the door is powerful enough to move… but can’t injure either cats or humans. The controller runs ScaderESP32 firmware, built on top of my RaftCore framework, all running on an ESP32-S3.

If that all sounds like overkill for opening a door: you are surely correct.

Knowing where the door is (and when to stop)

One of the big improvements in this version is both position and force feedback.

Rather than relying on counting stepper pulses and hoping nothing slips, the system uses an AS5600 magnetic rotation sensor to directly measure the shaft position that drives the door lever. This gives absolute position feedback, so the system always knows exactly where the door is—fully shut, fully open, or somewhere in between—even after a power cycle.

The lever mechanism includes a strain gauge, measured using an HX711 amplifier. This lets the controller monitor how much force is being applied to the door. If the door hits an obstruction, a human decides to “help”, or Ollie does his classic last-millisecond dash, the force spikes and the motor immediately shuts down.

The human interface (our attempts to get Ollie to read have not yet borne fruit)

There are several ways to interact with the system.

The first way is simply to pull or push the door. This activity is detected by the strain gauge, the motor disabled, and the door can be opened or closed easily.

The second is a physical button in the conservatory so humans can get in when the door is closed – since the first option is so straightforward I don’t think the button ever gets used.

The third is a small UI panel built using an M5Stack Core ESP32 with display, mounted on a custom PCB and connected to the main controller over a simple serial link. This shows the current door position and allows us to enable or disable “in” and “out” directions independently – useful if you want the cat to be able to go out but not come back into the kitchen if he’s been naughty and brought in a mouse.

The final option is a Web UI which is available over a WiFi connection. This is used for configuration – setting the max power for the motor, setting the initial open and closed positions, etc. It can also be used to monitor the door remotely and open/close it.

PIR sensors and cat detection

Detecting Ollie’s intent is handled using PIR sensors, one on each side of the door. These aren’t fancy, but they’re cheap, reliable, and mainly good enough for detecting “cat-shaped movement approaching a door”.

I used standard HC-SR501-based PIR modules (with dome removed) that can be bought on AliExpress or Amazon and mounted with a baffle so they detect motion near the door rather than just general activity in the room. This dramatically reduces false triggers caused by humans moving about or the cat stretching elaborately three metres away. It does require a bit of tuning in though using the sensitivity controls on the PIRs. I also found that applying a coat of ModPodge to the PIR sensor reduced its sensitivity quite a lot.

The reason I only say mainly good enough is that direct sunlight falling on the PIRs tends to trigger them. The baffles can help with this but I still find there are false triggers which cause the door to open and close for apparent ghost cats. I am yet to try other detection methods but maybe some of the human presense radar modules that are commonly available now could work for cats?

Other unnecessary features

As mentioned above, in addition to the physical UI, there’s a full Web UI for configuration and control, because once you add Wi-Fi you might as well lean into it. The system supports MQTT, websockets, and even BLE, with BLE integration handled via raftjs.

None of this is strictly required to open a door of course!

Mechanical and physical design

The enclosure is built from laser-cut acrylic sheets, which has proven to be far more heat-resistant than the ill-fated PLA enclosure from version two. The mechanical parts—gears, brackets, and the lever mechanism—are 3D printed in PETG, which copes much better with temperature changes and mechanical stress.

All mechanical design was done in Fusion 360, and I’ve made all the Fusion source files, STL mesh files, and DXF files available in the GitHub repository. The PCB design files are in there too, complete with poor decisions preserved for posterity.

The end result

The system has now been running continuously for over a year without incident. The door opens smoothly, closes gently, stops politely when interfered with, and – most importantly – Ollie has learned how to use it despite being a pretty dim (but lovable) moggy. Of course the incentive for Ollie to learn is pretty strong since he’d otherwise be marooned in the arctic wasteland of the conservatory.

Is five boxes of electronics an excessive solution to a door problem?

Absolutely.

Would I build it again?

Also absolutely.

After all, this isn’t really about opening a door.

It’s about ensuring that a cat gets exactly what it wants, exactly when it wants it—using stepper motors, strain gauges, custom firmware, and a frankly unjustifiable amount of engineering.

Design Files

GitHub repo containing the CAD and PCB design files

GitHub repo containing the ScaderESP32 firmware

GitHub repos containing the RaftCore and RaftCLI