← Projects
electronics intermediate 1 hr ago ◯ 4 min read

Build an ESP32 RFID Pet Door with Collar Tag Recognition and a Motorized Latch

Build time: 6-10 hours
Tools needed: Soldering iron, 3D printer (for collar tag holder and latch mount), drill, small screwdriver set, multimeter
Parts List
esp32rfidpet doorautomationservohome automationpn532

This site's RFID access control reader project covers a PN532-based badge reader for a door or workshop, and the escape-room prop project covers RFID-triggered relay locks for a sequence puzzle. A pet door is a different kind of access control problem: it needs to run unattended for months, tell your animals' tags apart from a neighbor's cat or any other EM4100 tag that wanders by, and fail in a safe default state if power drops. This project builds a motorized pet door flap that only unlatches for registered collar tags, with a standard reed switch confirming the door actually closed behind them.

Why 125kHz Instead of the PN532's 13.56MHz

Most pet RFID collar tags and the microchips implanted by vets are 125kHz (EM4100/EM4102 protocol), not the 13.56MHz NFC standard the PN532 modules this site usually covers are built for. A 125kHz reader module is a different, simpler piece of hardware — typically just a coil antenna and a decoder chip outputting a serial tag ID over UART or as raw Wiegand data. If you'd rather use tags you already own (or your pet already has a 125kHz-compatible implanted chip and a compatible scanner), this project uses the 125kHz path instead of the PN532; the overall logic is identical if you substitute 13.56MHz hardware and have ISO14443-compatible tags to issue instead.

Wiring the Reader and Latch

ComponentESP32 connectionNotes 125kHz RFID reader TXGPIO16 (RX2)Most modules output tag IDs as plain ASCII over UART at 9600 baud Reader VCC/GND5V / GNDCheck your specific module's voltage requirement — some need 5V for reliable read range even though the UART logic level is 3.3V-safe MOSFET driver inputGPIO18 (PWM-capable)Drives the linear actuator or latch motor; never drive a motor directly from a GPIO pin Reed switchGPIO19 (with internal pull-up enabled)Confirms the door physically closed after the latch cycle, rather than assuming it based on timing alone

Registering Tags and Storing Them Safely

Run the reader in a "learn mode" first — a simple serial monitor sketch that just prints every tag ID it sees — and scan each pet's tag to capture its unique ID. Store the list of authorized IDs in ESP32 NVS (non-volatile storage, the same flash-backed key-value store covered elsewhere on this site for WiFi credentials) rather than hardcoding them in the sketch, so adding or removing a pet later doesn't require reflashing. A simple allow-list check against the incoming scanned ID is all the access logic needs to be — this isn't a security application with an adversary trying to spoof tags, just a filter against false triggers from the occasional stray animal's own chip or tag.

Latch Mechanism and Fail-Safe Behavior

A small 12V linear actuator pulling a sliding bolt, or a servo rotating a cam that retracts a spring-loaded latch, both work — the important design decision is which state the latch defaults to when power is lost. Building this fail-locked (no power means the flap stays latched shut) protects against the door swinging open and letting other animals or weather in during a power outage, at the cost of your own pet being unable to get in or out until power's restored. Fail-unlocked is simpler to build (a spring holds the latch open by default, and the actuator only engages to lock it) but means a power outage effectively disables the door's entire access control. Most builds choose fail-locked and simply accept that a prolonged outage needs a manual override, which is worth adding as a simple exterior key-lock bypass regardless of which fail state you choose.

Handling False Reads and Debounce

A pet standing near the door, walking past without going through, or another animal's tag within read range (collar tags typically read from several centimeters, further than you might expect from a cheap module) can all trigger reads that don't correspond to an actual door-use intent. Debounce in software: require the same tag ID to be read twice within a short window before actuating the latch, and add a cooldown period after a successful unlatch before the reader accepts a new trigger, which prevents the motor from cycling repeatedly while a pet lingers near the sensor.

Weatherproofing

The reader coil and any exposed wiring at the door itself need to tolerate rain, temperature swings, and a certain amount of being chewed on or scratched at — route the reader antenna inside the door panel itself where possible (RF passes through most non-metallic pet door materials fine) rather than mounting it exposed, and keep the ESP32 and driver electronics in a sealed enclosure well away from the opening, with only the antenna and latch mechanism actually at the door.

This is a genuinely useful automation project precisely because it solves a real, recurring annoyance — letting your own animals through while keeping everything else out — without needing a commercial smart pet door's subscription app or cloud dependency. The access logic is simple by design; most of the engineering effort here goes into the physical latch and weatherproofing, which is also where most of the long-term reliability of the finished door actually comes from.