Determine whether the toilet is free, and display status in the web

1. Intro h5> In our office of about 30 people, and all of us have to 1 wc to visit to pass the corridor, pull the handle, and if you do not open the door - to accept and wait until freed.

Included light - is not an indicator of freeness of the object, since next to it there is still a sink that can be occupied, and the toilet is not.

1.1 If there is no desire to read the entire text, you can go directly to the demonstration

2. The purpose h5> While I was working in the office (almost 4 years), this problem has ripened hard enough and therefore had to be obvious and simple solution in order to find out whether the toilet is free or not.

3. The simplest scheme h5> A simple diagram of the whole structure looks like this:
Closed door - red light
Open door - the green light is lit

4. We start adding elements h5> Our company develops and implements software, so all the computers sit most of the day, so you want to display on a web page free status of the toilet. The most reliable and simple to implement it seemed to take on a vehicle trailer, twisted pair and a server with two network cards.

4.1. How do you know that the door is closed or not h6> The simplest - is to go and see
Bryulchik suggested the use of the trailer vehicle (Ending Russian PS-116 R (PS 2B, AU-30B)) to determine the status of the door.





He has a fairly simple scheme - if the door is closed, it opens the circuit, in the opposite case - the circuit is closed, and the door is open, so everything is free.

4.2. Pull twisted pair and connected h6> There is such a thing called RJ-45 Loopback, it is necessary to test, and there is no need to use a second network card or a tester, for example, to check whether the cable is not interrupted.



We will use this knowledge to our project.
Stretched twisted pair to the entrance, the other end to compress and inserted into the server.

Link, of course, is not yet.
Take the first and third conductors and closes with -2oy and second living do the same.

In a second link appears on the port the server now opens, 2 and 6, the missing link, in general, this is what we need.

4.3. Fasten h6> Take the trailer and hang it on the door jamb, looking to avoid being pulled out of our powerful guards, pressed against the door jamb, but at the same time there was a contact when the door is open.

First and third conductors and reserve twisted, hiding them under obnalichnik door on the second wire and fasten the moving part of the trailer, the second strand in the trailer itself and all neatly wrapped with electrical tape.

4.4. Need more tape h6> Experience has shown that there is an adequate explanation of why this happens, but the point is that if we take the exposed areas of copper fingers (at the end of the 2nd and 6th wires), you will see the link ( !), and if you release the core, the link will not be gone (!!!). This way we could not explain, but if you do not touch anything with their greasy fingers, then everything will work as intended.

5. ON h6> The most exciting (for me) is part of the writing software.

The whole complex is divided into two parts - a server that polls the sensor and the web page.
Every 3 seconds, mii-tool, on a server with two sensor and network card, look at the interface and its status, and then resets this status option -R

If the status is changed from the previous one, it makes a simple HTTP GET request to the server with a web page.

In turn, the server from a Web Page hanging a script that writes the changed status of the file, and has regular html-page scans the file and displays a green light or red.

6. Demonstration h6> All that we have done can be seen in the video:


Source: geektimes.ru/post/250004/