What is a somewhat foolproof and secure way to detect whether a physical apartment door is closed (and locked)? Of course, an electric lock would or should have that kind of capability. However, I'd just like to install a status detector on a regular door. The most important thing is to detect whether the door is tightly at the 0 angle position. The next would be to detect whether the lock is in certain position, but we can postpone that part for now.
So what is the way to detect the door position? It should be made very difficult if not impossible to tamper the system. A simple switch will not do at all, you could simply put tape on the switch. Distance meter is also probably too easily tamperable. Would a simple accelerometer be so foolproof that it would detect the exact position of the door? Because that might be fairly difficult to tamper with. Would it be able to detect if you remove the device and it goes up/down and out of the horizontal circular orbit (= security breached)? To hack it, you would have to build a circular rail and move the accelerometer exactly right to the correct "closed" position to fake it.
So what is the way to detect the door position? It should be made very difficult if not impossible to tamper the system. A simple switch will not do at all, you could simply put tape on the switch.
Do you expect tampering from the inside or outside? Please describe the circumstances you expect on that door.
Would a simple accelerometer be so foolproof that it would detect the exact position of the door?
It won't detect the position at all, it will simply detect a movement of it. Sure you can add them all up but you always get a small measurement error and that sums up too.
So use the reed contact Wawa suggested and build it into the door so that you cannot remove it without destroying the door.
Circumstance: opening the door remotely and relying on other people to properly close the door. Where there are problems such as the person not realizing the door is not closed completely. Thus it would be great if the system would both measure the exact position of the door (under millimeter accuracy) and the state of the bolt (however we can still leave out the state of the bolt, that'll be another project). Most likely the tampering would happen when the door is open and then faking the closing of the door.
Thank you for the reed switch. It's a viable choice. However, I would also like to add that ideally I would not have to break/remove anything to make it work. Adding stuff is fine. I mean, I could glue detectors and cables somewhere but it's good if I don't have to drill big holes in the door, for example. In other words I would like to make it a relatively portable solution.
I'm not sure which is easier to tamper, the magnet switch or the accelerometer solution. With the accelerometer, it could recalibrate when the door is stationary for a long time (= probably closed). I believe it depends on how accurate it is whether it would work for this purpose at all.
Does a wireless RF distance meter exist? Perhaps that might work: hiding a transmitter/receiver somewhere in the same room, attaching it with glue (or similar) so that it doesn't move. The door would have the other transmitter/receiver. Manual calibration when the door is closed. That would be the exact (under millimeter accuracy) distance between the door and the hidden box when the door is closed. To tamper with this, one would have to know the exact distance when leaving the door open and then repositioning the box accordingly.
From what you describe the reed contact is the simplest solution. You can glue the magnet to the door and the reed switch to the wall, with a bit of trial and error you probably find a location where the millimeter accuracy is reached.
All the other ideas you had are about the same complexity to tamper as the reed contact.
The accelerometer solution won't work, you'll never reach the needed accuracy. And forget to check if the sensor is move in a circular orbit or not, an Arduino simply does not have enough memory for that.
If you want a smart attacker to fail to tamper the reed contact by gluing a magnet to the contact, just use two of the in different positions on the door and check that the open/close at almost the same time (inside a very small time frame). It doesn't eliminate the possibility of tampering but makes it very hard.
Thank you for the suggestion. Could you explain how what you mean by the open/close trigger? Is it not boolean, on or off? If you suggest it detects close and open separately, then how exactly does it do that?
Oh, two sets, probably next to or on top of each other, ok. If you know how it works, then it might be easy to tamper. For example you have a suitable magnets and you trigger them both at the same time. If on top of each other, then it should be simulatenous, probably within 1 millisecond time range. Might work, would have to test to see in action.
Thanks again and if there are any other ideas, that would be great. An idea that is portable would be the best. Portable, but once installed, it would detect if it's tampered and would have to be reset again (e.g. with a password) and then it would be fine again.
There is no such thing as tamper proof.
You haven't even explained what you want the sensor to do. Light up? Send status over the internet? Make a noise?
It sounds like this isn't even your door if you can't drill into it.
Go with a magnet and reed switch. Get a system working. Then worry about changing the sensor type once you've solved all of the other problems. And since you're so sure it's going to be tampered with, magnets and reed switches are cheap.
distrill:
Circumstance: opening the door remotely and relying on other people to properly close the door. Where there are problems such as the person not realizing the door is not closed completely.
As I recall it, this is the reason for doing the properly, using some serious door closers and electric strikers. If you don't do that, you are just playing around. It is a while since I have been involved in this sort of stuff, but the most vital component in the system, the users, are still the same.
If you know how it works, then it might be easy to tamper. For example you have a suitable magnets and you trigger them both at the same time.
If your definition tampering says it's easy to put two magnets to a reed switch within 10ms you should definitely forget about a "portable" solution. You then expect very experienced users with a high intent to attack your system. So you should definitely invest in serious parts (as Nick_Pyner already stated) and it will definitely not be portable.
there are following alternates:
Use of Limit Switches
Use High range Proximity at door end to walls.
Use of rotatory potentiometer. (Cheapest and best alternate).