Introduction: GSM Shield Home Alarm



The other day my father and I were discussing about the problems of living in a third world country. Because of the social inequality, there is little security on the streets. Also one major problem is that no one is secure, even the 1% richer, because there are know cases of robbers getting inside homes even on private neighbourhoods. We ended up thinking about putting a home security system in our house. The problem is those are very expensive and, in general, they just ring an alarm to scare potential thieves, but they don’t actually warn you in real-time that your house is being invaded. A complete system would be even more expensive. So I got the idea to make my own Arduino based home alarm. I just had to buy a GSM shield for the Arduino Uno, because all other parts I already had.

Step 1: The Parts

Picture of The Parts

For this project you will need:

  • Arduino Uno (Ebay);
  • GSM Shield (Ebay);
  • PIR sensor (Ebay);
  • An Arduino based buzzer (Ebay);
  • An alarm siren horn 12V(Ebay);
  • 12V power supply (Ebay);
  • Relay module (Ebay);
  • Keypad for the Arduino (Ebay);
  • A box;

Step 2: Connecting the Components

First you will place the GSM shield above the Arduino Uno, then you will need to solder the wires GND and VCC together from the two sensors, the buzzer and the relay module input. After that, you connect those soldered wires on the corresponding connector from the GSM shield. Next you will make a connector from the input / output signals from those parts, and the last thing will be to connect the keypad above the shield. It will be:

Arduino Uno / GSM shield pins:

  • Pin 0: unconnected;
  • Pin 1: unconnected;
  • Pin 2: unconnected (the GSM will use this pin);
  • Pin 3: unconnected (the GSM will use this pin);
  • Pin 4: last row from keypad (keypad pin 4 – from 8);
  • Pin 5: unconnected;
  • Pin 6: second column from keypad (keypad pin 6 – from 8);
  • Pin 7: third column from keypad (keypad pin 7 – from 8);
  • Pin 8: unconnected (the GSM will use this pin);
  • Pin 9: unconnected (the GSM will use this pin);
  • Pin 10: PIR sensor number 2 data;
  • Pin 11: siren horn signal (goes to the relay module input);
  • Pin 12: PIR sensor number 1 data;
  • Pin 13: buzzer signal input;

As it is possible to see, although the keypad has 8 pins, I just connected three (one rom and two columns, allowing two numbers to be read – 1×2 matrix), because this way I can make passwords using these three wires, and there is no need to use all the pins from the keypad. This is because once the movement sensor detects a person walking inside the room, the person will have just 5 seconds to deactivate the alarm, so there is not enough time for the thief to figure out the alarm code. Once the alarm is not disabled on the given time, the GSM shield will proceed to send SMS to you, or to call your phone. The Arduino was programmed to call and once you answer the phone, it will finnish the call. This way it will spare the credits from the mobile operator.

Of course, it is possible to get false readings from the sensor, or even the code can be buggy, so I put an option to disable the alarm just by sending an SMS text from my phone to the Arduino. Also another option you can make is to order the shield to send you one message a day to ensure you it is working correctly.

Step 3: The Code

Just download the code below and compile. It uses the Keypad.h and GSM.h libraries. As the Keypad.h is not standard with the Arduino, I put it to download here too. I suggest you test your setup by steps.

Step 4: Conclusion

Picture of Conclusion

Considering the code will make the Arduino Uno send SMS messages and call your phone in only five seconds after someone break into your house, I guess you will have plenty of time to call the police. Of course the siren horn will scare the thieves and they will run away taking whatever they can, but if you don’t use the siren, you will probably end up having them arrested. I hope this way you can have a more secure home. If you have some good idea please leave a comment, that I will improve my system here. Hope you guys find this article useful.


noel.kuck (author)2016-11-09

Could you advise the sketch changes necessary to offer a multiple digit password? Mine isn't working. Thank you.

AashishG6 (author)2016-07-15

will u please send a circuit diagram its little bit difficult without it

jayt18 (author)AashishG62016-10-13

I would love to make this. Can you please send me the schematic too?

benhur.goncalves (author)jayt182016-10-21

Sorry guys, I dont have a schematic for this one. Just follow these instructions:

  • Pin 0: unconnected;
  • Pin 1: unconnected;
  • Pin 2: unconnected (the GSM will use this pin);
  • Pin 3: unconnected (the GSM will use this pin);
  • Pin 4: last row from keypad (keypad pin 4 – from 8);
  • Pin 5: unconnected;
  • Pin 6: second column from keypad (keypad pin 6 – from 8);
  • Pin 7: third column from keypad (keypad pin 7 – from 8);
  • Pin 8: unconnected (the GSM will use this pin);
  • Pin 9: unconnected (the GSM will use this pin);
  • Pin 10: PIR sensor number 2 data;
  • Pin 11: siren horn signal (goes to the relay module input);
  • Pin 12: PIR sensor number 1 data;
  • Pin 13: buzzer signal input;
