Arduino security system (SIM CARD)

Build your own arduino security home system.

We are going to build together a arduino based security system. We will utilize motion detection sensors which is a very exciting field in security systems.

With a couple of components you can build this project as well and make your own arduino security system

Arduino motion detection

How are we goind to detect motion? But of course with a PIR sensor. PIR sensors are using IR radiation. There are 2 potentiometers on the module. One is for the sensitivity (distance from target) and the other is for adjusting the duration of the output (HIGH state in case of trigger)

Infrared sensor

The basic component for our project is the PIR motion sensor. In the photograph below you can see how the sensor looks.

Motion sensor

Underneeth the white plastic cover there is a IR sensor as you see in the following image.

arduino motion detection

The principle of the sensor is that captures the emmiting IR radiation and checks if there is any change in that value. In case it detects a value change it sends HIGH (5v) to the OUT pin, which we can connect to Arduino or the rest of the circuit.

There are two variable resistors on the sensor . We can adjust sensitivity and the time that the output will be HIGH.

There is a Jumper. That jumper allow us to choose whether we want a single pulse when activated or continuous pulses during the HIGH state in the output.

The project

Project is easy-medium. It will teach us how to use the PIR sensor. In combination with the GSM module we can create a complete system that will warn us by sending us a SMS to our mobile each time the alarm is triggered.

The list of materials that we need

  1. Arduino (any edition)
  2. PIR sensor
  3. LED
  4. Raster
  5. some jumper wires
  6. GSM module. I bought this from ebay and it’s supporting only asian networks. After some workaround, if upgraded this and now it works also with European networks 100%

*I found out (the hard way) that when you choose a GSM module you must be sure that is supports the network in your country. Most GSM modules from ebay that cost <10$ do NOT work with european networks.

So, either you will buy one that supports your GSM networks (whereever you are located) or… you can upgrade the firmware as i did and make it work!

For the upgrade i used an module serial to usb FTDI

arduino motion detection
FTDI Serial to USB

GSM module

You can find these kind of gsm modules everywhere in ebay. If you are not able to upgrade the SIM900 firmware, don’t buy from ebay unless you are Asian (works ok with asian gsm companies).

gsm module arduino

What about GSM Libraries?

Nop, you don’t have to use any library just old school serial communication between GSM modem and Arduino (RX/TX). We are using AT command set which we make a brief presentation below.

ΑΤ commands

There is a command set (AT commands) which we can use to communicate with the GSM modem. GSM has no memory, therefor the commands must be writer in setup() in order to setup the modem and in loop() if we want to send/receive messages or calls

AT–> By giving command AT we must receive OK. That means that communication is OK between modem and Arduino.

AT+CMGF=(Mode) (where Mode 1 or 0) With this command we define the modem mode as far the SMS types. 0 menas PDU and 1 is for text. For example AT+CMGF=1 should return OK.

AT+CMGW is the command where the message to be sent is saved. When we give this command to serial the character > is showed. After we write the message we must give as input the character  Ctrl+Z. The result will be an index that represents the stored message.

The message is stored to index 1. So, in order to actually send that message we need the command:


Make / Receive calls

We are going to have to use the command:


example ATD+346999999999, it will dial phone number 6999999999

To answer an incoming call we have to use the command:

ATA. When the modem rings with the ATA command it responds.

For more AT commands click here

How the security system works

As soon as the motion sensor detects motion, a LED is lit which indicates that the alarm is triggered. Next, the GSM module is activated and sends an SMS to a given number. The LED is turned off after a period of time we have set. Besides the SMS we could wanted to turn on a light for extra safety for a short period of time (10-15sec).

The circuit

Το GSM module may varies in the scheme from what you see in the video but the pins are connected exaclty like this (i couldn’t find another).

Attention! There is a small chance even if you do exactly as i do that your project don’t work. If that is the case try again!

This happens because when the GSM is sending a SMS it draws current up to 1Amp, so if you are powering the GSM modem with 5V of arduino, make sure you have 1A or more (1,5 best) available. Most USB ports have 1 or 1,5Amps max current output.

At the beginning of the video i connect the gsm module to my power supply just to show you the current that draws. You can attach to arduino 5v works just fine.

You can download to circuit and open it with Fritzing here (unzip it)

Fritzing circuit

The code

Here is the code for our project. We can utilize more inputs if we like to make the security system more complex. All we need is a OR between inputs that we check if they are HIGH.

int PIRValue, flag; // to ensure only one sms
int PIRSensorPin = 6;
int ledPin = 13;
void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(PIRSensorPin, INPUT);
void loop() {
  PIRValue = digitalRead(6);
  if(PIRValue==1 && flag==0)
  if (PIRValue == 0)
    digitalWrite(13, LOW);
void sendMessage()
  digitalWrite(13, HIGH);
  Serial.println("AT + CMGS =\"+300000000000\"");
  Serial.println("Alarm is triggered!");
  Serial.write(0x1a); // Sends a Ctrl+Z characted to declare end of sms
  Serial.println(); // sends enter
November 11, 2019

0 responses on "Arduino security system (SIM CARD)"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Σχεδιασμός © GetCert. Με επιφύλαξη παντός δικαιώματος.