Another GSM security and fire alarm with the ability to control the heating of a house (dacha)

Friends, allow me to present a GSM alarm project on Arduino. There are quite a few “Arduino + modem + sensors” type projects on the network, but I often see some incompleteness in them (especially from a software point of view): lack of flexibility in settings and configuration. In the presented solution, I tried to make the device as ready as possible for “combat” conditions, providing everything that the average user might need (in my opinion).

TL; DR has been implemented in software and hardware, the test in real conditions has been launched, the sources and binaries have been published, but the case has not been mastered.

Device and characteristics

The device sends SMS when the following events occur:

  • door opening (reed sensor);
  • sudden change in lighting (photoresistor);
  • motion (PIR sensor);
  • temperature out of the specified range;
  • low battery voltage.

Example SMS with event

Also, once a day you can set the time of the daily report

The device is powered by 3 AA batteries. Estimated operating time ≥6 months.

Setting up the device, reading event logs and plotting a monthly temperature graph is done using the utility (Python 2.7 + Tk + pyserial + matplotli).

Main window of the setup utility

Event log window

Temperature log window

Formulation of the problem

The first stage of the project, if you want to create a simple signaling system on Arduino with your own hands, is to state the problem. We are talking about what it should “be able to do” and what functions it should have. It is the actual actions that will determine its final cost and the components necessary to obtain the desired result.

So, the alarm system must be able to:

  • determine the movement of any object in the observed space;
  • monitor the condition of the doors - whether they are open or closed in cross-section;
  • feel a change in illumination - in case of any unauthorized access, either the light will be turned on or a flashlight will be used, which will directly indicate to the control device the factor of the break-in;
  • send periodic messages to the owner’s cell phone using SMS about the current state of the environment and control equipment;
  • inform - through the same communications - about the fact of unauthorized access to the protected premises;
  • You also need the ability to simply change the settings of the security system itself.

Alarm assembly powered by battery:

In addition to the above functions, given the constant problems with electricity, it is necessary to provide a backup power supply for the alarm circuits, pending a complete replacement of the external power supply with internal batteries.

We recommend reading: detailed instructions on how to make a motion sensor work on the Arduino platform.

Assembling the device

The cost of the device parts at the time of publication of this article is approximately 1000-1200 rubles (excluding the order of the board).

For ease of assembly and reliability in operation, it is better to order a board. Chinese friends from a well-known site offer to make 10 pieces with delivery for ~$7, and sometimes less. But you can always assemble it on a breadboard, as I did with the first prototype:

Prototype.

Arduino and compatible modules were ordered from aliexpress. You will need:

  • Arduino Pro Mini 3.3v 8MHz (5v 16MHz is also acceptable, but requires different firmware);
  • MH-SR602 MINI Motion Sensor;
  • SIM800C(L) GSM Module;
  • CP2102 MICRO USB to UART TTL Module;
  • DS3231 RTC Module For Raspberry Pi;
  • 3 AA battery holder With ON OFF Switch;
  • various loose parts (resistors, capacitors, buzzer, etc.).

The list specifically contains names that give the desired result when entered into a search.

Device diagram To reduce power consumption, you must remove the power LED resistor and voltage regulator from the Arduino board. The board design was made in Ki-CAD.

Project diagram

The alarm circuit with a barking dog on Arduino and a PIR sensor is shown in the following figure. The amplifier included in the circuit is used to amplify the signal from the output of the sound module with a dog barking.

The alarm circuit includes an Arduino Nano board, a PIR motion sensor, a barking dog sound module, an LM386 amplifier IC, a loudspeaker, an NPN transistor and several resistors and capacitors. Transistor BC547 is used to activate the alarm whenever the PIR sensor detects movement. The VCC and GND pins of the PIR sensor are connected to the 5V and GND pins of the Arduino board, and its OUT pin is connected to the digital pin 12 of the Arduino board.

Pins 1 and 8 of the Amplifier IC control the amplifier gain, the default is 20 but can be increased to 200 using a capacitor between pins 1 and 8. We used a 10uF capacitor C1 to get the highest gain – 200.

Pins 2 and 3 are the input pins of the amplifier IC. Pin 2 is the inverting input, in our case it is shorted to ground. Pin 3 is a non-inverting input and supplies the signal that needs to be amplified. In our circuit, it is connected to the output of the dog barking sound module through a 100 kOhm potentiometer (RV1).

