Security system, smart home project (part 2)

    security systemIn a previous post, the initial stage of creating a security system was described, with a detailed description of the selection and connection of sensors to the microcontroller, the transfer of information to a computer and the creation of a room layout for testing and debugging the system itself. You can read about it here on the Habr and in more detail here, on the project website . And at the end of that article, we shared our plans for the further development of the project, which were adjusted after some comments (many thanks for that).
    Below, after the habrakat, there will be a short story about how you can use social resources, in particular twitter, as well as how to make a PTZ camera controlled by a microcontroller from improvised means, and in the end there will be results and development plans.

    Use Twitter to Connect


    When developing the security system, the task was not only to output data to a computer, but also the ability to view the status of the protected object in any place and at any time. At the same time, two ways of notification were considered: the first - to inform via SMS, and the second - to receive messages through social services and networks (Vkontakte, twitter, facebook).

    As you might guess from the header, the second path was chosen. And for starters, there were 3 ways to decide whether to receive messages (they all use the Twitter API functions):
    1) Direct .
    Straight
    direct connection method
    Here, I think, comments are not required
    2) Serial .
    Consistent
    serial connection method
    This path was allocated for debugging equipment, collecting and analyzing received data (false positives, etc.).
    3) Consistent independent .
    Consistent independent
    consistent independent connection method
    Here, we see that first the data is sent to the Twitter server, and then to the third-party statistics server.

    Due to the fact that a statistics tool was needed, the choice became between 2 and 3 ways. In our opinion, 2 method (sequential) was easier to implement. We took up its development.
    To implement the server part, the TwitterOAuth library (a Twitter API library) by Abraham Williams dev.twitter.com/docs/twitter-libraries#php and the GET method were used.
    And for the top-level program written for the computer, the standard Windows API functions and the winsock2.h library were used.
    And here is the result
    Submitting alarm status on Twitter

    Create a PTZ camera


    In our project, the engine should perform the following function - rotation of the web-camera, i.e. creation of a cheap analogue of the dome camera was provided.

    When choosing a stepper motor, the main attention was paid to two main parameters - size and cheapness. Size, since the main purpose is to rotate the camera, whose weight is not more than 150 grams. Cheapness due to the fact that the entire security system should not be expensive, but to pay $ 30 - $ 40 only for the engine itself is an overkill. The way out of this situation was found.

    It’s enough to recall that almost everyone has an old computer with drives, and there we have the component we need. If not, you can go to the radio market, or to a thrift store, where you can buy $ 3-4 per piece, agree 3 and 30 there is a difference.

    To control the stepper motor, we used a circuit consisting of a processor, ILN2003 microcircuit (a seven-channel driver and being an analogue of ULN2003A) and the stepping motor itself “bitten out” of the printer.
    Stepper motor control circuit
    To control the engine, the “one phase on full step” mode was selected, the operation diagram for this mode is shown below:
    Digram work
    Video, quality is not very good, it was shot on the phone


    How the whole system works


    The system was developed on the basis of what will be used in small rooms. In this case, the sensors are installed in places of possible penetration (doors, windows), then they are all connected to the security loop. Information from the sensors arrives at the control panel, which processes the received data and, if an attempt is made to penetrate it, it performs the following sequence of commands:

    - re-checking the status of the loop;
    - turning the camera to the place where the triggered sensor is installed;
    - sending a message to a computer, iPhone, where a special application is installed, capable of sending information to your twitter account or mail;
    - checking the illumination in the room using the connected photodiode and, if necessary, turning on the light;
    - sending a message to a computer, iPhone, where a special application is installed, capable of sending a photo taken by a webcam to your twitpick account;
    - transition to the polling mode of the remaining sensors.

    The system diagram is presented below.
    security system block diagram

    Conclusion and Plans


    Above, notification methods, stepper motor control and the algorithm of the system itself were considered. In the third and final part, we will show on the video the work of all the previously described elements and prepare the final video presentation.
    To develop the project, a new site was created - make-smart-room.com , where detailed materials for each considered component of the security system were laid out. A huge request to help with advice and suggestions for further development.

    Also popular now: