Repair Design Furniture

The simplest signaling circuit for arduino. Creation of a security alarm with a motion sensor based on Arduino and infrared sensors. Key features of Arduino Uno

They are special hardware platforms on the basis of which various electronic devices can be created, including and. Devices of this type are distinguished by a simple design and the ability to program algorithms for their operation. Thanks to this, the alarm created with the Arduino GSM , can be configured as much as possible for the object that it will guard.

What is an Arduino module?

Arduinos are implemented as small boards that have their own microprocessor and memory. The board also contains a set of functional contacts to which you can connect various electrified devices, including sensors used for security systems.

The Arduino processor allows you to load a program written by the user yourself. By creating your own unique algorithm, you can provide optimal operating modes for security alarms for different objects and for different conditions of use and tasks to be solved.

Is it difficult to work with Arduino?

Arduino modules are very popular with many users. This is made possible by its simplicity and affordability.

Programs for managing modules are written using ordinary C ++ and additions in the form of simple functions for controlling I / O processes on the module pins. In addition, the free software Arduino IDE operating under Windows, Linux or Mac OS can be used for programming.

With Arduino modules, the procedure for assembling devices has been greatly simplified. GSM signaling on Arduino can be created without the need for a soldering iron - assembly takes place using a breadboard, jumpers and wires.

How to create an alarm using Arduino?

The main requirements that the alarm system created by the gsm on the Arduino must meet with their own hands include:

  • notify the owner of the facility about burglary or penetration;
  • support of external systems such as sound siren, warning lights;
  • alarm control via SMS or call;
  • autonomous operation without external power supply.

To create an alarm you will need:

  • Arduino module;
  • a set of functional sensors;
  • or a modem;
  • autonomous power supply;
  • external executive devices.

A distinctive feature of Arduino modules is the use of special expansion cards. With their help, all additional devices are connected to the Arduino, which are required to assemble the security system configuration. Such boards are installed on top of the Arduino module in the form of a "sandwich", and the corresponding auxiliary devices are connected to the boards themselves.

How it works?

When one of the connected sensors is triggered, a signal is transmitted to the processor of the Arduino module. Using the loaded custom software, the microprocessor processes it according to a specific algorithm. As a result of this, a command can be formed to operate the external actuator, which is transmitted to it through the corresponding expansion-interface board.

To ensure the possibility of sending warning signals to the owner of a house or apartment that is being guarded, a special GSM module is connected to the Arduino module through an expansion board. It installs a SIM card from one of the cellular providers.

In the absence of a special GSM adapter, an ordinary mobile phone can also play its role. In addition to sending SMS messages with a warning about an alarm and dialing, the presence of cellular communication will allow you to control the GSM alarm system on the Arduino remotely, as well as monitor the state of the object by sending special requests.

"Note!

To communicate with the owner of the facility, in addition to GSM-modules, ordinary modems can also be used, which provide communication via the Internet. "

In this case, when the sensor is triggered, the signal processed by the processor is transmitted via the modem to a special portal or website. And already from the site, automatic generation of a warning SMS or mailing to the linked e-mail is carried out.

conclusions

The use of Arduino modules will allow users to independently design GSM alarms that can work with various functional sensors and control external devices. Thanks to the possibility of using various sensors, the alarm functions can be significantly expanded and a complex can be created that will monitor not only the safety of the facility, but also its condition. For example, it will be possible to control the temperature at the facility, record the leakage of water and gas, shut off their supply in the event of an accident, and much more.

To protect their home from uninvited guests, more and more people are installing alarms. They allow you to timely warn of entry into the room. Today there are various types of alarms, but recently the popularity of GSM alarms has begun to grow, since they allow you to receive information about penetration at any distance from the object, the main thing is that the owner has a phone with him at that time, and this phone is in the network. Unfortunately, these systems are not yet too cheap to be preferred exclusively to them. But nowadays, you can make a simple GSM signaling yourself. And the popular Arduino board will help in this matter.


This project is a security (alarm) system to alert about intruders entering the house. The system uses GSM technology.



An intrusion detection module is connected to the microcontroller board of this security system, which can be based, for example, on an IR sensor or an ultrasonic proximity sensor. Upon receipt of a signal from such a module, an SMS message is sent to the user's phone about the penetration into his home.


The figure below is a block diagram of the security system.



The main elements of the system are a microcontroller board (for example, Arduino Uno) and a GSM / GPRS module SIM900A. The entire system can be powered from a single 12V / 2A power supply.


The image below shows the schematic diagram of an Arduino based GSM home security system.



The operation of the system is very simple and does not require any special explanations. When the supply voltage is applied, the system goes into standby mode. However, when J2 is shorted, a warning message is automatically sent to the preset mobile phone number. Any detection sensor can be connected to the J2 input connector. It should be noted that the low level on pin 1 of J2 is active and activates the security system.


In addition, the system added the ability to make a call by pressing the S2 button. The S3 button can be used to reset this call.


