Determine whether the toilet is free, and display the status in the web
1. Intro
There are about 30 people in our office, and we all have 1 toilet to visit which we need to go through the corridor, pull the handle and, if the door does not open, put up with it and wait for it to be released.
The switched on light is not an indicator of the freedom of the given object, since next to him there is still a sink that can be occupied, but the toilet itself is not.
1.1 If you do not want to read the entire text, you can immediately proceed to the demonstration
2. Purpose
While I work in this office (almost 4 years), this problem has matured quite strongly, and therefore an obvious and simple solution was needed in order to find out if the toilet is free or not. ')
3. The simplest scheme
A simple diagram of the whole structure looks like this: The door is closed - the red light is on Open door - green light is on
4. Start adding items
Our company is engaged in the development and implementation of software, so everyone is at computers all day, which means that you need to display the status of free toilet on a web page. The most reliable and simple to implement seemed to take the switch from the car, twisted pair and a server with two network cards.
4.1. How to know that the door is closed or not
The simplest thing is to go and see. Bryulchik proposed to use the car's trailer (Trailer Russia PS-116 R (PS 2B, AU-30B)) to determine the door status.
He has a sufficiently simple scheme - if the door is closed, then he opens the circuit, otherwise, the circuit is closed and the door is open, which means everything is free.
4.2. We pull the twisted pair and connect
There is such a thing, called RJ-45 Loopback, it is needed for testing, and there is no need to use a second network card or tester to, for example, check if the cable is interrupted.
We will use this knowledge for our project. Stretched a twisted pair to the entrance, the other end is compressed and inserted into the server.
Link, of course, not yet. We take the 1st and 3rd veins and close, with the -2nd and 6th residential we do the same.
A second later, a link appears on the port at the server, now we open 2 and 6, the link is gone, in general, this is what we need.
4.3. Fasten
We take the switch and hang it on the doorframe at the door, we look so that our powerful guards do not pull it out, pushing the door close to the doorframe, but at the same time there was contact when the door was open.
We leave the 1st and 3rd cores twisted, hide them under the door clerk, onto the 2nd core and fasten the moving part of the trailer, the 6th core on the end itself and carefully wrap everything with electrical tape.
4.4. Need more tape
As practice has shown, there is no adequate explanation as to why this is happening, but the bottom line is that if you take hold of the open areas of copper with your fingers (at the end of the 2nd and 6th core), then a link will appear (!), And if you release the cores , the link will not disappear (!!!). This we could not explain, but if you do not touch anything with your fat fingers, then everything will work as intended.
5. software
The most fascinating (for me) part is writing software.
The whole complex is divided into 2 parts - a server that polls the sensor and the web page. Every 3 seconds, the mii-tool, on the server with a sensor and two network cards, looks at the interface and its status, and then resets this status with the -R option
If the status has changed from the previous one, then it makes a simple HTTP GET request to the server with a web page.
In turn, a script hangs on the server with a web page, which writes the changed status to a file, and the usual html page polls this file and displays a green or red light bulb on the screen.
6. Demonstration
Everything that we have done can be seen in the video: