Introduction: GSM Security Alarm (SIM800L SMS)

About: Electronic Design Freelancer. Technical Author. Hardware βeta Tester. Product Reviewer» International

Here's a simple GSM Security Switch project which's infact a cellular based alert system configured to send an SMS in response to a security switch action. When the security sensor switch input recognize an event, the system sends a customized alert message to a predefined cell phone number.

Step 1: Key Hardware

This simple GSM Security Switch project needs only an Arduino Nano microcontroller and a SIM800L GSM modem.Following is the schematic drawing of the GSM Security Switch built around Arduino Nano (V3) and SIM800L module. As you can see from the schematic drawing, the system needs a stabilized and clean 5V/1A (min) dc power supply for proper performance. The microcontroller board (Nano_V3) runs on the 5V dc supply and the modem (SIM800L) gets around 4.3V dc.

When the hardware setup is ready, just upload the given sketch to Arduino, power up the system, and take a trial run. Don't forget to insert a valid micro-SIM card in the slot before powering the system up. Normally the SIM card registers automatically to the home network within a couple of seconds, and the onboard LED indicator of the SIM800L module will blink once every 2-3 seconds (not continuously) when it has successfully registered to the network.

Step 2: Schematic Drawing

In the schematic a micro-usb connector (USB_IN) is used as the dc input port. The red lamp (LED1) is the ‘power on’ indicator and the yellow lamp (LED2) is the system ‘status’ indicator. First two resistors (R1-R2) are current-limiters, and rest of them (R3-R5) forms a tricky logic-level translator setup. Also see one buffer capacitor (C1) in the VCC line of SIM800L module. A gentle grounding of the sensor port (SW_IN) input (Pin 1) will trigger the alert generator instantly.

Note that my breadboard prototype was tested with a 5VDC/1A-rated mobile phone USB charger. A noteworthy fact is that the SIM800L itself demands a dc supply input between 3.4 and 4.4 volts (at least 1A), and the module used here comes without an integrated voltage regulator. This cries for a healthy power supply because if the power source can't keep up, the module will shut down/restart in the middle of the service.

Step 3: Arduino Sketch

There are so many featured Arduino Libraries (for example, the one from Cristian Steib - steibkhriz@gmail.com) you can try but the sketch included here ,without any such exceptional libraries, will work fine for this application. Here, the communication between Arduino and SIM800L goes over a SoftwareSerial, and uses standard AT commands. So simply use this sketch, after changing the recipient’s phone number to the one you want to send the alert message to.

/*
* GSM Security Switch (v1.1) * Hardware: Arduino Nano V3 & SIM800L GSM Module * Arduino IDE: 1.6.9 * T.K.Hareendran / 2020 *
/Connect TXD pin of the GSM module to D10 
//Connect the RXD pin of the GSM module to D11 
//SMS Trigger Input (Sense Pin) connected to D9 (Active LOW) - see text
#include 
SoftwareSerial smsSerial(10,11); // RX and TX pins to communicate with GSM module
#define sense_pin 9
#define status_pin 12
String number ="0123456789"; // Recipient's number - see text
void setup()
{
   
  Serial.begin(9600);
  smsSerial.begin(9600);
   pinMode(sense_pin,INPUT);
   digitalWrite(sense_pin,HIGH); // Enable internal pull-up
   
   }
void loop()
{
  if (smsSerial.available())
  {
    digitalWrite(status_pin,HIGH); // Enable status indicator if serial is available
  }
   //Sends an sms everytime sense_pin sets off
   if (digitalRead(sense_pin)==LOW) // Check if the sense_pin sets off
   {
     smsSerial.println("AT+CMGF=1"); // Set to Text Mode
      delay(150);
      smsSerial.println("AT+CMGS=\"+91"+number+"\""); // Specify recipient's number in international format
      delay(150);
      smsSerial.print("Warning!Intrusion"); // Enter the alert message 
      delay(150);
      smsSerial.write((byte)0x1A); // End of message character 0x1A (CTRL+Z)
      delay(50);
      smsSerial.println();
   }
  
}

Step 4: Power Supply Notes

For true portable applications, you can use a standard 1S (3.6V/3.7V) Li-Ion battery as the power source. SIM800L module works happily from a 3.6V Li-Ion battery but you should add a dc-dc boost converter module (3V to 5V) to power Arduino with the required 5V dc supply. See the proposed hardware diagram shown below. A bit of googling will hopefully get you more about these popular components ( I got mine from Amazon).

Moreover, the sensor input port have the ability to interface with various sensors, such as reed switches, photo-resistors/diodes, thermostats, etc allowing for considerable customization of the security system. This also adds a number of capabilities including the recognition and response to momentary inputs from a laser trip wire/impact sensor, and/or from a door/gate sensor.

Step 5: Quick Test Instructions

1. Ensure that the breadboard prototype is intact & there's no loose connection

2. Insert a valid and UNLOCKED SIM card into the socket of SIM800L module

3. Power up the breadboad from a 2AMP/5V (+/- 2%) DC REGULATED POWER SUPPLY, AND WAIT FOR A FEW SECONDS...

4. LED in the SIM800L module starts flashing fast, and WHEN REGISTERED TO A NETWORK, LED STARTS BLINKING ONCE IN 3 SECONDS!

5. If everything up to this point is okay, then do push the test button, and wait for a while.... (ELSE RECHECK SIM & POWER SUPPLY)

6. You can see the alert SMS in the recipient's phone ( code programmed with number +91 9446582139 ---- change it to an EFY number) .....DONE!!!

See the quick test video https://youtu.be/3FdUEW1myXM