Arduino SIM800L – Dial phone numbers & LASER Tripwire GSM Alarm project [DigitSpace.com]
Sponsored by: DigitSpace
Product used: SIM800L Module Replace SIM900A GSM GPRS 5V Serial with Antenna
Hello there and welcome to another tutorial sponsored by DigitSpace, and it’s about the SIM800L again, the previous article was about sending SMS/Text (Simple and sensor values) to your phone, but this time it’s about dialing phone numbers using the same module, and a little project which is a LASER tripwire GSM Alarm.
Make sure to check this tutorial about the module first: Send SMS/Text from Arduino using SIM800L GSM/GPRS Module [DigitSpace.com], and if you want to send and receive SMS between your Arduino and your phone make sure to check Send/Receive SMS using SIM800L with Arduino + DHT11/MLX90614 [DigitSpace.com]
So to sum up we gonna dial numbers, not make a full phone call, because this module doesn’t have pins for Speaker/Mic like the other version:
SIM800l module
HALT!! Please make sure that your SIM Card is unlocked (not protected by a pin code, you can do this by inserting it in your phone and disable the pin code) and that it has enough credit to be able to make a phone call/Send SMS depending on your mobile operator.
N.B: I’m powering the module using a 7.4V Li battery with a buck converter, it could be powered directly from the Arduino but it’s sketchy….
Test 1
So in the test #1 all we have to do is wire the module and dial a phone number using the Serial monitor of the Arduino IDE.
- The main command for dialing a number is “ATD+xxxxxxxxxx;” where the xx.. stand for your phone number including the country code.
- The other command is “ATH” to hang up/stop the phone call, if not used the call will end after a certain delay.
Wiring
This is the basic wiring of the module, and the Arduino is powered via USB, it could be powered with the battery too, but I’m in need of the Serial monitor to be able to send AT commands to the module.
Libraries
No external library is required for this, Software Serial, but it’s already with the Arduino default libraries.
Code
You can download the code from here or check below, this code is not something special, it just permits the communication between the module and the PC, you’ll be able to send commands to the module and check the feedback.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
/* This code can send data via serial to a module via UART and display on the serial monitor data sent by the module * It works with SIM800L and give the ability to send AT commands to test them * Refer to http://www.SurtrTech.com for more information */ #include <SoftwareSerial.h> SoftwareSerial sim800l(2, 3); // RX,TX for Arduino and for the module it's TXD RXD, they should be inverted void setup() { sim800l.begin(9600); //Module baude rate, this is on max, it depends on the version Serial.begin(9600); } void loop() { Serialcom(); } void Serialcom() { delay(500); while (Serial.available()) { sim800l.write(Serial.read());//Forward what Serial received to Software Serial Port } while(sim800l.available()) { Serial.write(sim800l.read());//Forward what Software Serial received to Serial Port } } |
Result
After wiring your module and plugging the Arduino board, you can first type just “AT” to check if the module and communication are working, then you can proceed with the ATD command.
After using the ATD command + the phone number press enter, the phone should start ringing.
ATH command is to hang up.
GSM tripwire Alarm Project
So the project is about a tripwire alarm which call your phone number whenever someone passes through it.
I’ve chosen a LASER + LDR, you can use anything you prefer to detect presence for example PIR, Doppler Radar, or some classic modules like proximity sensors HC-SR04, FC 51, Sharp IR… Whatever suits you.
KY-008 LASER module and LDR
Don’t forget to add a resistor to the LDR, I’ve used 1kO.
So as you know the LDR (Light Dependent Resistor) changes the value according to light, if there’s light it lowers the resistance, otherwise (when darker) it gets bigger, so when used with a resistor it will change the voltage value that we can read using the Arduino Analog Pin.
Wiring
So here as you can see the SIM module is powered with the battery, but for the rest they are powered by the Arduino plugged in the PC, you can of course power the Arduino using the battery all you have to do is add a wire between the 5V of the Source with the 5V of the Arduino.
Libraries
Just like above, no external one is needed.
Code
The code is meant to work without the Serial monitor, but I’ve add some functions and kept the wiring to use with Serial monitor and check the LDR value. Download the code here or check below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
/* This code works with SIM800L, LASER module and LDR for LASER GSM Tripwire Alarm * The LASER constantly lights up the LDR, and if someone passes by the value will drop * and it will trigger a phone call alerting the phone owner * Refer to http://www.SurtrTech.com for more details */ #include <SoftwareSerial.h> #define LDR A0 //Read the LDR value from the point where it meets the Resistor #define LASER 7 //LASER trigger pin int LDR_Value; SoftwareSerial sim800l(2, 3); // RX,TX for Arduino and for the module it's TXD RXD, they should be inverted void setup() { pinMode(LDR, INPUT); //Define pinModes pinMode(LASER, OUTPUT); Serial.begin(9600); //Start the Serial communication with the PC and SIM800L sim800l.begin(9600); digitalWrite(LASER,HIGH); //Put the LASER at high state delay(5000); } void loop() { LDR_Value=analogRead(LDR); //Constantly read and display the LDR value Serial.println(LDR_Value); delay(30); //To avoid false reading if (LDR_Value < 800) { //If someone passes through the value will drop, 800 is the threshold, you can chose whatever suits you, the serial monitor will help you sim800l.println("ATD+xxxxxxxxxxxxx;"); //The number to call don't forget to add the country code } } |
Result
The serial monitor is constantly displaying the LDR value and as you can see in the last few lines when I obstructed the LASER beam the value dropped significantly, you can use this test to set your threshold.
When the value dropped below the threshold, which mean something passed through the LASER, the Arduino automatically called the set phone number.
Well that’s all folks, thanks a lot to the video sponsor.
Categories
Yassine View All
Automation and Electrical Engineer, Electronics amateur trying to share my little projects.
3 thoughts on “Arduino SIM800L – Dial phone numbers & LASER Tripwire GSM Alarm project [DigitSpace.com]” Leave a comment ›