Below is the code for Arduino.


// Connect the Tx pin to the D3 pin of the GPS module // Connect the Rx pin to the D4 pin of the GPS module // connect the SMS send signal to the D7 pin (active low) // Connect the CALL call signal to D8 (active low) // Connect the END call reset signal to pin D9 (active low) #include NewSoftSerial mySerial (3,4); // set RX and TX pins for communication with the GSM module #define msg_key 7 #define call_key 8 #define end_key 9 String number = "0000000000"; // Here, instead of zeros, you need to enter a 10-digit mobile number void setup () (Serial.begin (9600); mySerial.begin (9600); pinMode (msg_key, INPUT); pinMode (call_key, INPUT); pinMode (end_key, INPUT ); digitalWrite (msg_key, HIGH); digitalWrite (call_key, HIGH); digitalWrite (end_key, HIGH);) void loop () (// send sms every time msg_key fires if (digitalRead (msg_key) == LOW) / / Check if the sms send button is pressed (mySerial.println ("AT + CMGF = 1"); // Set the mode as the text mode delay (150); mySerial.println ("AT + CMGS = \" + 00 "+ number + "\" "); // Specify the destination number in international format, replacing zeros delay (150); mySerial.print (" Warning! Intruder Alert! "); // Enter the message delay (150); mySerial.write (( byte) 0x1A); // End of message character 0x1A: equivalent to Ctrl + z delay (50); mySerial.println ();) // Make a call when call_key triggers else if (digitalRead (call_key) == LOW) // Check whether call_key has already been pressed (mySerial.println ("ATD + 91" + number + ";"); // Determine n number to call while (digitalRead (call_key) == LOW); delay (50); ) // Reset the call else if (digitalRead (end_key) == LOW) // Check if the reset button is already pressed (mySerial.println ("ATH"); while (digitalRead (end_key) == LOW); delay (50 );))

Thus, it is quite easy to create a GSM alarm based on the Arduino board with your own hands. Such an alarm at its cost will, of course, be cheaper than proprietary counterparts on the market today, and it will function in an almost identical way.

This project concerns the development and improvement of a system to prevent / control any attempts to enter by thieves. The developed security device uses an embedded system (includes a hardware microcontroller using open source software and a gsm modem) based on GSM (Global System for Mobile Communications) technology.

The security device can be installed in the house. The interface sensor for the burglar alarm is also connected to the controller-based burglar alarm system.
When an attempt is made to penetrate, the system sends a warning message (for example, sms) to the owner on the mobile phone or to any pre-configured mobile phone for further processing.

The security system consists of an Arduino Uno microcontroller and a standard SIM900A modem based on GSM / GPRS. The whole system can be powered by any 12V 2A power supply / battery.

Below is a diagram of an Arduino-based security system.

The operation of the system is very simple and self-explanatory. When power is applied to the system, it enters standby mode. When the pins of connector J2 are shorted, a preprogrammed warning message is sent to the required mobile number. You can connect any intrusion detector (such as a light guard or motion detector) to the J2 input connector. Note that the active-low (L) signal on pin 1 of J2 will activate the burglar alarm.

Moreover, an optional “call - alarm” device has been added to the system. It activates the phone call when the user presses the S2 button (or when another electronic unit triggers an alarm). After pressing the “call” button (S2), the call can be canceled by pressing another button S3 - the “end” button. This option can be used to generate a “missed call” alarm in the event of intrusion.

The circuit is very flexible, so it can use any SIM900A modem (and of course the Arduino Uno board). Read the documentation for your modem carefully before starting assembly. This will make the process of making the system easier and more enjoyable.

List of radioelements

Designation Type of Denomination Quantity NoteShopMy notebook
Arduino board

Arduino Uno

1 Into notepad
GSM / GPRS modemSIM900A1 Into notepad
IC1 Linear regulator

LM7805

1 Into notepad
C1 100μF 25V1 Into notepad
C2 Electrolytic capacitor10mkF 16V1 Into notepad
R1 Resistor

1 kΩ

1 Into notepad
LED1 Light-emitting diode 1 Into notepad
S1 ButtonWith fixation1

Good time of day 🙂 Today we'll talk about alarm. The service market is full of companies, organizations that are engaged in the installation and maintenance of security systems. These firms offer the buyer a wide variety of alarm systems. However, their cost is far from cheap. But what should a person who does not have so many personal funds do that can be spent on a burglar alarm? I think the conclusion suggests itself - do alarm by their hands... This article provides an example of how you can make your own coded security system using an Arduino uno board and several magnetic sensors.

The system can be deactivated by entering the password from the keypad and pressing the ‘ * ‘. If you want to change the current password, you can do it by pressing the ‘ B', And if you want to skip or interrupt the operation, you can do it by pressing the key ‘#’. The system has a buzzer for playing various sounds when performing a particular operation.

The system is activated by pressing the 'A' button. The system gives 10 seconds to leave the premises. After 10 seconds the alarm will be activated. The number of magnetic sensors will depend on your own desire. The project involves 3 sensors (for two windows and a door). When the window is opened, the system is activated and the alarm goes off from the buzzer. The system can be deactivated by entering a password. When the door is opened, the alarm gives the visitor 20 seconds to enter the password. The system uses an ultrasonic sensor that can detect movement.

Video of device operation

Craft made for informational / educational purposes. If you want to use it at home, you will need to refine it. Enclose the control unit in a metal case and secure the power line from possible damage.

Let's get started!

Step 1: what we need

  • Arduino uno board;
  • high-contrast LCD display 16 × 2;
  • 4 × 4 keyboard;
  • 10 ~ 20kΩ potentiometer;
  • 3 magnetic sensors (they are also reed switches);
  • 3 2-pin screw terminals;
  • HC-SR04 ultrasonic sensor;

If you want to build a system without using an Arduino, you will also need the following:

  • DIP connector for atmega328 + atmega328 microcontroller;
  • 16MHz crystal resonator;
  • 2 pcs. 22pF ceramic, 2 pcs. 0.22uF electrolytic capacitor;
  • 1 PC. 10k ohm resistor;
  • power socket (DC power jack);
  • bread board;
  • 5V power supply;

And one box to pack it all!

Instruments:

  • Something that can cut a plastic box;
  • Hot glue gun;
  • Drill / screwdriver.

Step 2: Alarm circuit

The connection diagram is quite simple.

Small clarification:

High contrast LCD:

  • Pin1 - Vdd to GND;
  • Pin2 - Vss to 5V;
  • Pin3 - Vo (to the center pin of the potentiometer);
  • Pin4 - RS to pin 8 of Arduino;
  • Pin5 - RW to GND;
  • Pin6 - EN to pin 7 of Arduino;
  • Pin11 - D4 to pin 6 of Arduino;
  • Pin12 - D5 to pin 5 of Arduino;
  • Pin13 - D6 to pin 4 of Arduino;
  • Pin14 - D7 to pin 3 of Arduino;
  • Pin15 - Vee (to the right or left pin of the potentiometer).

4 × 4 keyboard:

Left to Right:

  • Pin1 to A5 pin of Arduino;
  • Pin2 to A4 pin of Arduino;
  • Pin3 to A3 pin of Arduino;
  • Pin4 to A2 pin of Arduino;
  • Pin5 to pin 13 of Arduino;
  • Pin6 to pin 12 of Arduino;
  • Pin7 to pin 11 of Arduino;
  • Pin8 to pin 10 of Arduino.

Step 3: Firmware

The step presents the code that is used by the built-in!

Download the codebender plugin. Click on the "Run" button in the Arduino and flash your board with this program. That's all. You've just programmed the Arduino! If you want to make changes to the code, click the "Edit" button.

Note: If you will not be using Codebender IDE to program your Arduino board, you will need to install additional libraries in the Arduino IDE.

Step 4: making your own control board

After you have successfully assembled and tested a new project based on Arduino uno, you can start making your own board.

A few tips for a more successful completion of the undertaken:

  • A 10K resistor must be wired between the 1 (reset) and 7 (Vcc) pins of the Atmega328 microcontroller.
  • A 16MHz crystal should be connected to pins 9 and 10, labeled XTAL1 and XTAL2
  • Connect each lead of the resonator to 22pF capacitors. Lead free capacitor leads to pin 8 (GND) of the microcontroller.
  • Remember to connect the second ATmega328 power line to the power supply, the 20-Vcc and 22-GND pins.
  • You can find more information on the microcontroller pins in the second image.
  • If you plan to use a power supply with a voltage higher than 6V, you must use a linear regulator LM7805 and two 0.22uF electrolytic capacitors, which should be mounted at the input and output of the regulator. It is important! Do not apply more than 6V to the board !!! Otherwise you will burn your Atmega microcontroller and LCD display.

Step 5: Place the circuit in the case

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 -. 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. One-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 1.5mm thick
6. Instrument case from the local radio market - 1.5$
7. A pair of LEDs of different colors (taken from a 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
Direct 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 came across advice to use exactly the 168th atmega.
However, I had to tinker to find such a board, since all the lots were often 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 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, this is 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 AMS1117 linear voltage converter - 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 Atmega168PA consumes current 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, as a rule, is second-hand, not always soldered by clever Chinese hands from 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 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 , choose 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 a 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 - I placed a lithium discharge charge control board with a pre-soldered microUSB connector and soldered wires in it.

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. See how it looks in the photo below.
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. Here 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 - 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, which 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 to the battery contacts so that the distance between them coincided,
I bent the tips, tinned them with a soldering iron, and pulled them 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, measuring 95x60x25mm, 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 to the body. 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 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 do.

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 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 you apply 1.8V voltage, then the consumption will drop below the 1μA bar in active mode. Quite not bad! But if the MK 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