• What can be cooked from squid: quick and tasty

    Spring, as you know, is accompanied by all sorts of exacerbations, and the main “exacerbation” has climbed out of its holes into the street in order to appropriate for itself what does not belong to it. This means that the topic of protecting your property is becoming more relevant than ever.
    The site already has several reviews on homemade ones. They are of course functional, but they all have a common feature - dependence on an outlet. If this is not a problem with real estate, where electricity has already been supplied, then what about property where the outlet is far away or the surroundings are completely de-energized? I decided to go the other way - to assemble a long-lived, maximally simple and independent from the mains supply device, which will sleep all the time, and when the robbers penetrate, start and call the owner on the phone, signaling with a simple alarm call.

    Review items

    Purchased:
    1. Single-sided development board 5x7 cm: getinax- or fiberglass
    * - fiberglass is much better than getinax.
    2. Neoway M590 module -, with PCB antenna -
    3. Arduino Pro Mini "RobotDyn" ATmega168PA 8MHz 3.3V -
    4. Lithium charge-discharge control board -

    Mined from the ruins of civilization:
    1. Racks for the board, sawn out of the instrument cases - 6 pcs.
    2. Battery lithium flat 1300mAh
    3. Brackets used to fix the cable to the wall
    4. Stationery eraser
    5. Copper wire thickness 1.5mm
    6. Instrument case from the local radio market - 1.5$
    7. Pair of LEDs different color(took from VHS player)
    8. Antenna and a button with a cap (taken from a Wi-Fi router)
    9. 4-pin terminal block (taken from the dimmer)
    10. Power connector (taken from an old 18650 charger)
    11. 6-pin connector (taken from a DVD drive)
    12. Tin can (for coffee for example)

    Arduino Pro Mini "RobotDyn" Atmega 168PA 3.3V 8MHz

    Specifications:
    Microcontroller: ATmega168PA
    Direct operating voltage:.8 - 5.5V
    Operating voltage through the LE33 stabilizer: 3.3V or 5V (depending on model)
    Working temperature:-40 ° C ... 105 ° C
    Input voltage: 3.35-12V (3.3V model) or 5-12V (5V model)
    Digital Inputs / Outputs: 14 (6 of which can be used as PWM outputs: 3, 5, 6, 9, 10, and 11)
    Analog inputs: 6
    Timers-counters: two 8-bit and one 16-bit
    Power saving modes: 6
    Constant current through input / output: 40 mA
    Flash memory: 16 KB (2 used for bootloader)
    RAM: 1 Kb
    EEPROM: 512 bytes
    Resource write / erase memory: 10,000 Flash / 100,000 EEPROM
    Clock frequency: 8 MHz (3.3V model) or 16 MHz (5V model)
    SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK)
    I2C: A4 (SDA) and A5 (SCL)
    UART TTL: 0 (RX) and 1 (TX)
    Datasheet:

    The choice fell on this atmega quite by accident. on one forum where energy-efficient projects were discussed, in the comments I came across advice to use exactly the 168th atmega.
    However, I had to tinker with finding such a board, since quite often all lots were littered with 328 atmegs at a frequency of 16 MHz, operating from 5V. For my project, such characteristics were redundant and inconvenient from the very beginning, the search became more complicated.
    As a result, I came across a 3.3-volt version of the Pro Mini on the Atmega 168PA on eBay, and not just a simple Chinese one, but under the RobotDyn brand from a Russian developer. Yes, I, too, at first, like you, had a grain of doubt. But in vain. When the project was already assembled, and AliExpress introduced a mandatory paid delivery for cheap goods (after which the parcels were lost much more often), then later I ordered the usual Pro Mini Atmega168 (without PA) 3.3V 8MHz. I experimented a little with the power-saving modes with both boards, flashing a special sketch into each, immersing the microcontroller in the maximum power-saving mode, and this is what happened:
    1) Arduino Pro Mini "RobotDyn": ~ 250μA
    2) Arduino Pro Mini "NoName": when power was applied to the voltage regulator (RAW output) and the LED was removed, the current consumption was ~ 3.92mA




    - as you understand, the difference in power consumption is almost 16 times, all because the NoName "Pro Mini uses a bunch of Atmega168 +, of which the MK itself eats only 20μA current (I checked this separately), all the rest of the gluttony falls on the linear voltage converter AMS1117 - the datasheet only confirms this:


    In the case of the RobotDyn board, the bundle is somewhat different - this is Atmega168PA + - here we have used another LDO stabilizer, whose characteristics in terms of energy saving turned out to be more pleasant:


    I didn't solder it, so I can't say how much current Atmega168PA consumes in its pure form. In this case, I had enough ~ 250μA when powered by a Nokia lithium battery. However, if you solder AMS1117 from the NoName "of the motherboard, then the ATmega168 is an ordinary one, in its pure form, as I said above, it consumes 20μA.
    Power LEDs can be knocked off with something sharp. It's not a problem. The stabilizer was soldered with a hairdryer. However, not everyone has a hairdryer and the skills to work with it, so both of the above options have a right to exist.

    Neoway M590E module

    Specifications:
    Frequencies: EGSM900 / DCS1800 Dual-band, or GSM850 / 1900 or Quad-band
    Sensitivity:-107dBm
    Maximum transmission power: EGSM900 Class4 (2W), DCS1800 Class1 (1W)
    Peak current: 2A
    Working current: 210mA
    Sleep Current: 2.5mA
    Working temperature:-40 ° C ... + 85 ° C
    Working voltage: 3.3V ... 4.5V (3.9V recommended)
    Protocols: GSM / GPRS Phase2 / 2 +, TCP / IP, FTP, UDP etc.
    Internet: GPRS CLASS 10
    Datasheet:

    The cheapest GSM-module that can be found on the market, usually used, not always soldered by smart ones Chinese hands from the equipment. Why not always dexterous? Yes, all because of soldering with a hairdryer - often people come with these modules with a short-circuited plus and minus, which is one of the reasons for their inoperability. Therefore, the first step is to ring the power contacts for a short circuit.

    Note. A separate important point, in my opinion, I would like to note - these modules can come with a round coaxial connector for the antenna, which allows you to separately order a more serious antenna and connect it to the module without dancing with a tambourine. And they can come without this connector. This is when we talk about the cheapest sets. If you don't want to rely on a fluke, then there are a little more expensive sets, where this connector is present + an external antenna on a textolite board is included in the kit.

    This module is also capricious before power supply, since at its peak it consumes up to 2A of current, and the diode included in the kit seems to be conceived to lower the voltage from 5V (which is why it is written on the 5V board itself) to 4.2V, but judging according to the complaints of the people, it creates more trouble than good.
    Suppose you have already assembled this module, and instead of a diode, a jumper is soldered, since we are not going to supply it with a voltage of 5V, but we will power it directly from a lithium battery, which is within the range of permissible voltages of 3.3-4.2V.
    It will be necessary to somehow connect it to the computer and check for operability. For this case, it is better to buy yourself in advance - through it we will communicate with the module and Arduino boards via the UART serial interface (USART).
    The connection is shown below in the picture (I drew it as I can):
    TX modem >>> RX converter
    RX modem<<< TX конвертера
    Battery Plus - Modem Plus
    The minus of the lithium battery is combined with the GND of the modem and the GND of the converter
    To start the modem, apply the BOOT pin through a 4.7 kOhm resistor to GND


    Meanwhile, run the program on the computer. Pay attention to the settings:
    1) Select the COM port to which the TTL converter is connected, in my case it is COM4, ​​you may have a different one.
    2) Select the baud rate. (There is a nuance here, because the modules themselves can be configured for different speeds, most often 9600 baud or 115200 baud. Here you need to select empirically, choosing some speed, connecting, and sending the AT command, if crackers come in response, it will turn off , select a different speed and repeat the command, and so on until you get an OK answer).
    3) Select the packet length (in this case 8 bits), the parity bit is disabled (none), the stop bit is (1).
    4) Be sure to check the box + CR, and then a carriage return character will be automatically added to each command we send to the module at the end - the module understands commands only with this character at the end.
    5) Connection, everything is clear here, we clicked and we can work with the module.

    If you click on "Connect" and then start the module by applying BOOT through a 4.7K resistor to ground, then the terminal will first display the message "MODEM: STARTUP", then, after a while, the inscription "+ PBREADY", which means that the telephone number has been read. book, even though it may be empty:

    Under this spoiler, AT teams with examples

    We print the AT command - in response, the module sends us our command, since the echo mode is enabled, and OK:

    Let's check the status of the modem with the AT + CPAS command - in response, our command is again, + CPAS: 0 and OK.
    0 - means that the module is ready for operation, but depending on the situation, there may be other numbers, for example, 3 - incoming call, 4 - in connection mode, 5 - sleep mode. I did not find information on 1 and 2.

    Changing the data transfer rate on the UART is performed by the command AT + IPR = 9600 - this is if the speed is 9600. If any other, it is similar to AT + IPR = 19200 for example or AT + IPR = 115200.

    Let's check the network signal. AT + CSQ, the answer comes + CSQ: 22.1 - the value to the decimal point has a range of 0 ... 31 (115 ... 52dBl) - this is the signal level, the more the better. But 99 means his absence. The value after the decimal point is the signal quality 0 ... 7 - here it is already the opposite, the lower the number, the better.

    Disable echo mode by sending the ATE0 command so that duplicate commands do not get in the way. Inversely, this mode is turned on by the ATE1 command.

    View firmware version AT + GETVERS



    These and many other commands can be viewed

    Aligning boards

    While Pro Mini is easy to solder to the breadboard, the situation with the GSM module is a little more complicated. his contact comb is located only on one side, and if you solder only it, then the other side of the board will simply hang in the air. Then, again by eye, I had to drill 3 additional holes near three corners on the board. The areas around each of the holes were then stripped of the mask. For convenience, I placed the disconnected leads from the comb on the solderless breadboard (white) and, having installed the GSM module board on them, normally soldered:

    Later I had to make another hole, in my case on the letter "I", where it says "Made In China", on the edge of the board.


    It turned out that the added contact, which is essentially GND, became located next to the GND of the Pro Mini board, and thus it became possible to combine the ground of the GSM module and the Pro Mini with a drop of solder (the long pin in the middle and to the right of it is the Pro Mini pin) - I marked them with arrows. Of course it turned out a little crooked, but now it is holding on reliably:



    There is some space left between the boards - in it I placed a lithium discharge charge control board with a pre-soldered microUSB connector and soldered wires.

    The scarf fits there very tightly, while the glow of the LEDs from the side will be clearly visible through a small hole in the case.



    PCB stands

    To securely fix the board inside the case, I had to spend a couple of days thinking about how this could be implemented. The option with hot melt glue was not considered for several reasons - it can fall off, deform, and most importantly, the structure would be difficult to disassemble.
    I came to the idea that the simplest and most correct option here would be to use racks, which, of course, I did not have. However, there were a couple of non-working chargers, from where one long rack with a thread for self-tapping screws was cut. Each stand was sawn in half and finished with a file to about 9.5mm - it is at this height that the battery located under the board has a sufficient margin, about 2mm - this is done so that the soldered contacts of the board do not touch it with their tips and so that it is possible to insert a piece between them foam rubber for fixation.
    As for attaching the board directly to the case, here I cut four strips from a coffee can, at the ends of which I drilled a hole, then fixed them on the same screws that were screwed into the racks. Below in the photo, see how it looks.
    The next step is to screw a couple of racks on the other side of the board, that is, from above, so that when the case is closed, the lid rests slightly on these racks, creating additional fixation. A little later, under this case, I came across a body from under the Soviet propaganda radio (if it had been found earlier, I would have taken all the racks from here), where I found a couple more or less suitable in height, but first I drilled them in the center with a drill under self-tapping screws. Then he cut them down and also finished them off with a file, removing the excess. Then I got one subtlety - in the photo you can see that one white stand is screwed to the getinax board from the edge, and the other white stand is screwed directly to the module board, because from one edge of the modem board completely covers the lower board, and from the opposite edge - on the contrary - the lower one looks out. At the same time, in both boards it was necessary to additionally drill holes so that the caps of the self-tapping screws could pass freely.
    And finally, it remains to make sure that the board is always parallel to the case - the brackets that are used to fix wires and cables on the wall perfectly fit for this case, I previously removed the nails from them. The brackets adhere well to the board with the concave side without any additional devices, the only thing is to the right of the SIM card, the width of the bracket turned out to be excessive and had to be sanded as well.
    All details were adjusted by eye and empirically, below the photo of all of the above:



    Connectors. LEDs. Button.

    Since I ran out of the comb, I had to dismantle the 6-pin connector from the DVD drive board, which I then soldered to the Pro Mini, this is for the convenience of flashing the board. Nearby, I soldered a round connector (Nokia 3.5mm) for charging lithium.

    The body of the 6-pin connector was slightly finished off with a file, because its edges protruded slightly above the body. The charging socket fits perfectly against the wall of the case.

    On the other side of the board, I soldered a button to reboot the device and two LEDs for debugging the firmware - the red LED is connected to the GSM module, the second green LED to pin 10 of the Pro Mini - it's easier for me to debug the program using it.

    Refinement of the battery

    A flat Nokia battery from Nokia phones is no less common than the 18650, but many simply refuse to use it due to the inconvenience of connecting the contacts, which are recessed into the battery itself. It is undesirable to solder them, so it was decided to use the method proposed by these, namely to make a terminal block from a stationery eraser and copper wire (1.5mm thick).
    First, I pierced a piece of eraser with two wires with pre-stripped ends, and put it on the battery contacts so that the distance between them coincided,
    I bent the tips, tinned it with a soldering iron, and pulled it back a little by the long ends so that the resulting contacts were sunk into the eraser.



    Fitting on a battery:

    You can fix the terminal block with a rubber band or wrap it with blue electrical tape, which I did in the end.

    Assembly.

    The main part of the work is done, it remains to collect and fix it all.
    Between the battery and the board I put a piece of foam rubber so that it would not crawl inside the case afterwards. I additionally soldered a 2200 uF capacitor to power the module.

    When charging is connected:

    Frame. External terminal block.

    I got the case on the local radio market for about $ 1.5, if translated into dollars, 95x60x25mm in size, almost the size of a pack of cigarettes. I drilled several holes in it. First, for a 4-pin terminal block, taken from an inoperative dimmer.
    I completely freed the two extreme contacts from the bolts with gaskets, drilled holes for longer bolts, on which the entire terminal block will hold on to the case. On the case itself, of course, the two extreme holes will be large, and the two in the middle are smaller - they will have pins through them, one of which is connected to the VCC Pro Mini, and the second pin to pin 2.

    Drilling holes, although simple at first glance, is still no less time consuming, it is very easy to miss, so I did it first with a smaller drill, then with a larger one.

    For the tact button, I selected a cap with a slightly concave top so that it would be convenient to hit it with a match or a paper clip through a narrow hole in the case.

    Board in a case with a USB-TTL converter loop connected:

    About the antenna.
    The antenna, as you may have noticed along the way, was constantly changing, as I experimented with different homemade antennas. Initially, there was a round coaxial connector on the module board, but the fifth time it was used for an external antenna, it just fell apart, so keep in mind that it is flimsy. As a result, I tore out the antenna on the PCB from the old router, and soldered it to the module board, tk. it catches the net a little better than the spring and wire.

    Well, completely assembled with a connected charger looks like this:

    Test. How it works:

    In addition to tests with antennas, I checked how the alarm would behave on the street, in frost -15. To do this, I simply placed the insides entirely in a container and left them on the balcony overnight, the alarm did not start at the same time, the reason was, in general, obvious - lithium does not like frost. This was confirmed by another test, where I left the battery at home, and brought the board through long wires to the street and left it there for a day in the same frost - the operation, as if nothing had happened. On the other hand, it would be strange if the alarm didn’t work. in datasheets for atmega, for module, for quartz - permissible operating temperatures up to -40 degrees.

    The principle of operation is organized by an external interrupt, initially pin 2 is closed to VCC and thus a logical 1 is supported on the pin, and the controller sleeps. As soon as the contact is broken and 0 appears on pin 2, the microcontroller wakes up, lowers the 3rd pin (to which the BOOT modem is connected through a resistor) to the ground - the module starts up, the MC periodically polls the module for readiness, and as soon as it catches the network, it immediately sends a call to the owner's phone number specified in the code. After rejecting the call, the device shuts down without sending more endless calls than many Chinese alarms are guilty of.

    Additional Information

    #include #include // library of software UART SoftwareSerial gsm (7, 6); // RX (7), TX (6) void wakeUp () () // empty interrupt handler //////////////////////////// /////////////// void gsmOFF () (// PORTD | = (1<<3); // ВЫКЛЮЧЕНИЕ МОДУЛЯ _delay_ms(10); // gsm.println("AT+CPWROFF"); // ПЕЧАТАЕМ КОМАНДУ OFF PORTB &=~ (1<<2); // выключить LED 10 } // //========================================= void gsmON(){ // PORTD|=(1<<6); // 6-му порту (TX) назначить 1 PORTD &= ~(1<<3); // ЗАПУСК МОДУЛЯ _delay_ms(10); // while(!gsm.find("+PBREADY")); // ждём прочтения тел. книги PORTB |= (1<<2); // включить LED 10 _delay_ms(100); // while(1){ // gsm.println("AT+CREG?"); // проверяем в сети ли модуль if (gsm.find("0,1")) break; // если сеть есть, выходим из цикла _delay_ms(400); // проверка раз в 0,4 сек } // } // /////////////////////////////////////////// // void sleepNow(){ // функция засыпания ADCSRA = 0x00; // отключить подсистему АЦП (экономия 140 мкА) PORTD&=~(1<<6); // в вывод TX поставить 0 _delay_ms(100); // set_sleep_mode(SLEEP_MODE_PWR_DOWN); // режим сна PWR_DOWN sleep_enable(); // включение сна attachInterrupt(0, wakeUp, LOW); // включить прерывания sleep_mode(); // sleep_disable(); // detachInterrupt(0); // отключить прерывания } void setup(){ gsm.begin(9600); // скорость работы UART DDRD = B01001000; // 3-й и 6-й выводы на выход DDRB |= (1<<2); // вывод 10 на выход gsmON(); // запуск модуля для теста gsmOFF(); // выключаем модуль } void loop(){ if (!(PIND&(1<<2))){ // если на 0-ом прерывании появился 0 gsmON(); gsm.println("ATD+79xxxxxxxxx;"); // отзваниваемся, в ответ приходит OK и CONNECT _delay_ms(100); if (gsm.find("OK")) while(1){ // ожидание сброса вызова gsm.println("AT+CPAS"); // при каждой итерации опрашиваем модуль if (gsm.find("0")) break; // если 0, то выходим из цикла while _delay_ms(100); // проверка раз в 0,1 сек } for (char i=0; i<14; i++){ PORTB|=(1<<2); // LED 10 ON _delay_ms(200); PORTB&=~(1<<2); // LED 10 OFF _delay_ms(200); } gsmOFF(); // выключить модуль _delay_ms(10); while(1); // блокируем программу } else { sleepNow(); // укладываем контроллер спать } }

    Circuit (without charge-discharge control board)



    Conclusions and thoughts. Plans.

    The alarm is used in the country, I am satisfied with the work, however, with further study of the AVR, more and more ideas come up for its further modification. Arduino with its pseudo-language Wiring upset me a lot, because there was one unpleasant moment in the work. When I used the functions for working with ports digitalWrite (); or pinMode (); - then the GSM module for some reason very often hung up. But it was worth replacing them with freaks like DDRB | = (1<Only the operation of direct access to the ports made the device work, as it was intended.

    Energy saving ...
    The assembled device worked for four full months without recharging and continues to work, although it would be more correct to say "sleep". This is verified by a simple reboot through the white button. With an energy consumption of 250 μA (through the LE33 stabilizer) and a ~ 1430 mAh battery, although okay, due to the non-novelty of the battery, we round up to 1000mAh, it turns out that the device can sleep for about 5.5 months without recharging. If you nevertheless evaporate the stabilizer, then the operating time can be safely multiplied by 10 times. But in my case, there is no need for this, because you still need to spend the balance from the SIM card every three months, at the same time the device can be checked and recharged.
    The example of energy saving given in the review is far from the limit, since judging by the information from the datasheet, it is possible to lower the clock frequency of the microcontroller (and this is done by installing fuses) to 1 MHz and, if 1.8V voltage is applied, the consumption will drop below the 1μA bar in active mode. Quite not bad! But if the MC is clocked from the internal RC generator, then another problem will appear - the UART ether will be clogged with garbage and errors, especially if the controller is heated or cooled.

    On completion ...
    1) An ordinary wire installed on a gap is not very convenient, I plan to experiment with a Hall sensor and a reed switch, although they say about the latter that it is not very reliable, because the contacts inside it can stick.
    2) It would be nice to add the ability to change the "master number" without the participation of a computer and flashing. This already has to work with the EEPROM.
    3) Try interrupts from the watchdog timer, but not just for the sake of curiosity, but so that the microcontroller periodically wakes up by itself, takes measurements of the battery voltage and sends the received value via SMS in order to be aware of how much the battery is discharged.
    4) The solar panel can completely eliminate the need to recharge the device, this will be relevant especially for low-capacity batteries.
    5) For a long time I wanted to buy LiFePo4 batteries, which, according to reviews, tolerate frost normally, but while I was looking for a suitable lot, spring had already imperceptibly come.
    6) Work on the aesthetic component

    Which Pro Mini should you buy?
    If there is no hair dryer, then Pro Mini "RobotDyn" Atmega168PA 3.3V, pick off the LED with something sharp and you have ~ 250μA.
    If you have a hair dryer, then any board, you solder the stabilizer and the power LED - you get ~ 20μA of current consumption.

    That's all for now, I hope the review was interesting and useful.

    I plan to buy +174 Add to favourites I liked the review +143 +278

    In the last article, we learned how to use the SIM800L GSM module and made a simple design for controlling the load remotely, today we will do something more interesting, namely the GSM burglar alarm on the SIM800L module from Aliexpress and Arduino, which can be used to protect an apartment, summer house, garage, etc. other objects, and when it is triggered, it will notify you with a call or SMS message.

    What we need to make a GSM signaling:

    • GSM / GPRS module SIM800L;
    • Arduino Nano, UNO or another Arduinka;
    • DC-DC buck converter;
    • 3.7V battery;
    • 10 k resistors - 7 pcs;
    • Power Supply.

    How to make a security GSM alarm on the SIM800L module and Arduino, description of work:

    We connect the SIM800L module, Arduino, sensors, etc. according to the diagram below, everything is assembled on a breadboard so that you can change something at any time, we place it in any suitable case and remove the wires from the case for security sensors and on the power supply unit. We also place the battery in the case, it is needed so that when electricity is lost in the house, the device goes into autonomous mode, powered by the battery. On the step-up converter, we set 4.2 volts at the output, at this voltage the GSM SIM module works and at the same time the battery is recharged, and this voltage is also enough for the Arduino Nano to work.

    Any 5 sensors can be connected to the circuit, these are like reed switches, humidity, smoke, motion, etc. which support relay operation, since this circuit is configured to trigger an alarm for an open circuit of any of the five sensors, but if desired, the sketch can be redone for a short circuit.

    When the first sensor is triggered, a call is made to the specified number, then the call is dropped and a call is made to the second number, this is done if the first number is not available at the moment. When the other 4 security sensors are triggered, only an SMS message is sent in which the number or name of the triggered zone is written, and this message will also be sent to two telephone numbers.

    In the sketch, you can enter phone numbers and give your names to the protected zones, instead of “Alarm! Zone1 ”,“ Alarm! Zone2 ”,“ Alarm! Zone3 "... You can write the name of the object where you put a specific sensor, for example" Alarm! Okno ”,“ Alarm! Dverj ", etc., write the zone names only in Latin letters. Also, in the sketch, the callback time to the owner is set, that is, after how many hours to inform you that the whole system is working and everything is in order, by default it is set to call back every 144 hours.

    That's it, we made a simple security GSM alarm on the SIM800L and Arduino module, the sketch and the circuit can be modified, for example, the SIM800L module supports the ability to connect a loudspeaker and a microphone to it, which will allow you to listen to the protected area, as well as bring your voice to the loudspeaker.

    Download sketch for Arduino.

    Today we will talk about how using Arduino to collect security system... Our "guard" will guard one circuit and control one siren.

    For Arduino, this is not a problem, and, as you will see from the program code and the device diagram, you can easily increase the number of protected access points and the number of warning or indication devices.
    Security system can be used to protect both large objects (buildings and structures) and small items (boxes, safes), and even portable cases and suitcases. Although you need to be more careful with the latter, if you install a security system, for example, on a suitcase with which you decide to go on a trip, and the warning system goes off at some airport, then I think you will have a serious conversation with the local security service :-)

    Simplified, the principle of operation of the device is as follows (Fig. 1). After turning on the power, the device enters the operating mode and waits for arming. Arming and disarming are carried out with one button. To increase security, it is better to place this button inside the protected area (safe or box). Before turning on the security mode, the door must be slightly opened. When you turn on the security mode (press the button), the electronic circuit waits until you close the door to the room (safe door, box lid, etc.).

    A limit switch of any type must be installed on the door (or door), more on that later. By closing (or opening), the limit switch will inform the device that the protected circuit is closed, and the device will switch to the armed mode. The system will notify about the transition to the security mode with two short signals (as in car alarms). In this mode, the device "catches" the opening of the door. After opening the door, the system waits for a few seconds (this is a configurable value, for rooms about ten seconds, for a box one or two) for disarming, if this does not happen, the siren turns on. The algorithm and circuit are designed in such a way that you can turn off the siren only by completely disassembling the case and turning off the power.

    Device security system very simple (fig. 2). At the heart of the fee Arduino... The limit switches are connected like a regular button through pull-up resistors. I will dwell on the limit switches separately. They are normally closed and normally open. You can turn on an ordinary button as a limit switch, only the travel of the ordinary button is very large, the door play is usually greater. Therefore, it is necessary to come up with some kind of pusher for the button and spring it so as not to break the button with the door. Well, if not laziness, then you can walk to the store and buy a magnetic switch (reed switch) (Fig. 3), it is not afraid of dust and dirt.

    A limit switch for car alarms is also suitable (Fig. 4). It should be noted that the program is written for a reed switch. When the door is closed, its contact is closed. If you use a switch from a car alarm, then when the door is closed, it will most likely be open, and in the appropriate places in the code you will need to change 0 to 1 and vice versa.

    As a siren, I propose to use a sound annunciator PKI-1 IVOLGA Belarusian production (Fig. 5). Supply voltage 9 - 15 V, operating current 20 - 30 mA. This allows it to be used with battery power. At the same time, it "gives out" 95 - 105 dB.

    With such characteristics from the Krona battery, it will sound for several tens of minutes. I found it on the Internet for 110 rubles. There, a reed switch with a magnet costs about 30 rubles. The car alarm switch in auto parts was purchased for 28 rubles. The KT315 transistor can be taken with any letter or replaced with any modern low-power silicon transistor of appropriate conductivity. If the volume of one siren is not enough (who knows, maybe you want it to be heard for many kilometers), you can connect several sirens in parallel or take a more powerful one, only in this case the transistor must be replaced with a more powerful one (for example, the familiar transistor assembly ULN2003). As connectors for connecting a reed switch and a siren, I used the simplest connectors for audio / video devices - the price on the radio market is 5 rubles. for a couple.

    The device body can be glued from plastic or plywood; if a serious object is guarded, then it is better to make it metal. Batteries or accumulators should be placed inside the case to increase reliability and safety.

    To simplify the program code, no energy saving elements were used, and the batteries are not enough for a long time. You can optimize the code, or even better, radically alter it by applying interrupt event handling and MK hibernation. In this case, the power supply from two square batteries connected in series (9 V) should last for several months.

    Now the code

    // constants
    const int button = 12; // pin for the button
    const int gerkon = 3; // pin for reed switch
    const int sirena = 2; // pin of siren control
    const int led = 13; // indicator pin
    // variables
    int buttonState = 0; // button state
    int gerkonState = 0; // state of the reed switch
    int N = 0; // counter of the disarming button
    void setup () (
    // siren and indicator control - exit
    pinMode (sirena, OUTPUT);
    pinMode (led, OUTPUT); // push button and reed switch are inputs
    pinMode (gerkon, INPUT);
    pinMode (button, INPUT);
    }
    void loop () (
    digitalWrite (led, HIGH);
    while (buttonState = = 0) (// wait loop until we press the button
    buttonState = digitalRead (button); // to switch to security mode
    }
    digitalWrite (led, LOW);
    buttonState = 0; // reset the value of the button
    while (gerkonState = = 0) (// loop until we close the door
    }
    delay (500); // :-)
    digitalWrite (sirena, HIGH); // Code
    delay (100); // indications
    digitalWrite (sirena, LOW); // include
    delay (70); // mode
    digitalWrite (sirena, HIGH); // guard
    delay (100); // alert
    digitalWrite (sirena, LOW); // sound
    while (gerkonState = = 1) (// wait for the door to open
    gerkonState = digitalRead (gerkon);
    }
    for (int i = 0; i<= 5; i++){ // 7,5 секунды на нажатие
    buttonState = digitalRead (button); // secret button
    if (buttonState = = HIGH) (// keep track of our own - stranger
    N = N + 1;
    }
    delay (1500); // secret feature :-)))
    }
    if (N> 0) (// most important
    digitalWrite (sirena, LOW); // don't turn on the siren
    }
    else (
    digitalWrite (sirena, HIGH); // or turn on the siren
    }
    digitalWrite (led, HIGH); // turn on the indicator N = 0;
    buttonState = 0;
    delay (15000); // reminder for dummies who like
    digitalWrite (led, LOW); // press the buttons without interruption delay (1000);

    A simple home security alarm system on the Arduino Uno is the topic of this review. Despite the fact that microcontrollers of this family were originally intended for teaching students, it is quite possible to make a really useful project on Arduino. Security alarms for a house or garden plot will be able to warn the owner of an emergency and send a message from sensors to a smartphone.

    Arduino home alarm

    Let's consider how to make an alarm for a house, a suburban garden or a garage on an Arduino Uno or Nano. In the project, we used a motion sensor, a water and temperature sensor - this is a set of basic sensors for the simplest warning system. You will learn about a breakthrough in the water supply system, a decrease in the temperature in the house or the penetration of strangers into the room at any time and in any place.

    Arduino sensors for burglar alarms

    In this project, we used an old smartphone to transmit information over the Internet. Accordingly, the location of your property must have a GPRS signal and any mobile operator has the simplest tariff with Internet access connected. If these conditions are not met, then a sound siren is provided in the security system, which can also frighten off the robbers.

    The project uses the simplest sensors - a DHT11 temperature sensor, a water leakage sensor that you can make yourself, and a motion sensor. If you decide to make a more complex alarm, we recommend that you look at the project of a fire alarm or a GSM alarm. You will also need to install the application on your smartphone and register two Twitter accounts.

    How to make an Arduino alarm

    For this project we need:

    • Arduino Uno / Arduino Nano / Arduino Mega board;
    • smartphone with Internet access;
    • DHT11 temperature and humidity sensor;
    • water leakage sensor;
    • motion sensor and button (switch);
    • LEDs, resistors, wires, etc.


    A sketch for an alarm, all the necessary libraries and an application for a smartphone can be downloaded in one archive. Note that it will not be possible to remotely control the Arduino, since the project is as simple as possible. You can only in messages on your smartphone learn about the readings of the sensors installed in the house, after a specified period of time or when a sensor is triggered.

    Security alarm sketch on Arduino Uno / Nano

    #include // connecting the SoftwareSerial.h library SoftwareSerial mySerial (2, 3); // specify pins rx and tx, respectively#include // connect the library for the sensor DHT dht (16, DHT11); // tell which port the sensor will be on int tmp; #define PIR 5 // port for connecting the motion sensor int pir; #define KNP 7 // port for connecting the switch int knp; #define WTR 19 // port for connecting a water sensor int wtr; #define LED 11 // port for connecting LEDs#define BUZ 9 // port for connecting a piezo speaker // strings for identifying information received on the smartphone String stringT = String ("*"); String stringP = String ("^"); String stringW = String ("-"); String stringH = String ("#"); // variables for counters, counting cycles, etc. unsigned long motion; unsigned long hour; byte m, s1, s2, s3, c = 10; void setup () (mySerial.begin (9600); Serial .begin (9600); dht.begin (); pinMode (PIR, INPUT); analogWrite (PIR, LOW); pinMode (KNP, INPUT); analogWrite (KNP, LOW); pinMode (WTR, INPUT); analogWrite (WTR, LOW); // check LEDs and buzzer at power on pinMode (BUZ, OUTPUT); pinMode (LED, OUTPUT); analogWrite (LED, 255); tone (BUZ, 100); delay (1000); analogWrite (LED, 0); noTone (BUZ); delay (1000); ) void loop () (tmp = dht.readTemperature (); pir = digitalRead (PIR); knp = digitalRead (KNP); wtr = analogRead (WTR); // start counter hour = millis (); // 3600000 milliseconds is 1 hour, 10800000 - 3 hours // if 3 hours have passed - send data to the smartphone // if necessary, put your values ​​instead of 10800000 if (millis () - hour> 10800000) (mySerial.println (tmp + stringT); mySerial.println (stringH); // send a signal that 3 hours have passed } // counting the cycles, every tenth cycle we send data to the smartphone c--; Serial .print (c); Serial .println ("- loop"); Serial .println (""); delay (1000); noTone (BUZ); if (c> 10) (c = 10;) if (c< 1) { s1 = 0; s2 = 0; s3 = 0; mySerial.println (tmp + stringT); // send the temperature value mySerial.println (pir + stringP); // send the presence of movement in the house mySerial.println (wtr + stringW); // send data from water sensors // THE MOTION SENSOR WORKED AND THE BUTTON IS OFF - TURN ON THE LIGHT if (pir == HIGH && knp == LOW) (analogWrite (LED, 255);) // MOTION SENSOR DISCONNECTED AND BUTTON IS OFF - TURN OFF THE LIGHT if (pir == LOW && knp == LOW) (motion = millis (); while (pir == LOW) (tmp = dht.readTemperature (); pir = digitalRead (PIR); knp = digitalRead (KNP); wtr = analogRead (WTR); c--; Serial .print (c); Serial .println ("- loop"); Serial .println (""); delay (1000); noTone (BUZ); if (c> 10 ) (c = 10;) if (c< 1) { s1 = 0; s2 = 0; s3 = 0; mySerial.println (tmp + stringT); // send the temperature value mySerial.println (pir + stringP); // send the presence of movement in the house mySerial.println (wtr + stringW); // send data from water sensors // display all data from the sensors on the port monitor Serial .print ("TMP ="); Serial .println (tmp); Serial .print ("PIR ="); Serial .println (pir); Serial .print ("KNP ="); Serial .println (knp); Serial .print ("WTR ="); Serial .println (wtr); Serial .println (""); ) // LIGHT OFF INTERVAL IN MILLISECONDS if (millis () - motion> 5000) (analogWrite (LED, 0); break;) if (pir == HIGH) (analogWrite (LED, 255); break;))) // THE MOTION SENSOR WORKED AND THE BUTTON IS ON - STARTING THE TIMER if (pir == HIGH && knp == HIGH) (motion = millis (); delay (1000); analogWrite (LED, 255); Serial .println ( "SENSOR WORKED"); Serial .println (""); delay (1000); while (knp == HIGH) (tmp = dht.readTemperature (); pir = digitalRead (PIR); knp = digitalRead (KNP); wtr = analogRead (WTR); c--; Serial .print (c); Serial. println ("- loop"); Serial. println (""); delay (1000); noTone (BUZ); if (c> 10) (c = 10;) if (c< 1) { s1 = 0; s2 = 0; s3 = 0; mySerial.println (tmp + stringT); // send the temperature value mySerial.println (pir + stringP); // send the presence of movement in the house mySerial.println (wtr + stringW); // send data from water sensors // display all data from sensors on the port monitor Serial .print ("TMP ="); Serial .println (tmp); Serial .print ("PIR ="); Serial .println (pir); Serial .print ("KNP ="); Serial .println (knp); Serial .print ("WTR ="); Serial .println (wtr); Serial .println (""); ) // IF THE MOTION SENSOR IS DISCONNECTED - SENDING A MESSAGE TO BLUES if (knp == LOW) (Serial .println ( "ALARM DISABLED"); Serial .println (""); delay (1000); ) // IF IT HAS BEEN MORE THAN 10 SECONDS - SENDING A MESSAGE TO BLUES if (millis () - motion> 10000 && s1! = 1) (m = 1; goto message1;) delay (1000); )) // IF WATER LEAKS - SEND MESSAGE TO BLUES if (wtr> 500 && s2! = 2) (m = 2; goto message2;) if (wtr> 500) (tone (BUZ, 400);) if (wtr<= 500) { noTone (BUZ); } // IF THE TEMPERATURE HAS BEEN DOWN - SENDING A MESSAGE TO BLUES if (tmp< 20 && s3 != 3) { m = 3; goto message3; } if (tmp < 20) { tone (BUZ, 200); } if (tmp >= 20) (noTone (BUZ);) message1: while (m == 1) (Serial .println ( "ALARM SENT TO BLUESE" // send the temperature value mySerial.println (1 + stringP); // send the presence of movement in the house mySerial.println (wtr + stringW); // send data from water sensors s1 = 1; m = 0; break; ) message2: while (m == 2) (Serial .println ( "WATER LEAK SIGNAL SENT TO BLUESE"); Serial .println (""); delay (1000); mySerial.println (tmp + stringT); // send the temperature value mySerial.println (pir + stringP); // send the presence of movement in the house mySerial.println (500 + stringW); // send data from water sensors s2 = 2; m = 0; break; ) message3: while (m == 3) (Serial .println ( "TEMPERATURE SIGNAL SENT TO BLUESE"); Serial .println (""); delay (1000); mySerial.println (20 + stringT); // send the temperature value mySerial.println (pir + stringP); // send the presence of movement in the house mySerial.println (wtr + stringW); // send data from water sensors s3 = 3; m = 0; break; ))

    Explanations for the code:

    At first glance, the scheme may seem complicated, but it is not. The signaling can be assembled on any board, including the Arduino Uno. Instead of LEDs, you can use an LED strip, but at the same time, the power for the board will already need 12 Volts, and connect the LED strip not to 5V, but to the Vin pin of the Arduino. With LEDs, you can use a regular 5 Volt phone charger to power the circuit.

    Installing an alarm application on a smartphone

    To install the application, download the home_twit.apk file to your phone via a USB cable, find it in the phone's memory and click “Install”. This phone must always be in the bluethoth zone of the Arduino signal. After installation, open the application and click the "Configure" button. Here you will need to specify the minimum and maximum temperature values ​​at which the message will be sent.

    Now the hardest part is setting up Twitter accounts. In the settings, specify the Twitter username to whom you will send the message. You also need to specify a login, API key and API secret key on whose behalf messages will be received. The latest innovations are due to the fight against spam and the collection of information about users on the social network. How to get API key and API secret - read this review.

    On the phone, which will always be with you and will receive messages, you will need to install the official Twitter application from PlayMarket and enter it with the desired username. As a result, the signalizaciya.apk application from the phone in the house will collect data from the Arduino sensors and send them in a personal message via Twitter to the user under whose login you installed the Twitter application.

    If you have any problems with the alarm settings on the Arduino - write your questions in the comments to this review.

    Over the past decade, car thefts have occupied one of the most important places in the structure of crimes committed in the world. This is due not so much to the specific weight of this category of theft in relation to the total number of crimes, but to the significance of the damage caused due to the high cost of cars. The weak effectiveness of the measures taken in the field of combating vehicle theft by the end of the 90s led to the creation of stable groups specializing in the commission of these crimes and having the distinctive features of organized crime; you've probably heard the term "black auto business". The car park of European states is annually missing ≈ 2% of cars that become the subject of criminal encroachments. Therefore, I got the idea to make a gsm alarm for my car based on Arduino Uno.

    Let's get started!

    What will we collect

    We must choose the heart of our system. In my opinion, there is nothing better for such signaling than the Arduino Uno. The main criterion is a sufficient number of pins and a price.


    Main features of Arduino Uno

    Microcontroller - ATmega328
    Working voltage - 5 V
    Input voltage (recommended) - 7-12 V
    Input voltage (limit) - 6-20 V
    Digital Inputs / Outputs - 14 (6 of which can be used as PWM outputs)
    Analog Inputs - 6
    DC current through input / output - 40 mA
    DC current for 3.3 V pin - 50 mA
    Flash Memory - 32KB (ATmega328) of which 0.5KB is used for bootloader
    RAM - 2 KB (ATmega328)
    EEPROM - 1 KB (ATmega328)
    Clock frequency - 16 MHz


    Fits!

    Now you need to choose a gsm module, because our alarm system should be able to notify the owner of the car. So, you have to google it ... Here, an excellent sensor - SIM800L, the size is just wonderful.


    I thought and ordered it from China. However, everything turned out to be not so rosy. The sensor simply refused to register the SIM card on the network. Everything that was possible was tried - the result was zero.
    There were kind people who provided me with a cooler thing - Sim900 Shield. This is already a serious thing. The Shield has a microphone and headphone jack, a full-fledged phone.


    Main features of Sim900 Shield

    4 standards of working frequency 850/900/1800/1900 MHz
    GPRS multi-slot class 10/8
    GPRS mobile station class B
    Compliant with GSM phase 2/2 +
    Class 4 (2 W @ 850/900 MHz)
    Class 1 (1 W @ 1800 / 1900MHz)
    Controlled by AT commands (GSM 07.07, 07.05 and SIMCOM extended AT commands)
    Low power consumption: 1.5mA (sleep mode)
    Operating temperature range: -40 ° C to +85 ° C


    Fits!

    Ok, but you have to take readings from some sensors to notify the owner. Suddenly the car is evacuated, then the position of the car will clearly change in space. Let's take an accelerometer and a gyroscope. Fine. Dachshund, now we are looking for a sensor.

    I think the GY-521 MPU6050 will definitely fit. It turned out that it also has a temperature sensor. It would be necessary to use it, there will be such a "killer feature". Suppose the owner of the car put it under the house and left. The temperature inside the car will change "smoothly". What happens if an attacker tries to break into a car? For example, he will be able to open the door. The temperature in the car will begin to change rapidly, as the air in the passenger compartment begins to mix with the ambient air. I think it will work.


    Main features of GY-521 MPU6050

    3-axis gyroscope module + 3-axis accelerometer GY-521 on the MPU-6050 chip. Allows you to determine the position and movement of an object in space, the angular velocity during rotation. It also has a built-in temperature sensor. It is used in various copters and aircraft models, it is also possible to assemble a motion capture system based on these sensors.

    Microcircuit - MPU-6050
    Supply voltage - from 3.5V to 6V (DC);
    Gyroscope range - ± 250 500 1000 2000 ° / s
    Accelerometer Range - ± 2 ± 4 ± 8 ± 16g
    Communication interface - I2C
    Size - 15x20 mm.
    Weight - 5 g


    Fits!

    A vibration sensor is also useful. Suddenly, they will try to open the car with "brute force", or, in the parking lot, another car will touch your car. Take the vibration sensor SW-420 (adjustable).


    Main features SW-420

    Supply voltage - 3.3 - 5V
    Output signal - digital High / Low (normally closed)
    Used sensor - SW-420
    Comparator used - LM393
    Dimensions - 32x14mm
    Additionally - There is an adjusting resistor.


    Fits!

    Screw on the SD memory card module. We will also write a log file.


    Main characteristics of the SD memory card module

    The module allows you to store, read and write to the SD card the data required for the operation of the device based on the microcontroller. The use of the device is relevant when storing files from tens of megabytes to two gigabytes. The board contains an SD card container, a card power stabilizer, a connector for the interface and power lines. If you need to work with sound, video or other volumetric data, for example, to keep a log of events, sensor data or store information from a web server, then the SD memory card module for Arduino will make it possible to use an SD card for these purposes. Using the module, you can study the features of the SD card.
    Supply voltage - 5 or 3.3 V
    SD card memory capacity - up to 2 GB
    Dimensions - 46 x 30mm


    Fits!

    And let's add a servo, when the sensors are triggered, the servo with the DVR will turn and shoot video of the incident. Take the MG996R servo.


    Main features of MG996R servo

    Stable and reliable protection against damage
    - Metal drive
    - Double row ball bearing
    - Wire length 300 mm
    - Dimensions 40x19x43mm
    - Mass 55 gr
    - Angle of rotation: 120 degrees.
    - Working speed: 0.17sec / 60 degrees (4.8V no load)
    - Working speed: 0.13sec / 60 degrees (6V no load)
    - Starting torque: 9.4kg / cm at 4.8V power supply
    - Starting torque: 11kg / cm at 6V power supply
    - Working voltage: 4.8 - 7.2V
    - All drive parts are made of metal


    Fits!

    We collect

    There are a lot of articles about connecting each sensor in Google. And I have no desire to come up with new bicycles, so I will leave links to simple and working options.