Hacking the PetPorte

As a cat owner of the geeky persuasion, I am a sucker for pet gadgetry. One such indulgence was the PetPorte Smart Cat Flap, which has a built in microchip reader to control feline access to your home, plus loads of built in features like timer and night modes to accommodate kitty’s curfew. It is more expensive than the alternative magnetic or infra-red fob cat flaps, but if you have escape-artist cats who lose their collars pretty much every time they leave the house, like I do, the cost difference soon balances out.

My experience with the product and company have been great, I do not hesitate to recommend it! Nevertheless I have one niggle – I just can’t get Night Mode to work satisfactorily. So rather than throw an otherwise excellent baby out with the bathwater, I hacked it instead.

The Problem

Night  Mode is for keeping your cat in at night. It uses a light dependent resistor (LDR) to detect the outside light level and decide if it is time to lock or unlock the flap in the outgoing direction. The problem in my case is the flap is fitted to the kitchen door, which being located on the side of the house is permanently in shade. Not only would the light level in the morning be sufficient to open the flap, but turning on the kitchen lights in the evening would unlock it! No amount of messing around with the light level seemed to fix the issue.

Enter the Arduino

Arduino RTC and transistor resistance switching circuitReplacing the LDR with a sub-circuit which at the appropriate times switches between two resistances, one for a day-time light level and the other for night-time, would fool the flap into operating correctly in Night Mode. This can be achieved quite simply with an arduino, Real Time Clock (RTC) module, a few resistors and a transistor, all of which I had to hand.

Using a multimeter I measured the resistance of the LDR in the light (250Ω) and in the dark (25KΩ). This gives an idea of the resistances required to fool the flap into thinking it is day- or night-time and hence open or lock the flap.

The simplest sub-circuit I could think of to switch between two resistances was the following:

Switching between two resistances

When the switch is open, the current has to flow through both R1 and R2 giving a total resistance of R1 + R2. When the switch is closed, the current flows through the switch branch rather than the R2 branch giving a total resistance of R1 (assuming the switch has zero or negligible resistance). The values or R1 and R2 were determined by whatever resistors I had at hand that were closest to the values I measured for the LDR.

A transistor is a type of switch which can be controlled using an output pin on an arduino. The arduino starter kit that I first bought came equipped with several P2N2222A transistors. Replacing the physical switch in the previous circuit with this gives the following:

Arduino controlled transistor switching between two resistances

When the arduino pin output is HIGH, the voltage at the base is sufficient that the transistor switch is ‘closed’ and current can flow between the collector and emitter, providing resistance R1 across the sub-circuit i.e. DAYTIME. When the arduino pin is LOW, the transistor switch is effectively ‘open’, providing resistance R1+R2 across the sub-circuit i.e. NIGHTTIME. R3 protects the transistor by limiting the current its base (this resistor came with the transistor in the arduino starter kit so I assume it’s the right value!).

Daylight Hours

It is possible to calculate the sunset and sunrise times for a given day and location, and fortunately this Sunrise/Sunset algorithm gives exact instructions on how to do this. The times repeat in a 4 yearly cycle, so I used these instructions to write a python script to calculate the sunrise and sunset times for every day in a 4 year period at my longitude and latitude, These are held in lookup arrays in the arduino memory.

The Sketch

Tying it all together, the arduino sketch gets the time and date from the RTC, looks up the sunrise and sunset times for that day, decides whether the cat flap should be locked or open and switches the transistor accordingly.

Next Steps

Current hacked PetPorte cat flap set upThe flap has been operating with this set up since January without any problems. However, there are a few improvements I would like to make:

  • Upgrade the RTC – the basic clock I am using is obviously losing time.
  • Share the cat flap power supply – the cat flap is already powered with a 12V DC supply. It would free up a socket and neaten things up if it were possible to power the arduino off that same supply.
  • Shrinkify the project – using an Arduino Uno to read a clock and switch one pin is a bit of overkill, so I have bought some ATTinys and it would be nice to shrink the project, especially if it would then all fit inside the cat flap housing.

