Optical door lock sensor

For some time, I have been looking for a sensor to mount in my old-fashioned door locks (I do not use smart locks yet - still worried about the security), but I have not been able to find anything.

I have looked at what other people in the same situation have come up with and they all seem to use some sort of mechanical switch. I went for another solution that has no moving parts.

Using a relatively cheap reflective object sensor (containing a LED and a phototransistor) I made a small PCB that measures the distance to the lockbolt and sets the output depending on the distance (above or below a set level).

The sensor is mounted on the back of the locking plate where I made a rectangular hole for the sensor and two M3 threaded holes for mounting the sensor with nylon screws.

The output from the sensor is wired to an Aeotec Door/Window sensor 7 Pro for inclusion in my z-wave network. The Aeotec sensor get its 3V power supply from the lock sensor.

The output is an open collector with optional pull up resistor (to 3V).

The sensor will make a measurement every 3 seconds by turning on the LED, measure the distance and then turning off the LED again. Depending on the distance the sensor will set the output high or low.

When the Aeotec sensor detects a change in its input it will send a message on the z-wave network indicating the new status of the lock.

Works quite well. Only problem I have seen is that bright sunlight when the door is open might cause the sensor to detect the door as locked. No big issue as the door is open, so it cannot be locked at the same time.

2 Likes

I appreciate you sharing your project and your exploration of another means of detecting a lock’s state. However, there are good reasons why mechanical switches have been used, for many decades, for contact detection.

Contact sensors designed for security systems are rated for tens of thousands of operating cycles. I installed micro-switches, with tiny levers, to serve as lock sensors for two doors over ten years ago and they continue to work properly.

I also used a traditional magnetic reed switch to monitor the latch on an exterior gate. It required embedding a small magnet into the metal latch. That has also worked reliably for years and survived many cold winters.

These devices are inexpensive, robust, compact, and reliable (and their operation is unaffected by sunlight). They’re merely switches so, obviously, they contain no electronics and consume no power. In terms of aesthetics, the switches are located within the door jamb and completely hidden from view.

In my case, each lock-detecting switch is hard-wired (it’s my preference to have hard-wired security sensors wherever possible). However, I imagine it would be possible to use a wireless (Zigbee) contact sensor modified to support an external contact switch.