Through pins 4 and 6, power is supplied to the amplifier chip. Pin 6 is supplied with +Vcc, and pin 4 is supplied with Ground. The amplifier circuit can be powered from a voltage in the range of 5-12v.

Pin 5 is the output pin - the amplified signal is removed from it. The output signal contains a constant and variable component. The DC component of the signal is undesirable - it cannot be supplied to the loudspeaker input, so a 220 µF capacitor is used to eliminate it.

Pin 7 is the bypass terminal. You can leave it unconnected or short it to ground through a capacitor to increase the stability of the amplifier.

Usage

  • After assembly and firmware, the device requires loading the configuration (using the utility).
  • When connected to USB, normal operation of the device is suspended and the queue of unsent messages is cleared.
  • If SMS sending fails, the device will try again after 2 minutes, then after 5, 10, 20, twice after 40 and then every 12 hours.
  • Once a call is received, it will be completed in 3 minutes.
  • The audible alarm sounds for 30 seconds.
  • The events “door opening”, “movement” and “lighting changes” are triggered no more often than once every 20 minutes.
  • If the device is not powered for more than 3 hours, the recorded temperature measurement history is reset.

Where can it be applied?

The scope of GSM signaling is very wide. It can be used not only as security for apartments, private houses, country houses or shops. Even in the simplest version of its manufacture, its functions are sufficient to notify the owner of any physical event.

For example, it is possible to install it on a garden watering system so that signals are sent when the water has run out. Or it can be used as a fire department - when the smoke and fire sensor is triggered, a call is made to the owner. It all depends on the type of sensors.


Various sensors

A GSM alarm is also good for protecting your car from theft or theft. In the first case, a pleasant bonus will be the ability to find the loss using radio direction finding of the phone.

Field tests

I apologize for the editing aesthetics.

Installation on the front door. The part of the structure on the right (directly on the door itself) is a magnet for triggering the reed switch

The device was installed at a place of permanent use (garage) 4 months ago. For enhanced testing purposes, the schedule function is not used (an SMS is sent for each event). On average, there are 5 SMS per day: two when entering the garage (the door opening sensor and light sensor are triggered), two when leaving and one “daily report”. Currently the batteries (3x AA) maintain a voltage of 4.1V when the modem is turned on.

The code itself:

here
/// GSM signaling with installation by call /// sensor on breakers // donat, https://money.yandex.ru/to/410012486954705 #include < EEPROM

.h> //// how is the modem connected?
//#include // if software //SoftwareSerial gsm(7, 8); // RX, TX #define gsm Serial
// if the hardware is in UNO //#define gsm Serial1 // if the hardware is in Leonardo #define LED 13 #define TELLNUMBER “ATD+70001112233;”
// number to which we will call #define SMSNUMBER "AT+CMGS=\"70001112233\"" // number to which we will send SMS #define TELMODE "70001112233" // number for arming #define SH1 A2 // loopback / /#define SH2 A3 #define pinBOOT 5 // BOOT or K leg on the modem byte mode = 0; // 0 - only enabled // 1 - armed // 2 - disarmed // when adding, do not forget to look at line 41 void setup() { delay(1000); //// !! so that nothing hangs when you turn on gsm.begin(9600); /// don't forget to specify the operating speed of the UART modem // Serial.begin(9600); pinMode(LED, OUTPUT); pinMode(pinBOOT, OUTPUT); /// BOOT leg on the modem pinMode(SH1, INPUT_PULLUP); /// stretch leg // pinMode(SH2, INPUT_PULLUP); /// stretch leg // read the mode from EEPROM mode = EEPROM
.read(0);
if (mode > 2) mode = 2; // check the value in eeprom // work on the modem delay(1000); digitalWrite(LED, HIGH); // temporarily turn on the ice digitalWrite(pinBOOT, LOW); /// turn on the modem // you need to wait until the modem turns on and connects to the network delay(2000); // while(gsm.find("STARTUP")); /// wait for a command from the modem gsm.println("ATE0"); // turn off echo while(1){ // wait for the modem to connect to the network gsm.println("AT+COPS?"); if (gsm.find("+COPS: 0")) break; digitalWrite(LED, LOW); // flash the LED delay(50); digitalWrite(LED, HIGH); delay(500); } //Serial.println("Modem OK"); digitalWrite(LED, LOW); // flash the LED delay(1500); digitalWrite(LED, HIGH); delay(250); digitalWrite(LED, LOW); } void loop() { if (mode == 1){ // if in security mode // check the sensors if (digitalRead(SH1)){ // if there is a break // call back gsm.println(TELLNUMBER); delay(2500); if (gsm.find("NO CARRIER")){ // looking for call reset, // disarming mode = 2; EEPROM
.write(0, mode);
} } } // if the security is disarmed if (mode == 2){ if (digitalRead(SH1)){ // check the sensors, turn on the LED digitalWrite(LED, HIGH); } else digitalWrite(LED, LOW); } // look for RING // if found, ask who it is and arm if(gsm.find("RING")){ // if found RING gsm.println("AT+CLIP=1"); // enable caller ID, while(1){ // in the loop if (gsm.find(TELMODE)){ // look for the phone number if found mode = 1; // change the EEPROM
.write(0, mode); // write it to eeprom break; // and exit } else{ // otherwise gsm.println("AT+CPAS"); // ask the modem status delay(100); if (gsm.find("+CPAS: 0")) break; // and if it is “ready”, we exit the loop } // if the call is in progress, returns +CPAS: 3 } // and move on gsm.println(“AT+CLIP=0”); // turn off Caller ID, delay(500); gsm.println("ATH0"); // reset the call digitalWrite(LED, LOW); // signal this delay(500); digitalWrite(LED, HIGH); delay(250); digitalWrite(LED, LOW); } }