hilmi emred (author)2016-04-21

Send me some shematic or detail photos how you connected the parts please

diyanamzah (author)hilmi emred2016-06-27

hey hilmi, have you got the schematic? can you send to me too?

diyanamzah (author)2016-06-27

Hi, can you send us the circuit diagram? I'm doing this project for my practical training and it will be so helpful if you upload the circuit diagram. Thank you

DS49 (author)2016-05-10

could u send us images of the whole connection circuit design,cause we have to show the judges in our school hows the circuit

ممحمود2 made it! (author)2016-02-12

Please help me I have shown this error

TarekB3 (author)2015-10-26

este e o link

benhur.goncalves (author)TarekB32015-10-26

sim entendi. seu problema é no codigo ou em como conectou o motor. vai testando por partes. esquece o codigo pronto do cara e testa como acionar o motor primeiro com algum exemplo especifico da web.. ou da plataforma mesmo. coloca no google "arduino servo motor" ou "arduino servo library", depois testa só a leitura do sensor sonar... pega exemplo da plataforma ou procura no google "arduino sonar example" ou "arduino sonar library", ai quando estiver um e outro funcionando separadamente, voce junta os codigos. Faz isso... vai por partes

TarekB3 (author)2015-10-26

ola amigo, tudo bem?

comprei um arduino uno, o mega kit, quero fazer um projeto simples para começar, quero fazer abrir e fechar ao ativar o sensor ultrasonico. tem um cara que fez tutorial do projeto, mais tentei muitas vezes e nao funciona, ou seja nao gira o motor. quando vou aos exemplos do arduino e testo o codigo blink funciona bem, ou seja o codigo se carrega bem.

vou colar o codigo para dar uma olhada se pude por favor

#define pingTrig 6

#define pingEcho 7

#include <servo.h>

Servo myservo;

void setup()


pinMode(pingTrig, OUTPUT);

pinMode(pingEcho, INPUT);



void loop()


long duration, inches, cm;

digitalWrite(pingTrig, LOW);


digitalWrite(pingTrig, HIGH);


digitalWrite(pingTrig, LOW);

duration = pulseIn(pingEcho, HIGH);

cm = duration / 29 / 2;

