There is one apartment door where the doorbell magically rings whenever the cat sits in front of it. Know the science behind it.
Just as most cats do, Leonie loves to explore her surroundings, and after satisfying her curiosity, she likes to return home, where it's warm and dry and there's food. Usually somebody will open the outside door for her, but entering her apartment is more difficult. There is one apartment door, however, where the doorbell magically rings whenever Leonie sits in front of it. This door is mine, so I can explain how the "magic" works.
Using the TSSP4P38 proximity sensor, I built a small device that activates the electric circuit to ring the doorbell when it senses anything staying in front of the door. Typical alarm systems would use a passive infrared (PIR) sensor, but for Leonie these devices have two disadvantages. For one, in order to avoid false alarms, they are designed to ignore pets. Secondly, they only respond to moving objects, and can't sense a cat sitting still in front of the door. At best, they would ring the doorbell when the cat starts moving again; that is, when she leaves. With the TSSP4P38, my sensing device detects when Leonie arrives, waits a few seconds to see if she stays, and if she does it rings the bell.
Here is an infrared mid-range proximity sensor.
For this purpose, I placed the sensor on one side of the door frame and connected it to a microcontroller that has additional connections to a driver circuit for a VSLB3940 infrared emitter, and to an IRLD024 MOSFET that controls the doorbell. All of these are Vishay parts, with the emitter and sensor mounted in a TSSP-HA for optical isolation. The microcontroller is a Microchip PIC10F200, the very smallest member of its family. This chip can memorise 256 program instructions, which is sufficient to handle the sensor and to implement an alternate mode of operation in which the program sends the values of some significant variables to the serial interface of a PC for debugging, instead of ringing the bell.
This cat sensor rings the doorbell when something waits in front of it.
A significant portion of the component count goes into the driver circuit for the emitter LED, which is a constant current source. Jumpers determine the current and thus match the sensing range to the environment. If the current is too small, the cat may not be detected when she is sitting at the opposite side of the door; if it is too high, the sensor might "see" too much of the other side of the door frame and ring the bell when it shouldn't.
Here is the circuit design for the cat doorbell prototype.
Power consumption is so small that the supply current may be harvested from the doorbell transformer by using the voltage across the open switch, leading to a simple two-wire connection. To ring the doorbell, the device shorts its supply, and an electrolytic capacitor keeps the controller alive until it turns the bell off again.
The software in the microcontroller uses a timed loop to generate the 38kHz carrier for feeding the VSLB3940 emitter and measure the duration of the TSSP4P38's output pulse. The program then computes a moving average of the most recent readings and uses it to fine-tune a threshold that classifies the next reading as either close or far. Close readings are counted, and after a predefined number of consecutive close readings, the MOSFET is switched on to ring the bell.
For details on how to operate the sensor, I found the application note "Vishay's TSSP-AGC P Sensor Series for Proximity Sensing" by John Fisher and Anika Kühnle to be very helpful.
The good news for Leonie is that she does not need to know how all this works. She is just happy whenever I open the door for her. But if she knew that the TSSP4P38 creates the magic, I am sure she would purr her approval and appreciation.