Standalone security and surveillance system at Raspberry PI

Having played with the Raspberry Pi and the camera for it, I thought about its practical application. Just at that moment, the need for an autonomous surveillance system with security functions for a summer residence had ripened (unaccompanied neighboring children burned a bathhouse in the country as a result of gatherings with alcohol and smoking).

Perhaps my experience and work results ( SD image with all the software configured ) will be useful.

I didn’t shoot videos on the ground. For the winter I did not dare leave in an unguarded cottage with roads covered with snow.

Some pieces of work in greenhouse conditions:



The project was not custom-made. Made exclusively for myself and my own pleasure. He refused to work with video offline through a modem right away. Video through a modem in the mode even in 3G is not serious.

Input limitations of the project:
  1. Low-speed Internet via GSM modem (MTS). In the best case, 2G;
  2. There is no host with a "white IP";
  3. Only readily available components.


The input requirements that I have formulated for myself:
  1. Autonomous work with overload after a power failure and software failure;
  2. Swivel platform (horizontal + vertical) with a circular view;
  3. Telephoto lens;
  4. External autonomous sensors with a radio channel;
  5. Automatic shooting of the sensor response zone;
  6. Sending Alarm SMS;
  7. Sending Alarm + low / medium resolution photo to e-mail;
  8. Background uploading high-resolution photos to a cloud drive;
  9. Background uploading of logs to a cloud disk;
  10. Management via e-mail (sending bash scripts and receiving the results of their execution);
  11. Management via SMS. Calling predefined scripts. For example, turn the camera and take a picture;
  12. Forwarding SMS to the modem by e-mail;
  13. Additional functionality when located nearby, within a stable WiFi (15-20m):

  • Functions of a WiFi router with Internet distribution;
  • Access via ftp and ssh console;
  • Web video stream from the camera.


With the exception of the round-robin review, all other requirements were implemented.



Horizontal overview


Completely circular review did not work. Experiments have shown that applying a current through a pair of “brushes from a drill motor + current collection from foil textolite” is clearly not a good idea. Around 2-5 turns of 360 degrees there is a power failure and reboot. The addition of high-capacity electrolyte did not help much. As a result, I put two stops on a rotation angle of 270 degrees and recorded directly without a current collector.

I did not make pictures of the construction with brushes, but I experimented with it a lot. In the photo you can understand how it looked from the beginning (brushes and slip rings from foil textolite were removed).
He did not experiment with other types of current collectors. For my purposes and installation location, 270 degrees of view is enough (building angle).

Conclusion: the current collector "carbon brush + copper plane" is suitable only for cases where short-term contact loss is not important and where due to inertia movement, the contact will be restored.



Swivel platform.


Cheap stepper motors are used for turning. According to the passport, they work from 12V, but as practice has shown, even at 19V they do not heat in the “1 minute after 3 minutes without hold mode” mode. The UN2003 driver copes with current at 19V even in the SO16 (SMD) package without overheating. With the standard UN2003 drivers in the DIP package, which are sold bundled with step switches, there should be no problems at all.
The rotation is smooth and completely silent.

Involute gears with a 1mm module, if you are interested, are very well cut on a CNC machine with a 1mm milling cutter made of fiberglass.



The choice of stepper motors is due to the ease of control and positioning accuracy during autonomous operation.

I suggested using a reed switch with a magnet to set it to “0”, but after abandoning the circular view, I came to the conclusion that the following technology is more convenient:
  1. Rotate the horizontal vertical and platform to the maximum angle;
  2. When reaching the stop, stepper motors begin to skip steps (the motors are weak and this is quite acceptable);
  3. At the end of the rotation cycle at maximum angles, we can assume that "0" is reached relative to the stops.


Positioning to “0” this way is pretty slow, but still faster than booting Linux. Linux boot speed on raspberries is just depressing.

Power Features


As many times said, raspberries are VERY finicky to eat. I powered it and WiFi USB from a 19V 2.6A power supply (which was) from an old laptop through a stepdown DC-DC converter. A separate stepdown DC-DC converter was needed to power a 3G modem.

I couldn’t power the modem from one converter and the board didn’t work, although according to the “Chinese passport” I should have enough current of the DC-DC module. There is enough current in the statics of one converter, but when the modem is activated, you can hear how the generation in the voltage converter module breaks down, passing into the audio range, and the output voltage sags with Linux rebooting.

Camera


Native Rasberry Pi camera with lens replacement. The lens came from the MT9D111 module, bought a long time ago on e-bay for experimentation. The matrix was not useful, and the lens fit perfectly. Together with the standard lens, the IR filter built into it was also removed. Which is even good, since the new lens is marked IR. The colors in the pictures are somewhat distorted (pinkish pictures), but IR illumination is possible for that.