Problems

During operation, the room temperature dropped from +10°C to -15°C and two problems were discovered.

  1. The PIR sensor used begins to give false alarms at low temperatures. At +5°C, use became completely impossible: the number of false alarms exceeded one per day. An attempt to replace the sensor with another one did not solve the problem, so now this sensor is temporarily disabled. It is not yet clear what to do with this.
  2. The temperature sensor built into the DS3231 at -10°C and below began to go crazy: it periodically produces random values, for example, “-84°C” or “+115°C”. Interestingly, the RTC works fine. At the moment it is not clear whether this is a problem specifically for my copy or not. I'm waiting for a second identical module to be checked; if the problem with it repeats, DS18B20 will be added to the device.

Otherwise the flight is normal.

GSM alarm system based on Arduino


One of the options for connecting Arduino to an alarm reed switch.
A more advanced option for making an alarm would be to use an Arduino controller with a GSM module. In this case, the signal sensors are connected to the microcomputer itself, and its program already controls the communication, sending messages or making information calls to the owner of the system.

A big plus of this design is the ability to control the security system via SMS, the main thing is to program the reaction to them in Arduino.

Key Features

Today, a lot of hardware platforms have already been presented, and there is also a wide variety of microcontrollers; they receive information from external sensors, then the data is processed and the signal is transmitted to the actuator. The Arduino platform greatly simplifies the performance of numerous tasks and has a truly large list of advantages compared to other similar devices. The main advantages include:

  1. Affordable price. The platform is distinguished by its low cost compared to other similar systems. But at the same time, it has the entire necessary set of functions to ensure complete security.
  2. Cross-platform. Arduino software can interface effectively with Linux, Windows, Macintosh-OSX.
  3. Simple programming process. In order to configure the microcontroller, the Processing programming environment is used. This option is perfect not only for a professional, but also for a user who does not yet have the skills to work with such devices.
  4. You can always upgrade the system. Thanks to special software and open source, you can adapt the security system to your own requirements, but in this case you need to have some skills. Arduino is highly reliable, and even the oldest models meet all modern requirements and provide reliable protection. As for new developments, there is an extensive list of functions and guarantees complete safety.

Top 6 most popular modules

The modules presented below are a popular product for installing autonomous alarm systems and other projects for transmitting a control signal through the networks of mobile operators.

A module is understood as a product consisting of a board and elements on it (including a component consisting of a chipset and a transceiver). The components are located under the cover in a single form factor (reminiscent of a processor for a computer motherboard). Wiring on the expansion board occurs through the end contact legs. Such a full-fledged board is called a module. If it has many other elements on it, it is sometimes called a shield.

Below we will list modules such as Neoway M590, A6 and A7, and others, and their characteristics will be presented.

SIM900

Developed by SIMCom Wireless Solution, the SIM900 module connects and communicates via the common UART physical data transfer protocol. Connection to a PC is made via a USB-UART converter.

The board allows you to work with messages and calls from the recipient in two-way mode.

Specification:

  1. Frequency range EGSM900, DCS1800, GSM850, PCS1900.
  2. Voltage 3.2-4.8 V.
  3. The current in idle mode is 450 mA.
  4. Maximum current – ​​2 A.
  5. Communication channel up to 14.4 kbit/s.
  6. Temperature range from -30 °C to +80 °C without distortion, and from -40 °C to +85 °C, with minor RF deviation, while maintaining performance.
  7. Weight 6.2 g.
  8. Dimensions 24 x 24 x 3 mm.

The component has modifications: 900B, 900D, 900TE-C, 900R 900X. Each modification has its own specifics. SIM900D is supplemented with a battery charging unit, and SIM900X introduces new energy saving modes, which allows the modules to be used in modern car tracking systems, security and industrial automation. All modifications of components can be found in a single SMT form factor, with solder end contacts. But the possibility of being in other form factors is not excluded.

SIM800L

The basis of the module is the SIM800L component with the implementation of data exchange via GSM and GPRS channels using duplex mode. A SIM card is installed in the module, there is a built-in antenna and an output for another antenna. Power is supplied to the board through a DC-DC voltage converter. It is also possible to connect to another power source. Connection interface – UART.

Specification:

  1. Quad-band cellular terminal.
  2. Voltage 3.8-4.2V.
  3. Standby current – ​​0.7 mA. Limit current – ​​500 mA.
  4. Slot
  5. Support 2G network.
  6. Temperature range from -30 °C to +75 °C.


GSM/GPRS module SIM800L (#1) - how to choose, connection, introduction to AT commands

A6

Shield A6 works in mobile networks and allows you to receive and transmit signals using GSM and GPRS. The module created by AI-THINKER several years ago has successfully proven itself and is popular in automation systems.

TTX A6:

  1. Quad-band cellular terminal.
  2. Supply voltage 5 V.
  3. The current in sleep mode is 3 mA.
  4. Standby current – ​​100 mA.
  5. Connection mode current – ​​500 mA.
  6. Peak load current – ​​2A.
  7. Connector
  8. GPRS speed during signal transmission is 42.8 Kbps.
  9. Temperature from -30 °C to +80 °C.

A6 modem

A7

The new A7 module differs from its predecessor in that it has built-in GPS. This solution allowed us to simplify the design of the board.

Main parameters:

  1. Quad-band cellular terminal.
  2. Voltage 3.3-4.6 V.
  3. Supply voltage 5V.
  4. 10 GPRS class: data channel 85.6 kbit/s.
  5. Jammer echo and noise.

GSMGPRS modem with GPS receiver AI-Thinker A7

Neoway M590

The module based on the Neoway M590 component allows you to receive calls, exchange data and messages. Has a UART connection interface.

Characteristics:

  1. Frequency range EGSM900, DCS1800.
  2. Grade 10
  3. Voltage 3.3-5 V.
  4. Peak current 2 A.
  5. Operating current 210 mA.
  6. Communication signal 3.3 V.
  7. Temperature from -40 °C to +80 °C.

When connecting the module to the controller, a 3.3V -> 5V converter is required.

GSM GPRS module SIM900

Based on the SIM900 module, we developed and successfully use the SIM900 GSM GPRS Shield as a module for connecting to Arduino UNO. Compared to other boards, the cost of this one is much more expensive, and it is equipped with many connectors and contacts. Among the main parameters:

  1. The board is connected to Arduino Mega and UNO.
  2. Four operating frequencies, as in other boards.
  3. Low power consumption 1.5 A in sleep mode.
  4. GPRS multi-slot class 10/8.
  5. Operating temperatures from -40°C to +85°C.

GSMGPRS shield SIM900, First look

Rating
( 1 rating, average 5 out of 5 )
Did you like the article? Share with friends:
For any suggestions regarding the site: [email protected]
Для любых предложений по сайту: [email protected]