ARDUINO Projects

  • Alarm system

    A simple security system but so much effectively using a sim card module "sim800l" to connect with outside world, send an SMS messages or make a phone call to Warning you, in this example I will use one laser diode as security line if anyone try to bloke the laser the Arduino will send a message to the phone number as you program it.
    As you can see in the photo below the module it has a serial communication port with speed of 9600 bit/s, the power consumption of the module 200Mha so it needs an external power supply the Arduino cannot power it up, also the power range of the module it's from 4.2v to 3.2, so if you connect it to 5v power supply you will burn it up, the serial port work with 3.3v level any 5v signal will destroy the serial port or the module itself, So I suggest to connect sim800l to raspberry pi or Arduino pro mini 3.3v to avoid.
    Post

    AT command

    This use AT command protocol for communication, the commands below these the main command you need to use.
    • AT the module return OK
    • AT+CLIP=1 To get the number of the incoming call
    • AT+COPS? returns the name of the operator network
    • AT+CMGF=1 set the module to SMS mode
    • AT+CMGS=+491xxxxxx To send SMS from SIM800
    • ATD+491xxxxxx; To call the mobile number
    • ATH To hang up a ringing call
    • AT+CMGR=1 To read the first SMS from the inbox
    • AT+CMGL=ALL To read all the SMS messages from the inbox
    • AT+CMGD=1 To delete the first message from the inbox
    • AT+CMGD=2 To delete the second message from the inbox
    Download the datasheet of the module to know all the AT command:- AT_COMMAND

    Demonstration

    First connect the serial port of the module to Arduino pin number 3 as RX and 4 as TX because I use the software serial library then connect 10K resistor to VCC and to LDR sensor then to analog pin A0, after that bring a laser pointer and aim it to the sensor to get high-value reading, in the end, connect an led to analog pin A1 to light every time the laser blocking..

    Post

    Arduino code
    #include <SoftwareSerial.h>
    String sms="Alarm";
    int laser=A0;
    SoftwareSerial sim800l(3,4); // RX, TX
    void setup()
    { 
      pinMode(A1,OUTPUT);
      sim800l.begin(9600);
      Serial.begin(9600);
      Serial.println("Ready for sending sms");  
      delay(10000); 
      //========================= 
    } 
    void loop()
    {
     int sensor=analogRead(laser);
     Serial.println(sensor);
     if(sensor<=450)
     {
      digitalWrite(A1,LOW);
      Send_sms();
     }
     else{
      digitalWrite(A1,HIGH);
     }
    }
    void Send_sms()
    {
      Serial.println("Sending Text...");
      sim800l.print("AT+CMGF=1\r"); // Set the shield to SMS mode
      delay(250);
      sim800l.print("AT+CMGS=\"your_number\"\r");delay(200);
       delay(250);
       sim800l.print("\r");
       sim800l.print(sms);
       sim800l.print("\r"); //the content of the message
      delay(250);
      sim800l.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet)
      delay(100);
      sim800l.println();
      Serial.println("Text Sent.");
      Serial.println(sms);
    }