19 thoughts on “Hacking the PetPorte”

  1. Hi,

    I had the same problem with the PetPorte light sensor not working properly, but my solution is slightly different: I just wired up a single (3mm blue) LED to sit right next to the light dependent resistor. It seems to work fine and didn’t require any soldering on the PetPorte PCB itself, so may be a better choice (for warranty reasons, etc) for some who find your page by searching like I did.

    Here’s to hoping they add a timer to the next version of PetPorte! :)


    1. Hi Juk,

      Thanks for your comment, good point about the warranty! Yours is a very neat solution.

      I’m hoping to see an open and hackable PetPorte next!


    2. Where is the light sensor located? Is it the transparent “led indicator” between the red and green button?

      1. Hi Mikael

        If you take the cover off, the LDR is the thing sticking out the bottom left hand corner of the circuit board. It isn’t near the LED indicator lights. I will try and add pictures!

    1. Hi Phil,

      Thanks for the link, I’ll check it out!

      Did you get your flap hooked up to your home automation system?


  2. Lovely project! Did you you ever investigate what drives the motor for the “entry” mechanism? The hack I’m thinking of requires operating that rather than as you’ve done the “exit” mechanism.

    1. Hi James,

      How’s your PetPorte project coming along, did you figure out the lock mechanisms?

      It’s been a while since I looked at the cat flap but from what I recall the locks are controlled by solenoids connected to springs. I imagine it would be slightly trickier to separate control of the solenoids from the PetPorte electronics whilst keeping the microchip reading circuits. Perhaps you’d have to use voltage changes on the solenoid controller pins as your input to your arduino sketch.

      I’d be really interested to hear what you’ve done :)


    1. Hi Martijn. The LDR is the thing sticking down from the bottom left corner of the PCB when you remove the cover. When the cover is on it is visible through the hole in the cover at the top left of the flap when viewed from the inside. Hope this helps, if not I’ll take some pictures.

  3. Hi, great post. I’ve been having the issue with my petporte that when I switch the kitchen light on it unlocks. I may work on something similar to this to solve my problem.

    1. Hi Mark,

      Did you solve your problem with your PetPorte unlocking?

      Another commenter had a great suggestion about hooking up an LED next to the LDR, and presumably covering up the external hole.


  4. Very nice! I will do this too, I have an spare Arduino. I am more mechanical than electronic and so I really appreciate that you posted this. It gives me the inspiration to try this too.
    If you do refine it, as you say you want to, then please post the results.

    1. Hi Peter,

      Did you give this a go?

      I did indeed mange to shrinkify my hack and it all fits (just!) inside the casing. I will have to write it up and let you know :)


  5. Hi.

    So my SmartFlap has started malfunctioning – about a second after turning on, it opens the green lock then every 5 minutes or so it locks for 1-2 seconds then repeats. Am handy with a soldering iron but don’t really know where to start diagnosing what’s wrong. Any of you clever types got any [highly appreciated] suggestions? Thanks. . .

    1. Sorry for the slow response, my blog has been poorly neglected recently.

      Did you get your problem sorted? If not I’ll do my best to help you out

  6. Did anyone reply to the question where on the unit is the LDR please? ORP12 LDRs have a habit of failing with exposure to low temperatures in my experience, so I’d like to replace mine. My flap won’t lock in the dark anymore. Thanks.

    1. If you take off the cover to look at the PCB, the LDR is the thing sticking out from the bottom left hand corner of the PCB. There’s a

    2. Did you get your flap fixed?

      In case you didn’t: when you take off the cover to look at the PCB, the LDR is the thing sticking out from the bottom left hand corner of the PCB. There’s a slot cut in the cover for the LDR so that light can reach it. If that isn’t clear let me know and I’ll add some photos.

Leave a Reply

Your email address will not be published. Required fields are marked *