External sensors


A PIR module on the BISS0001 is used as a sensor. A transmitter from a 433MHz keychain, slightly completed (one bipolar transistor and resistor) and controlled by the output from the PIR module.
Experiments have shown that from a 12V acid battery this combination works for at least 2 months (maybe more, have not tried it).

The receiver is 4-channel and is sold complete with a keychain. Thus, 4 protection zones are provided with the ability to take a photo of the place of operation.

The range of the transmitter-receiver kit is less than that claimed by the sellers, and reception is not stable at approximately 40 meters of direct visibility. Perhaps this is interference from the Raspberry pi, GSM modem and / or DC-DC converters.
In the summer, some nights, there were “false” responses. Probably on birds or bats.

The first version of the sensor was with a separate output for activating IR illumination. I didn’t take a photo then, but there’s nothing difficult. Just another transistor controlled from the PIR output. Backlight - a round board from a surveillance camera at 12V with IR LEDs.

After the tests, I refused the local IR illumination of the sensor zone:
  1. IR backlight LEDs are clearly visible at dusk. Unmask sensor mounting location;
  2. At night, the local IR backlight turned on from the PIR sensor seems to give positive feedback on IR radiation and miracles begin with the PIR sensor continuously triggering. It is necessary to "be smart" with the relative position of the sensor and the backlight. It is difficult, inconvenient and depends on the time of day.


By signal from the sensor:
  1. The camera rotates at a programmed angle horizontally and vertically;
  2. Takes low-resolution pictures (640x480) and the picture with the maximum resolution (stored in tmpfs);
  3. A low-resolution image is sent to e-mail;
  4. SMS is sent informing about the sensor activation;
  5. A high-resolution image in the background is uploaded to the cloud drive. If you can’t send immediately, it is saved to the archive on SD, for subsequent sending.




Software


A lot of detailed articles are devoted to the settings of a 3g modem, WiFi, etc., and I consider it irrational to repeat them.
SD image with all
software configured
.

The file /home/pi/read.me contains links to files where you need to register your passwords.
Configured on Yandex services (e-mail and cloud drive).
Login / password of console and ftp - standard: "pi / raspberry"

Potential opportunities for improvement (in my opinion):
  1. Make "/" completely readonly. For the most part, I put out the entire file entry in tmpfs. But, something remained and laziness was busy, because, in practice, the probability of damage to SD, after an abnormal power off, decreased to values ​​satisfying me;
  2. Hardware reset the modem by interrupting its power circuit. It may be subjective, but sometimes “on / off” helps better than a software reset modem. In principle, it is not difficult. Only one field effect transistor in the modem power circuit.


Components


Standard components:
  1. Raspberry pi + SD card from 4GB;
  2. Raspberry pi camera (Chinese clone);
  3. GSM modem - MTC 3G (ID 12d1: 1506 Huawei Technologies Co., Ltd. E398 LTE / UMTS / GSM Modem / Networkcard).
  4. WiFi from the standard recommended. (ID 0bda: 8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter);
  5. Stepping motors 28BYJ-48 12V + drivers for UN2003;
  6. Power supply - any 12-20V at least 2A;
  7. Stepdown DC-DC Converters - 2pcs. On the "Chinese" output current of at least 2A;
  8. If the lens does not suit the standard (and it is completely nonexistent) - any one you like. There are lenses for surveillance cameras for any task and wallet;
  9. RS232TTL-USB module for connecting a console. In fact, only for debugging;
  10. The receiver board and the required number of PIR modules and transmitter remote controls (full on ebay in different versions).


Solder:
  1. USB extension cable for a modem with + 5V extension to a separate DC-DC converter;
  2. Level matching between GPIO 3.3V IN and receiver outputs. On each channel - a bipolar transistor + a pair of resistors. I also set the LED for control;
  3. Connectors and cables to connect all this.


Who has a CNC machine - without problems, you can draw and cut the case / gears. You can draw and cut in a maximum of 3 hours. I don’t post my original drawing. I would do it a second time - I would do it differently and more compactly.

Conclusions from the results


If I needed to make a replicable industrial solution for a similar security alarm task, I would not have chosen the Raspberry Pi.

I would take an OEM camera module, a controller like STM32 ... with an interface for a camera and an OEM module of a GSM modem.
Somehow it’s more convenient for me to do such things without OS or on specialized OSs.

It would take a maximum of 3-4 times more time to develop a purely burglar alarm functional than pairing a bunch of free software with excessive functionality and bringing all this zoo to working condition.
The energy consumption of raspberries and the fastidiousness of food is simply depressing.

And so the raspberry pi toy is interesting. But just play. Although this is my personal opinion and I do not impose it.

Also popular now: