0

[question] Best way to detect if a door is locked?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

[question] Best way to detect if a door is locked?

by markg85 on Fri Sep 13, 2019 6:24 pm

Hi,

First of all, i'm not at all sure if this is the right sub forum. There is so much that could fit. Please move this topic to the right subforum if this one turns out to be inappropriate.

I'm trying to think of a system that can reliable tell me if my door is locked.
Note the word "locked"! I don't mean the simple magnetic door sensors that basically tell you if a door is open or closed. I specifically want to know if the door is locked.
I want to add this knowledge to my house to be able to get a notification that i forgot to lock the door when i'm away from home and didn't lock it.

For this to make sense, you might need a little more information about the type of door lock i have.
The door in question is an apartment door, the lock looks like this (just to get the idea):
Image

So there is a hinge part and a solid steel lock part which is controlled by a cylinder lock.

I do know of the wealth of "smart door lock" tech out there, but i have 2 kinda big problems with them.
1. Despite the name, they only tell you that the lock mechanism is extended. If the door is open and extended it counts as "locked" to them, which it obviously isn't. Some then add in a magnetic sensor too to detect if it's open, but that kinda ruins the looks with ugly sensors.
2. Surprisingly few systems work on a cylinder lock and those that are working for them are either stupidly expensive or really ugly or both.
3. I don't want to automate my locking mechanism (yet), i merely want to know if it's locked.

For the above reasons they just are not an option for me.

Now i want to know when the cylinder controlled part is fully extended in the door side. Thus the door being locked.
And which kind of sensors i might want to use for this.
The only requirement i have is that nothing on the door itself can change. No electronics or extra holes there. The door frame is where the tech would need to be placed in. The room i have is about the size of 3 arduino trinkets stacked on top. I can make the gap bigger, but i really do not want to do that. The room i have allows me to use a trinket or an ESP8266. The power for it is not a problem as there is one tiny very convenient hole right in the frame leading to another room from where i can power it.

I already have some ideas for this on which i'd really like your input on to see if this would work. Or more ideas that i haven't even thought of. Everything is welcome :)
The ideas i have thus far:
  • In the door frame, right underneath the place the iron lock slides in. There i would put a Time Of Flight (TOF) sensor pointing up. If the door is open the max distance would be read (the height of the hole for the lock part and for the hinge part). If the door would be closed, but not locked, the height would be slightly less. If the door would be locked the height would be close to 0. This was my initial first idea. It would work if the place where the lock and hings fall in would be one hollow section in the frame. It turns out that isn't the case. It's hollow only for that specific piece of iron to fit it. This can still work but then would only detect locking. If it were one hollow area it would also be usable to detect a closed door (not locked). I can hollow out the frame there to make this work, but i prefer not to do this. Also, the TOF sensor while small is still quite large to fit in that hole. I'd have to resort to desoldering it or making a custom smaller pcb. Both are steps i really don't want to do. Yet.

  • Using a hall effect sensor where the locking iron itself might already be magnetic enough to trigger it (doubtful though). If not, then i need to sticky glue a strong tiny magnet on it. That is still feasible. Within the door frame i would then put the hall effect sensor. This basically is the simple door switch sensor just in a much smaller form and completely out of sight. This could work, but i'm not sure how strong the magnet would have to be. If that's more then - say - 3mm thick then it might not fit in the frame hole anymore. Or i would need to hollow out the frame deeper. This is possible, but not a route i prefer either.

Those are the options i can think of now that could work..
Are there any other sensor combinations that will give me the same result but with less hassle?

I'm looking forward to all of your ingenious ways to tackle the same issue :)

Cheers,
Mark

markg85
 
Posts: 8
Joined: Fri Sep 13, 2019 4:50 pm

Re: [question] Best way to detect if a door is locked?

by dThirteen on Fri Sep 13, 2019 10:13 pm

My experience with reed switches is the magnet doesn't have to be very strong. I am in Australia and I have used this part https://www.jaycar.com.au/miniature-glass-reed-switch/p/SM1002. You could probably pot something like this in epoxy to give it some resilience.

A simple microswitch that is operated by the tongue of the locking bolt is probably the simplest solution. For example https://www.jaycar.com.au/spdt-125v-3a-sub-miniature-micro-switch-with-lever/p/SM1036

dThirteen
 
Posts: 9
Joined: Tue Aug 27, 2019 6:20 pm

Re: [question] Best way to detect if a door is locked?

by zener on Sat Sep 14, 2019 12:07 am

There are probably several ways you could detect the lock bolt. Here is something similar to your first idea, just simpler and less expensive. You possibly could use it either to detect the bolt itself, or the lack of the bolt:

https://www.adafruit.com/product/2349

zener
 
Posts: 4416
Joined: Sat Feb 21, 2009 2:38 am

Re: [question] Best way to detect if a door is locked?

by adafruit_support_bill on Sat Sep 14, 2019 7:07 am

The reflective sensor idea is a good practical one. We have a smaller version of those sensors here: https://www.adafruit.com/product/3930

Inductive proximity sensors are another good option. You can find reasonably priced ones from suppliers of 3D printer parts. They are used as bed-leveling sensors.

adafruit_support_bill
 
Posts: 74364
Joined: Sat Feb 07, 2009 10:11 am

Re: [question] Best way to detect if a door is locked?

by markg85 on Sat Sep 14, 2019 9:22 am

dThirteen wrote:My experience with reed switches is the magnet doesn't have to be very strong. I am in Australia and I have used this part https://www.jaycar.com.au/miniature-glass-reed-switch/p/SM1002. You could probably pot something like this in epoxy to give it some resilience.

A simple microswitch that is operated by the tongue of the locking bolt is probably the simplest solution. For example https://www.jaycar.com.au/spdt-125v-3a-sub-miniature-micro-switch-with-lever/p/SM1036


That was my very first attempt!
While that does work, i'm very space constrained. I have tiny strong magnetic discs of 10mm in diameter and 0.8mm thickness.
For that to trigger the reed switch the magnet needs to be within millimeters of it. That's quite precise for something as crude as a door. But it does work for the bolt.
It's not so easy to get it to work for the hinge because of the shape that metal has giving not much room to glue a magnet on. This does complicate the magnetic sensing quite a bit.

I might need to play a bit more with this method to see if i can get it to work reliable..

zener wrote:There are probably several ways you could detect the lock bolt. Here is something similar to your first idea, just simpler and less expensive. You possibly could use it either to detect the bolt itself, or the lack of the bolt:

https://www.adafruit.com/product/2349


Ha :)
That sensor is way too big to fit in the frame.
I was thinking about this sensor: https://www.adafruit.com/product/3317 and then on a smaller PCB. I already have that one https://www.amazon.co.uk/SODIAL-VL53L0X ... B075LHC51D It would be ideal if that PCB size could be half of what it is in that amazon link. Which i think is possible if i look at the components. But then again, i'm not adventurous enough (yet) to design my own PCB. If i go that route i might never get it done and probably just lose interest.


adafruit_support_bill wrote:The reflective sensor idea is a good practical one. We have a smaller version of those sensors here: https://www.adafruit.com/product/3930

Inductive proximity sensors are another good option. You can find reasonably priced ones from suppliers of 3D printer parts. They are used as bed-leveling sensors.


Thank you for the inductive proximity sensor idea, that would have been the most ideal version if i had the room in my frame :) Those sensors are quite large so i'm afraid they are just not an option.

Looks like i should either figure out if i can get the VL53L0X sensor to work. Sensing range won't be much of an issue as the max range it needs to cover is just about 10 centimeters. It can handle that with ease. But making that sensor fit in the frame quite the challenge!

markg85
 
Posts: 8
Joined: Fri Sep 13, 2019 4:50 pm

Re: [question] Best way to detect if a door is locked?

by adafruit_support_bill on Sat Sep 14, 2019 9:41 am

Reflective IR sensors come in many different form-factors. Some are quite tiny. https://www.sparkfun.com/datasheets/Rob ... 113.GR.pdf

adafruit_support_bill
 
Posts: 74364
Joined: Sat Feb 07, 2009 10:11 am

Re: [question] Best way to detect if a door is locked?

by zener on Sat Sep 14, 2019 4:35 pm

Since the bolt is metal maybe you could use these:

https://www.adafruit.com/product/394

zener
 
Posts: 4416
Joined: Sat Feb 21, 2009 2:38 am

Re: [question] Best way to detect if a door is locked?

by markg85 on Sat Sep 14, 2019 5:19 pm

zener wrote:Since the bolt is metal maybe you could use these:

https://www.adafruit.com/product/394


Oh this is funny :)
I click the link and the first thing i think: "uhm.. does he want me to drill a hole into that bolt?..." It looks a bit like a drill.
Then i went on reading it and am like: "ohhh, it's some form of switch!"

These could work too, but i'm a bit afraid of their size. The length the bolt goes into the frame is only about 10mm.
So for that reason i think those are not an option in this specific case.

markg85
 
Posts: 8
Joined: Fri Sep 13, 2019 4:50 pm

Re: [question] Best way to detect if a door is locked?

by markg85 on Fri Sep 20, 2019 7:37 pm

So, i just spend a whole day actually trying this.
I made a simple wooden door frame part for the bolt and the hinge bolt (does that thing have a name?) with the sole purpose to try this first before actually trying it on a real door.

20190921_010816_small.jpg
20190921_010816_small.jpg (35.7 KiB) Viewed 82 times


I first tried the VL53L0X. It would've been a bit overkill as it can handle about 2 meters in ideal conditions.
Yet in this setup it kept hanging at around 40 millimeters.
More worked just fine outside that post mockup, but within the mockup i couldn't get it above about 50 millimeters at times.