if (cm < 10 ) {



} else {





o projeto no ytube chama-se

Home Made Motion Activated Trash Can.

TarekB3 (author)2015-10-01

ola amigo

posso comprar as parts de ebay e mandar para meu endereço em porto alegre?? tenho que pagar para alfandega??

benhur.goncalves (author)TarekB32015-10-01

Pode sim. O produto chega normal se o vendedor for confiável e tiver varias vendas. A alfandega taxa meio aleatoriamente e na maioria das vezes pelo valor declarado pelo vendedor. Agora com a crise estão taxando quase qualquer coisa. Na maioria das vezes da so 30 reais por pacote. Pede pro vendedor declarar 5 dolares como valor da mercadoria e de boa. Pacotes muito pequenos eles não taxam.

noel.kuck (author)2015-09-16

Thanks for the continual hand-holding. The keypad works fine. Altough a bit confusing, I believe that I connected the keypad according to your instructions. KP#4 to Arduino#4, KP#6 to Arduino#6, and KP#7 to Arduino#7. Sensors to Arduino #10&12, VCC & GND. I am using the Seeed GPRS Shield, and it has worked for me before.

Search Google for which pins your gsm shield uses, because I think different shields use different pins. Mine uses pins 2, 3 and 8 and 13 I think. Try google and putting the sensors and keypad on different pins to see which ones cause malfunction

noel.kuck (author)2015-09-15

I get SMS Messages Sender on the Serial port, and the GSM is on and flashing. That is as far as I have been able to go. How would you suggest the best way to test the keypad and the GSM shield separately?

To test the keypad use it without the GSM shield. Plug it directly to pins 12 to 5, or 7 to 0 from the Arduino Uno and use the example "Multikey.ino" from the library. Set the line rowPins[ROWS] = {13,11,10,9}; colPins[COLS] = {8,7,6,5}; correctly (or the inverse depending on how you plug) then open the serial and press the buttons. When with the GSM shield you wont be able to use all 8 pins from the keypad because the GSM use some of them (I think the pins 0,1,2 and 3 wont be free to use), but you dont actually need all 8 pins. For example, to use one button as a password you only need 1 row and 1 column = 2 pins. For 2 different numbers password you will need 3 pins and so on. For my example I used 3 pins, but just the button "0" as password. But could have used 0 and #.

noel.kuck (author)2015-09-15

getting no response from anything

Fisrt compile the GSM example to test your board, a then the keypad example (that come with the libraries). Test it by parts, will be easier. Post your results here for me to help you.

noel.kuck (author)2015-09-15

ok, sketch loaded. where/how do i arm the device?

You have to turn the GSM shield on by pressing one of its buttons. The first from up to down. One led will turn on (the blue and then the green). Did that?

noel.kuck (author)2015-09-14

I'm getting error messages when trying to compile:

Arduino: 1.6.5 (Mac OS X), Board: "Arduino Uno"

Using library keypad in folder: /Users/noelkuck1/Documents/Arduino/libraries/libraries/keypad (legacy)

Using library GSM in folder: /Applications/

/Applications/ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/ -I/Applications/ -I/Users/noelkuck1/Documents/Arduino/libraries/libraries/keypad -I/Applications/ /var/folders/m6/_g9ydm_s5tv0m9v51tfpbtt80000gp/T/build6521207385780413459.tmp/GSM_Alarm.cpp -o /var/folders/m6/_g9ydm_s5tv0m9v51tfpbtt80000gp/T/build6521207385780413459.tmp/GSM_Alarm.cpp.o

In file included from /Applications/,

from /Applications/,

from /Applications/,

from GSM_Alarm.ino:2:

/Applications/ error: redeclaration of 'IDLE'



In file included from /Users/noelkuck1/Documents/Arduino/libraries/libraries/keypad/Keypad.h:36:0,

from GSM_Alarm.ino:1:

/Users/noelkuck1/Documents/Arduino/libraries/libraries/keypad/utility/Key.h:46:15: note: previous declaration 'KeyState IDLE'

typedef enum{ IDLE, PRESSED, HOLD, RELEASED } KeyState;


Error compiling.

I updated my version of above. Thanks for this question. Very relevant.

Did you download my version of Keypad library or did you download on GitHub? Because the original Keypad.h and Keypad.cpp have the name IDLE and that collide with the IDLE from the GSM.h. I had the same problem, but I just renamed all IDLE from Keypad to KEY_IDLE and that was solved.

TarekB3 (author)2015-09-13

thanks. were R u from?

benhur.goncalves (author)TarekB32015-09-13


TarekB3 (author)benhur.goncalves2015-09-13

Blza. Eu sou árabe, mais moro no Brasil. Porto Alegre.

benhur.goncalves (author)TarekB32015-09-14

Sou de S. J. do Rio Preto - SP. Aqui tem bastante árabe também. Dizem que aí o povo é muito educado.

TarekB3 (author)benhur.goncalves2015-09-14

Queria saber se o PIR do arduino detecta bem o movimento como os sensores de presença normais

benhur.goncalves (author)TarekB32015-09-14

Sim. Na verdade é o mesmo sensor. Só que quando uma empresa de segurança instala, eles colocam naquela caixinha de prender na parede e fica mais bonito, mas é a mesma coisa.

TarekB3 (author)benhur.goncalves2015-09-14

Que bom
Minha intenção é fazer sistema de segurança parecido e fazer ele conectar via wifi a internet e monitorar via Internet, que tipo de câmeras posso usar com o arduino e as câmeras podem ser monitoras via Internet?.?

benhur.goncalves (author)TarekB32015-09-14

Por exemplo, o sistema do arduino te avisa no celular por SMS e ligação se alguem entrar na sua casa e o sensor de movimento detectar, ai vc acessa o servidor do DVR e ve quem está la. Se for alarme falso, vc manda um SMS pro número do shield e ele desarma o alarme.

benhur.goncalves (author)TarekB32015-09-14

Nesse caso sugiro voce comprar um sistema DVR com 4 cameras (ou mais) no mercadolivre. O sistema do arduino pode ser separado, é o que estou fazendo em casa. O DVR transmite o video para a internet num servidor gratuito que voce pode configurar e acessar com senha de onde estiver.

TarekB3 (author)benhur.goncalves2015-09-14

Sim, geralmente tem comunidade árabe em todo o Brasil, vc tem muita experiência com arduino?

benhur.goncalves (author)TarekB32015-09-14

Sim, tenho bastante. Dá uma olhada nos meus Instructables na minha página do perfil desse site. Quase qualquer coisa que você me perguntar de arduino eu já devo ter mexido. Hehe.

irun4fundotca (author)2015-09-14

Well done great project using off the shelf parts!

Did you post your box design anywhere?

looks like a good 3d printed solution

Thanks! But the box I already had. I just made the holes with a drill of the same size as the sensor and the antenna. XD

About This Instructable




More by benhur.goncalves:GSM Shield Home AlarmArduino Chess Clock - Multi-game BoxArduino Pedometer Watch, With Temperature, Altitude and Compass!
Add instructable to: