SMS Home Alarm System with PIR and GSM Modem

                                   Figure 1: SMS Home Alarm System with PIR and GSM Modem

GSM Modem

A GSM modem is a wireless modem that works with a GSM wireless network. GSM stands for Global System for Mobile communications, this architecture is used for mobile communication in most of the countries in the world. 

A wireless modem acts basically like the traditional dial-up modem, the main difference is that a dial-up modem sends and receives data through a fixed telephone line while a wireless modem sends and receives data through radio waves. Besides the dial-up connection, GSM modem can also be used for sending and receiving SMS which is also one of the key features of GSM modem.

The operation of a GSM modem requires a SIM (Subscriber Identity Module) card just like mobile phones to identify a subscriber to the cellular network and to store the subscriber information. Also they have IMEI (International Mobile Equipment Identity) number similar to mobile phones for their identification. 

GSM Connections

It is very easy to interface a GSM Modem to a PIC Microcontroller as most GSM modems have a serial interface. The USART serial input pin RX and TX of the microcontroller are connected to the TXD and RXD pins of the GSM Modem. Some GSM modems have PCMCIA Type II or USB interfaces. Figure 2 below shows a block diagram of a GSM module connected to USART module of a PIC Microcontroller.

GSM module connected to a PIC Microcontroller

Figure 2: GSM module connected to a PIC Microcontroller

NB: Depending on the GSM module used, a voltage level translator circuit may be needed to make the system work with a microcontroller. Microcontroller USART voltage level is 5V in most of the cases while most GSM/GPRS modems voltage level is about 2.8V – 3V, you need a voltage level translator circuit.

You can use any Logic Level Converter, like the SparkFun bi-directional Logic Level Converter which is a small device that safely steps down 5V signals to 3.3V AND steps up 3.3V to 5V at the same time. This level converter also works with 2.8V and 1.8V devices.

Figure 3: SparkFun bi-directional Logic Level Converter

A simple diodes/resistors network could do the job as well as shown on figure 4 below.

Three diode in series are used to drop down voltage of TX pin of microcontroller to to 2.9 volt (each diode drops 0.7V) which is in acceptable range for RXD pin of GSM module. Similarly a diode, a resistor and 5 volt source is used to increase voltage of TXD pin of GSM module to 5 volt which is logic high for RX pin of pic microcontroller.

Figure 4: A simple diodes/resistors voltage level translator circuit

>>> To learn more on Interfacing a GSM mode: Interfacing GSM Modem with PIC Microcontroller 

There are GSM boards on the market  that one can use to quickly interface with a PIC. For example the SmartGM862 Board from Mikroelekronika is one example of many boards. The SmartGM862 is a full-featured development tool for Telit GM862-QUAD GSM/GPRS module or the GM862-GPS version. It features GM862 module connector, voltage regulator, antenna holders, speaker and microphone screw terminals and more. DIP switch is provided for configuring UART communication lines with the target microcontroller. It can be connected to development boards via IDC10 connnector.

Connecting the SmartGM862 Board to EasyPIC7 V7 Development Board

Figure 5: Connecting the SmartGM862 Board to EasyPIC7 V7 Development Board

Passive InfraRed (PIR) Sensor

A Passive Infra Red sensor or commonly referred to as PIR is an electronic device which measures Infrared light radiating from objects in its area of coverage. Any motion is detected when an object of different temperature (temperature radiates Infrared energy) than the covered area passes through. All objects emit what is known as black body radiation, this Infrared energy is invisible to the human eyes but can be detected by Infrared sensors like the PIR. The PIR will detect the movement of a human, an animal or any moving object entering the monitored area because the infrared energy emitted from the intruder’s body, or whatever was moving is always going to be different than the ambient Infrared energy present in the area. Figure 5 below shows a PIR that you can use inside your house.

Figure 6: A PIR

PIR Connections

A PIR has three pins, the Vcc, the ground and the output pin. Connecting PIR sensors to a microcontroller is not difficult, the PIR acts as a digital input, so all you need to do is check for the pin to flip high (detected) or low (not detected). You’ll have to read your PIR specifications to before using it. Below are some specifications of a prototyping PIR as shown on figure 8 below:

  • Module Type : Sensor
  • Weight : 15.00g
  • Operation Level : Digital 5V
  • Power Supply : External 5V
  • Input Voltage : DC 4.5-20V
  • Static current : 50uA
  • Output signal : 0,3V or 5V (Output high when motion detected)
  • View Angle : 110 degree
  • Distance : max 7 m
  • Shunt for setting override trigger : H – Yes, L – No

Figure 7:  PIR Connection

Figure 8: Prototyping PIR

Home Alarm System Operation

The PIR can thus be used as a sensor to detect the presence of an intruder into the house.  Figure 4 below shows the SMS home Alarm system circuit diagram.

SMS home Alarm system circuit diagram

Figure 6: SMS home Alarm system circuit diagram

In this project, when a motion sensor (PIR) detects a movement of an intruder, an SMS will be sent to a predefined number which could be you or your security reaction company and if it is not disarmed within 30 seconds, a relay will be triggered to switch ON the siren or any other sound device.

When the device is turned on, it needs to be armed by pressing the push button then it will give you one minute to allow you to safely exit your home or sleep without triggering the alarm, within this minute, a status Green LED will blink. After that, the status LED will stay ON to notify you that the program is in the alarm mode. In alarm mode, the program will constantly monitors the input from the PIR. When motion is detected, the device will wait for 30 seconds, after this delay the device will send an SMS message to a predefined phone number stating: “Alarm!!  Intruder Detected in your House!!! Siren will be activated in few seconds.”.  Within this 30 seconds, the status LED will blink rapidly and you’ll have 30 seconds to disarm it by pressing the push button or the siren will be activated and stay on until you disarm it. The reason for this short delay before activating the siren is because it might be the owner of the house who might want to disarm the alarm, 30 seconds is given to reach the alarm and switch it off or disarm it.
Once the system is disarmed, you have to press the push button again to arm it and check if the status LED is ON.

MikroC Source Code

You can download the full project files (MikroC source code and Proteus Schematic design) below here. All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to unzip files).

MikroC Source Code: Home Alarm MikroC Project