Then the thought of using the VL6180X (that's the one in the picture above) somehow creeped in me. It is accurate till about 10cm. That would still be plenty as the opening in the frame is about 8cm.
After some soldering and measuring, i'm again stuck with ranges around 40 millimeters!...
And outside that frame it again was working just fine. This started to become a headache issue :P

After scratching my head for a while and reading the specs i noticed the cone of laser light that is emitted by those chips. It is not a point laser, but rather a cone of 25 degree!
Then it all made sense, after about 40 - 50 millimeter, that cone would hit the sides of the wood and reflect back giving me a measurement.

I think i'm on the right path here, just the wrong chips. Do you folks know of any chips that can measure accurately within 10cm, has a tiny chip footprint and had a very narrow angle. Say between 10 and 15 degree would "probably" work (i didn't do the math). But an actual laser point would definitely work too.

markg85
 
Posts: 8
Joined: Fri Sep 13, 2019 4:50 pm

Re: [question] Best way to detect if a door is locked?

by adafruit_support_bill on Sun Sep 22, 2019 7:22 am


adafruit_support_bill
 
Posts: 74364
Joined: Sat Feb 07, 2009 10:11 am

Re: [question] Best way to detect if a door is locked?

by markg85 on Sun Sep 22, 2019 10:07 am

adafruit_support_bill wrote:https://www.robotshop.com/en/sfe-digital-ir-line-sensor-qre1113.html


Ohh that's awesome!
But.. for 3mm ;) Anyhow, i now at least know how it's called and what to look for.

markg85
 
Posts: 8
Joined: Fri Sep 13, 2019 4:50 pm

Re: [question] Best way to detect if a door is locked?

by adafruit_support_bill on Sun Sep 22, 2019 10:50 am

As mentioned earlier, IR reflective sensors come in dozens of different form-factors and working distances. They are super reliable, simple to interface with and not very expensive.
https://www.mouser.com/Sensors/Optical- ... ?P=1z0z7pt

adafruit_support_bill
 
Posts: 74364
Joined: Sat Feb 07, 2009 10:11 am

Re: [question] Best way to detect if a door is locked?

by markg85 on Sun Sep 22, 2019 11:27 am

adafruit_support_bill wrote:As mentioned earlier, IR reflective sensors come in dozens of different form-factors and working distances. They are super reliable, simple to interface with and not very expensive.
https://www.mouser.com/Sensors/Optical- ... ?P=1z0z7pt


None of those sensors matches my requirements of 8cm (80mm) at the very least till about 10cm (100mm),
But while thinking about it, i might change the design to make it work! Thus far i've been focused on one sensor to measure both. That would have been the ideal situation..
But i can also flip the idea around! Look at this image:
20190921_010816_small_2.jpg
20190921_010816_small_2.jpg (50.66 KiB) Viewed 30 times


I hollowed out the middle of that frame muckup with the idea to create a sort of shaft for the "laser" to pass through (when i didn't know it was an ever expanding cone..). If i double the sensors and put one at the very bottom and one at the very top i can measure the same thing too. Then the requirements drop to, say, 1cm max distance ranging. Now i can still use those ToF sensors while they might be overkill in terms of range, they are awesome in terms of small package size. With these new requirements there is a lot more that would fit the job though :)

Thank you for making me realize this alternative idea! Also, it prevents the need to have that shaft in my frame, which is good! I now only need a small groove where 4 tiny wires could fit through. That's definitely not an issue! The wiring and programming is going to be a bit more complicated though :P

markg85
 
Posts: 8
Joined: Fri Sep 13, 2019 4:50 pm

Re: [question] Best way to detect if a door is locked?

by adafruit_support_bill on Sun Sep 22, 2019 12:15 pm

The wiring and programming is going to be a bit more complicated though :P

Slightly more wiring to handle 2 sensors. But the programming doesn't get any simpler than reading an IR reflective sensor. No library required. Just a simple digitalRead().

adafruit_support_bill
 
Posts: 74364
Joined: Sat Feb 07, 2009 10:11 am

Re: [question] Best way to detect if a door is locked?

by markg85 on Sun Sep 22, 2019 1:13 pm

adafruit_support_bill wrote:
The wiring and programming is going to be a bit more complicated though :P

Slightly more wiring to handle 2 sensors. But the programming doesn't get any simpler than reading an IR reflective sensor. No library required. Just a simple digitalRead().


You are assuming something here that isn't my case ;)

I don't have those IR reflective sensors. I do have a load of VL53L0X sensors which does require more wiring and definitely much more complicated code.
With 1 sensor i could just power it on and use the library for it. With 2 i also need to hookup the XSHUT pin and run them both through a startup sequence just to set the i2c address. As otherwise they would both have the same address which definitely won't work.

If i had only one (my setup thus far) i could just read a distance measurement and based on the result determine a closed or open state.
Still, it all isn't that complicated. The hardware side is done and soldered now. Next up is the software side. I'll post a picture with the results once i get it working properly.

markg85
 
Posts: 8
Joined: Fri Sep 13, 2019 4:50 pm

Please be positive and constructive with your questions and comments.