Haaiz Sir,
I have a question. I'm using a Siemens TC35i to send en receive SMS
but on the test program where do you get de "R" and "K" value for the response of the shield ?
Can I use the same condition for a TC35i ?
Because when I test my tc35i with your code, I get a "GSM not working" for all 4 commands.
Hi,
First of all, it's not the way to work on any new module. You should first try to do the basics . Don't run mu code yet just send the AT command to your module and get the response.
If you got succeeded in receiving the response then move forward. Let me know when you get the response n then we will discuss it further.
Thanks.
Hi ,
well thank u Syed for every thing ,
but I have little problem in my project and I hope to help me ,
my project is smart home security .
Im using Icomsat v1.1 GSM and arduino uno and RIP,Gas,and water sensors and Relay
meaning I want my project send and receive SMS.
Windows 7 , Arduino IDE 1.6.0
Im using AT commend .
its sending very good but it take about 2minuts to receive sms and excute it .
this is my cod >>
#define _SS_MAX_RX_BUFF 256 //RX BUFFER SIZE
#include
char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(4, 6);
int Buzzer = 13;
int x = 0;
int y = 0;
float z =0;
int RIP_sensor = 12;
int Room2 = 11 ;
int Room1 = 7 ;
int Home_light = 8;
int water_sensor = 0;
int Gas_sensor = 0;
float Tem_sensor = 0;
float temp =0.0;
String textForGAS ;
String textForRIP ;
String textForWATER;
String textForTAM ;
void setup()
{
Serial.begin(19200);
// set up the digital pins to control
pinMode(RIP_sensor, INPUT);
pinMode(Buzzer, OUTPUT);
pinMode(Room1, OUTPUT);
pinMode(Room2, OUTPUT);
pinMode(Home_light, OUTPUT);
digitalWrite(Buzzer, LOW);
digitalWrite(Room1, LOW);
digitalWrite(Room2, LOW);
digitalWrite(Home_light, LOW);
// wake up the GSM shield
SIM900.begin(19200);
delay(20000); // give time to log on to network.
SIM900.print("AT+CMGF=1r"); // set SMS mode to text
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
Serial.println("Ready...");
}
void sendSMS(String message)
{
SIM900.print("AT+CMGF=1r");
delay(100);
SIM900.println("AT + CMGS = "+967737704074"");
delay(100);
SIM900.println(message);
delay(100);
SIM900.println((char)26);
delay(100);
SIM900.println();
delay(5000);
}
void loop()
{
//If a character comes in from the cellular module...
if (SIM900.available())
{
inchar = SIM900.read();
Serial.println(inchar);
if (inchar == '#')
{
delay(10);
inchar = SIM900.read();
if (inchar == 'a')
{
delay(10);
inchar = SIM900.read();
if (inchar == '0')
{
digitalWrite(Home_light, HIGH);
}
else if (inchar == '1')
{
digitalWrite(Home_light, LOW);
}
delay(10);
inchar = SIM900.read();
if (inchar == 'b')
{
inchar = SIM900.read();
if (inchar == '0')
{
digitalWrite(Room1, HIGH);
}
else if (inchar == '1')
{
digitalWrite(Room1, LOW);
}
delay(10);
inchar = SIM900.read();
if (inchar == 'c')
{
inchar = SIM900.read();
if (inchar == '0')
{
digitalWrite(Room2, HIGH);
}
else if (inchar == '1')
{
digitalWrite(Room2, LOW);
}
delay(10);
}
}
SIM900.println("AT+CMGD=1,4"); // delete all SMS
}
}
}
// put your main code here, to run repeatedly:
Gas_sensor = (analogRead(A0));
water_sensor = (analogRead(A1));
Tem_sensor = (analogRead(A2));
temp = Tem_sensor * 0.48828125;
//program for GAS sensor
if (temp > 70.0)
{
textForTAM = "Alarm ! The degree of Tamperture is :n ";
textForTAM.concat(temp);
textForTAM = textForTAM +"C";
digitalWrite(Buzzer, HIGH);
Serial.println(textForTAM);
sendSMS(textForGAS);
delay(1000);
do {
z = (analogRead(A0));
} while (z >= 141.312);
}
else {
digitalWrite(Buzzer, LOW);
delay(1000);
}
//program for GAS sensor
if (Gas_sensor > 500)
{
textForGAS = "Alarm ! there is Gas by rate :n ";
textForGAS.concat(Gas_sensor);
digitalWrite(Buzzer, HIGH);
Serial.println(textForGAS);
sendSMS(textForGAS);
delay(1000);
do {
x = (analogRead(A0));
} while (x >= 499);
}
else {
digitalWrite(Buzzer, LOW);
delay(1000);
}
//program for Water sensor
if (water_sensor > 830)
{
digitalWrite(Buzzer, HIGH);
delay(60);
digitalWrite(Buzzer, LOW);
delay(40);
textForWATER = "Warnning ! n Tank is Empty ! tourn on the Dynamo ";
textForWATER.concat(water_sensor);
Serial.println(textForWATER);
sendSMS(textForWATER);
delay(1000);
do {
y = (analogRead(A1));
} while (y >= 829);
}
else if (water_sensor < 175 )
{
digitalWrite(Buzzer, HIGH);
delay(60);
digitalWrite(Buzzer, LOW);
delay(40);
textForWATER = "Warrning ! n Tank is Full ! tourn off the Dynamo ";
textForWATER.concat(water_sensor);
Serial.println(textForWATER);
sendSMS(textForWATER);
delay(1000);
do {
y = (analogRead(A1));
}
while (y <= 176);
}
else {
digitalWrite(Buzzer, LOW);
delay(1000);
}
}
thank you
sir you have code for arduino mega 2560 received SMS?
This same code also works on Arduino mega 2560.
Hi,
I am not receiving any numbers what i am sending is their any solution for this
Receiving sms is quite tricky, it normally doesn't work in first attempt so give it some time and test it again and again. Moreover, don't test the whole code instead test it step by step. Try AT commands and then check their response and then move on.
Thank you very much for this wonderful code, It helps me a lot! I have a question Sir. When I send text message from my mobile phone it reads for the first time but when I send another message only the mobile number appeared. Thank you Sir more power.
Great program! I am working with sim300 and atmega8 arduino. The foll. is a program to send an sms. But the sms does not get sent. It just displays on the serial monitor. The place from where i got the program uses a peizo sensor to send sms but i dont want to use it. Pls check and suggest changes that i should make to send an SMS everytime reset is pressed. i.e (The program is run) My current rogram is:-
void setup()
{
Serial.begin(9600); // the GPRS baud rate
delay(2500);
Serial.println("AT"); //To check if GSM module is working
delay(2000);
Serial.println("AT+CMGF=1"); // set the SMS mode to text
delay(1500);
}
void loop()
{
delay(1500);
Serial.print("AT+CMGS=");
Serial.write("34");
Serial.print("+919408955901");
Serial.write("34");
delay(1500);
Serial.println("This is a sms from BCG"); //this is the message to be sent
delay(1500);
Serial.write("26"); //Ascii code of ctrl+z to send the message
while(1);
{
}
}
THANK YOU!!!!!!!!!
Hello Sir,
Thank you for the code, its great...
Is there any command which can display all my sms that are stored in the SIM card? or any particular message which is at 'n'th position?
Please respond
Thank you
Hi,
Yeah it has this small bug, I have tested it. Will remove this bug soon. Thanks for mentioning.
Regards.
Hi,
Use this command Serial.print("AT+CMGL=\"ALL\"\r"); and it will display all the messages stored in the SIM card. Also use Responsefunction in order to get that response.
Thanks.
If its receving the message then it means your code is correct and working and if its taaking time in receving this message then its network fault. Attach antenna with your GSM shield and it will perform quicker.
thank you very much.. small modifications, but it works.
Hi, First I send sms it receives and displays, but since the second onwards, it receives but does not display any text whatsoever.Help me. Thanks.
After printing your message, clear all the buffers and assign initial values to all integers. Make a function to do this say clear_everything() and call it just after last serial.println(). It will work for sure.
Hello I write Function for clear the buffs but not Working again when i send second sms not Display my function is
void Clear(){
char RcvdMsg[200] = " ";
int RcvdCheck = 0;
int RcvdConf = 0;
int index = 0;
int RcvdEnd = 0;
char MsgMob[15];
char MsgTxt[50];
int MsgLength = 0;
}
thank you sir for this tutorial , it worked with my arduino uno and GSM module
but i need to control something (let's say LED connected on digital pin 13) , so i added that piece of code in the void loop function
if ( MsgTxt== "ON") {digitalWrite(13,HIGH);}
else digitalWrite(13,LOW);
but it isn't working
can you help me please ? :)
Yeah others have also talked about this problem in comments, give me a day and I will make the correction andwill upload the new code.
It should work, give it some time and do some tweaking. You must be making some minor mistake. I have a plan to upload such tutorial on which I will be controlling LEDs with GSM so will do that soon. Till then you have to wait. :)
plzzz uploAD new code
The code has been updated. Now it will work fine :)
Where is the updated COde?
The above code is updated one.
Dear Syed Zain Nasir,
first thank you for the sketch it is really great.
i just want to ask what are the serial letters "K" & "R" that you check in Response() function, because i always get "GSM not found". I use Arduino Leonardo.
Regards
Hi sir, badly need your help. the updated code you said is still not working. can you pls recheck it? it does not display the second message. only the first sent message is working fine. Thank you for the immediate response.
Hi sir, your updated codes still does not work. can you please recheck? It appears that the first message is printed but the second message only displays the mobile number of the first sender. Please update it as soon as possible.
Yeah I have the same problem! Only the SMS body appears first time, it shows nothing when I send another SMS even though it receives the message.
sir i got the gsm response well, but when i try to run the whole code I get the following errors. how can I solve this.?
SIM900.ino: In function 'void RecSMS()':
SIM900.ino:93:19: error: 'amp' was not declared in this scope
SIM900.ino:93:22: error: expected ')' before ';' token
SIM900.ino:93:24: error: 'amp' was not declared in this scope
SIM900.ino:93:45: error: expected ';' before ')' token
SIM900.ino:94:22: error: expected ')' before ';' token
SIM900.ino:94:45: error: expected ';' before ')' token
SIM900.ino:95:22: error: expected ')' before ';' token
SIM900.ino:95:45: error: expected ';' before ')' token
SIM900.ino:109:18: error: 'lt' was not declared in this scope
SIM900.ino:109:23: error: expected ')' before ';' token
SIM900.ino:109:24: error: name lookup of 'x' changed for ISO 'for' scoping [-fpermissive]
SIM900.ino:109:24: note: (if you use '-fpermissive' G++ will accept your code)
SIM900.ino:109:27: error: expected ';' before ')' token
SIM900.ino:116:19: error: 'lt' was not declared in this scope
SIM900.ino:116:31: error: expected ')' before ';' token
SIM900.ino:116:35: error: expected ';' before ')' token
Error compiling.
sir i got the gsm response well, but when i try to run the whole code I get the following errors. how can I solve this.?
SIM900.ino: In function 'void RecSMS()':
SIM900.ino:93:19: error: 'amp' was not declared in this scope
SIM900.ino:93:22: error: expected ')' before ';' token
SIM900.ino:93:24: error: 'amp' was not declared in this scope
SIM900.ino:93:45: error: expected ';' before ')' token
SIM900.ino:94:22: error: expected ')' before ';' token
SIM900.ino:94:45: error: expected ';' before ')' token
SIM900.ino:95:22: error: expected ')' before ';' token
SIM900.ino:95:45: error: expected ';' before ')' token
SIM900.ino:109:18: error: 'lt' was not declared in this scope
SIM900.ino:109:23: error: expected ')' before ';' token
SIM900.ino:109:24: error: name lookup of 'x' changed for ISO 'for' scoping [-fpermissive]
SIM900.ino:109:24: note: (if you use '-fpermissive' G++ will accept your code)
SIM900.ino:109:27: error: expected ';' before ')' token
SIM900.ino:116:19: error: 'lt' was not declared in this scope
SIM900.ino:116:31: error: expected ')' before ';' token
SIM900.ino:116:35: error: expected ';' before ')' token
Error compiling.
I have used Arduino Mega 2560 , SIM900a (SIMCom) and on running your code I always get
"GSM not Found" message for all 4 commands.
Expecting your help!
I have used Arduino Mega 2560 , SIM900a (SIMCom) and on running your code I always get
“GSM not Found” message for all 4 commands.
Expecting your help!
Hi,
Check yourpinconnectionsand andif they are correct then increase the delay before sending first command. Few modules are slow to response.
Thanks.
AOA how r u sir?
Sir please help me in my project if you can.. sir i need complete arduino code for electronic notice board.
my project is that simple text msg from your mobile to arduino kit n arduino display that msg on LCD 16*2 lcd. plz help me :( i m really very worried about it:(
my mob no:0334-8473040
Hi Syed,
When i use this code it works fine the first message i send the arduino, however each message after this skips the +CMT check so no message is displayed?
Thanks for you time
Andy
Hi, if you have already solved the problem I appologize, but amp should be replaced by & (ampersand).
Hi Sr.
I have the same problem with arduino uno, the first 4 commands always display "GSM not found", can you tell me why or send me a copy of your sketch where this has been corrected.
Thanks in advance
Regards
Jose
Hi Sir,
Am trying to receive sms with SIM900 and Arduino UNO but when i have send a message to sim900,l serial monitor display
+CMTI: "SM"=1
value of SM increase as to number of times i send sms to SIM900
i have use following code :
#include
SoftwareSerial gsm(7, 8);
char incoming_char=0;
void setup()
{
Serial.begin(9600); // for serial monitor
gsm.begin(2400); // for GSM shield
delay(20000); // give time to log on to network.
gsm.println("ATE0\r");
delay(100);
gsm.println("AT\r");
delay(100);
gsm.println("AT+CMGF=1\r");
delay(100);
gsm.println("AT+CNMI=0,0,0,0,0\r");
delay(100);
gsm.println("AT+CNMI=2,2,0,0,0\r");
delay(100);
Serial.println("GSM READY");
}
void loop()
{
if(gsm.available() >0)
{
incoming_char=gsm.read(); //Get the character from the cellular serial port.
Serial.println(incoming_char); //Print the incoming character to the terminal.
}
}
Please help me out '
Thank You.
Hi,
Send me message on skype, will check it out.
Thanks.
Sir,
Still it can only read the first message only. Please help me in reading the upcoming messages also.
Thanks in advance.
thanks a lot for your tutorial..can you post a similar post regarding web server..recieving data and storing it on a server...thank you....
Think you for your tutorial, its very GOOd (y)
Hi Syed,
How are u? I am testing your code, what i want to do is read the Imei number. When I test your code, I could read char by char, but i cant read a hole phrase. How can I do that?
Can you give me a hand please?
Thank you very much
Jose Luis
Hey. I'm having the same problem. did you figure out the problem?
In this code, I am not reading it character by character. I am saving it in Array so from that arracy you can get the IMEI number. Need more help then add me on skype.
Hello Syed,
This is really great and helped me a lot!
However, I have several GSM modules and some work with this code, others do not (even with the same setup). I'm really stuck on why the other modules give very strange outputs (big '?' characters as though it were initialized on the wrong baud rate). I've tried initializing the rx pin as low (digitalWrite(rxPin, LOW)) which only allows me to confirm that something has been written to the SIM card (sim.available() > 0). So I'm under the impression that my tx pin works, but something is happening during the rx transfer. I tried changing inverse_logic to true by declaring SoftwareSerial(rxPin, txPin, true). But this has also not helped.
All of this hangup occurs when I call your Response() routine. On the working GSM modules (with the same setup mind you), the commands initialize as OK, on the others, they simply say GSM not found.
I have attached a sample output. The first numbers are Serial.print(sim.available()), then I try to print the data char from Response to the Serial.
Do you have any suggestions?
Thank you! These are great tutorials.
Hmmm it happens to me as well when I try different modules sometimes they didn't work. So what I do is I simply change the delay time. Some gsm modules are slow so they respond slowly. In these cases you need to increase the delay. So my suggestion is to try 1500 n them 2000 value in delay.
Thanks.
what can i do if i don't want to receive new sms message notifications when im reading the serial port???
Hi
It is a very nice piece of cod and very useful.
I think that can be used on my project but is come :
SIM900.ino: In function ‘void RecSMS()’:
SIM900.ino:93:19: error: ‘amp’ was not declared in this scope
SIM900.ino:93:22: error: expected ‘)’ before ‘;’ token
SIM900.ino:93:24: error: ‘amp’ was not declared in this scope
SIM900.ino:93:45: error: expected ‘;’ before ‘)’ token..............
I understood that you have already corrected the cod and I will like to tested and see if can be integrated. So plaese if is not to much send the corrected code at mmedocean@gmai.com
All the best and thanks in advance
Hi,
I have used the code as it. I just had change the position where we extract phone number. so for the first message it works fine and from the it displays
Mobile Number is: +27630894756
Message Text: Www.engineeringprojects.com
and the second time
Mobile Number is: +27630894756
Message Text:
===
[Code hidden]
May you please help to find what i have missed.
Big thanks for this post! It'll help me a lot in my current project.
Would be nice if it was possible to copy the source code 1 to 1.
At the moment it has html tags in it like & and <...
Cheers Paul
Thanks for mentioning and sure I will correct them. Cheers !!!
I have created a function to clear all the buffers and it is working. thank you very much.
I have created a function to clear all the buffers and it is working. thank you very much.
could you pls share the function to clear cause on mine does not work
void Clear()
{
strcpy(RcvdMsg,"");
RcvdCheck = 0;
RcvdConf = 0;
index = 0;
RcvdEnd = 0;
strcpy(MsgMob,"");
strcpy(MsgTxt,"");
MsgLength = 0;
}
Please if you are displaying on the lcd may please share the code i want check some thing.
thanks it worked
My project is mini But project is that type of one lamp is control (on, off) through sms.I have taken one GSM Module Sim900a and one Arduino uno R3. Sir how to interface and GSM module with Arduino uno R3. And programming code. Sir Plz help me.
You can buy the project code from our shop. Its just of $20 or add me on Skype and we will discuss it.
Thanks.
#include
#include
static const int RXPin = 4, TXPin = 3;
static const int GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(9600);
ss.begin(GPSBaud);
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0)
if (gps.encode(ss.read()))
displayInfo();
if (millis() > 10000 && gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
while(true);
}
}
void displayInfo()
{
Serial.print(F("Location: "));
if (gps.location.isValid())
{
Serial.print(gps.location.lat(),4);
Serial.print(F(","));
Serial.print(gps.location.lng(),4);
}
else
{
Serial.print(F("INVALID"));
}
Serial.println();
}
void Sendsms()
{
Serial.println("AT+CMGF=1\r\n");
delay(5000);
Serial.print("AT+CMGS=\"+923339383046");
Serial.print("\"\r\n");
delay(5000);
Serial.print(F("Location: "));
Serial.write(0x1A);
while(3);
}
Sir.
This is my code Gps get coordinates correctly but doesn't send properly throuh GSM module (Sim900a).help me in this code. At sherhasan78@gmail.com.
#include
#include
static const int RXPin = 4, TXPin = 3;
static const int GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(9600);
ss.begin(GPSBaud);
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0)
if (gps.encode(ss.read()))
displayInfo();
if (millis() > 10000 && gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
while(true);
}
}
void displayInfo()
{
Serial.print(F("Location: "));
if (gps.location.isValid())
{
Serial.print(gps.location.lat(),4);
Serial.print(F(","));
Serial.print(gps.location.lng(),4);
}
else
{
Serial.print(F("INVALID"));
}
Serial.println();
}
void Sendsms()
{
Serial.println("AT+CMGF=1\r\n");
delay(5000);
Serial.print("AT+CMGS=\"+923339383046");
Serial.print("\"\r\n");
delay(5000);
Serial.print(F("Location: "));
Serial.write(0x1A);
while(3);
}
GPS Coordinates doesn't send through GSM module(Sim900a) why sir help me in this code. At sherhasan78@gmail.com
hello sir,
it would be great if you post the code for getting the message and sender number from received output i got what you explained in the points but i was not able to code it.so, please it would be helpful for my project if you post the code.
regards
sagar
what about the setup and void loops, i cant run without it, i m unable to receive message .
Hi,
Bro you need to buy it from our shop.
Thanks.
Hi Mr Syed Zain Nasir, powerful your explanation. I’m a young programmer. I start focus some my programming in AT command (GSM module, interface with computer…). I very interested on that particular part of the programming and wish to master it. Unfortunately I not get documentation on it. Please can you help me to provide some documention? Please me I used CCS compiler software to write programs. I start start learn ADUINO but I was in face in a particular problem. I remark that we most used xBoard(AVR dev Board) which is not available in how country. And also ARDUINO is just program ATMEGA microcontroller and not other types of microcontrollers such as 16fxx, 18fxxx…Thus, this discourage me to program with ARDUINO. Please sir I will very happy I you send me the documentation on AT command, serial communication RS232, GSM module.
I see the example that your show. It is very powerfull… .
Thank in advance…
Cordially Arthur
Hello i want to find out if there is a way the gsm module can reply the sender when it gets a text?
yeah it can be done. Add me on Skype and we will discuss it in detail.
Sir i want to recieve a message, if the message is from the right number then i gsm module should reply "hellow" can you help me to sort my problem. gsm module is sim800l.
Dear Syed Zain Nasir sir.. is it possible to move the robot in all 4 directions using GSM module and arduino uno?? plzz sir suggest me. thanks
hey! can you please help me out. i need your code for my college project purpose. my project is based on iot and its topic is solid waste management. and as a college student i can't afford to buy your code for $20. please can you provide me your code for free. if you want i can send you my project details. it will become very important for me... please!!!
Can I ask help on my code sir?(Code which i formed from various codes on the forums about parsing sms, with the aid of your guide/steps sir)
I am confused, as to where should I put my Clear function. It gives me nothing on my serial monitor everytime I'll put the clear function in my sketch. But if clear function is not present, there is a result in the serial monitor, though the output prints the same on my after my 1st msg.
Ouput is something like:
AT+CMGF =1
OK
AT+CNMI = 1,2,0,0,0
OK
Success!
Received from: +639********** // I just hid my number here for privacy
Message Text : 12345678
Received from: +639********** // the same output
Message Text : 12345678 // I sent another message:87654321, yet the prev. one displayed. its Clearing problem..
Success!
Received from : +6392**********
Message Text : 12345678
***
Your help would be greatly appreciated. I just dont know how to clear it.
I can be contacted at mi.lenmuelt@gmail.com.
how to get your code???
You have to buy it from the shop.
hi zain
how to send sms on multiple recipients .? is this possible or not i have sim900A module.
Hi, sir. Im sharif here. Im working with circuit simulation in Proteus software. How can we send commands to arduino in the circuit simulation,sir? i have attached the virtual terminal and it shows AT+CNMI=2,2,0,0,0
AT+CMGF=1. Im doing project on load switching controlled by sending sms. That means whenever i send a command sms from any phone to the gsm module, it will send the message to the arduino and the output will be 16x2 lcd which indicating either the load is on or not and also to relays. I am using sim 900A in my project. TQ
Sir i have done my project on smart surveillance system using motion sensor and gsm when pir sensor detects someone it text and if i give reply it does not call me otherwise it will call till now it works fine but i want add program that if i send D so it will deactivate means not to text and call and if i send A it will sense again and call and text me what changes can be made in my programming plz help my programming is as under
#include
SoftwareSerial SIM900(7, 8);
char inchar; // Will hold the incoming character from the GSM shield
int x,y,m,n;
String textForSMS;
int motion = 4;
int infrared = 5;
int fflag = 0; // feedback flag. for ackonowledgment message
int mflag = 0; // message flag
// for timing
int interval= 60 ; // in secs
// Tracks the time since last event fired
unsigned long previousMillis=0;
unsigned long int previoussecs = 0;
unsigned long int currentsecs = 0;
unsigned long currentMillis = 0;
int relay = 13;
void setup()
{
SIM900.begin(19200);
Serial.begin(9600);
// delay(20000); // give time to log on to network.
Serial.println(" logging time completed!");
randomSeed(analogRead(0));
pinMode(motion, INPUT);
pinMode(infrared, INPUT);
digitalWrite(infrared, HIGH);
digitalWrite(motion, HIGH);
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
// gsm modem settings
SIM900.print("AT+CMGF=1\r"); // set SMS mode to text
delay(1000);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(1000);
SIM900.println("AT+CMGD=1,4"); // delete all SMS
delay(5000);
Serial.println("Ready...");
}
void sendSMS(String message)
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = \"+923339322283\""); // recipient's mobile number, in international format
delay(100);
SIM900.println(message); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
}
// to call someone
void callSomeone()
{
SIM900.println("ATD + +923339322283;"); //
delay(100);
SIM900.println();
delay(10000); // wait for 10 seconds...
// SIM900.println("ATH"); // hang up
}
void loop()
{
//while((SIM900.available() == 0)&& (digitalRead(motion) == LOW ) && (digitalRead(infrared)== HIGH ) ) ; // ORIGINAL
while((SIM900.available() == 0)&& (digitalRead(motion) == HIGH) && (digitalRead(infrared)== HIGH ) )
{
if (fflag == 1 )
{
// Get snapshot of time
currentMillis = millis();
currentsecs = currentMillis / 1000;
// How much time has passed, accounting for rollover with subtraction!
if ((unsigned long)(currentsecs - previoussecs) >= interval) {
Serial.println("calling...");
callSomeone(); // call someone
delay(1000);
fflag = 0 ;
digitalWrite(infrared, HIGH);
previoussecs = currentsecs;
} else
Serial.println(currentsecs);
}
// Serial.println(currentsecs);
delay(1000);
}
if((SIM900.available() >0) && (fflag == 1))
{
inchar=SIM900.read();
Serial.println(inchar);
delay(20);
if (inchar == 'V')
{
fflag = 0;
digitalWrite(relay, HIGH);
Serial.println("acknowledgment msg received");
delay(15000);
digitalWrite(relay, LOW);
}
}
// if(digitalRead(infrared) == LOW)
if((digitalRead(infrared) == LOW)&& ( fflag == 0))
{
textForSMS = "\nIntruder detected on infrared sensor\n kindly send the acknowledgment message V";
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent.");
digitalWrite(infrared, HIGH); // new line
fflag = 1;
delay(10000);
currentMillis = millis();
currentsecs = currentMillis / 1000;
previoussecs = currentsecs;
}
if((digitalRead(motion) == LOW)&& ( fflag == 0))
{
textForSMS = "\nIntruder detected on motion sensor\n kindly send the acknowledgment message V";
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent.");
digitalWrite(motion, HIGH); // new line
fflag = 1;
delay(10000);
currentMillis = millis();
currentsecs = currentMillis / 1000;
previoussecs = currentsecs;
}
}
Actually i need one help from u,While i missed-call to that particular GSM number then only i want to receive massage from GSM,Do u have any sollution for this problem then please help me....!
Sir, I am unable to receive SMS through my GSM 900a module whenever I send msg from my mobile to gsm module I just don't get the output whereas I am able to send msg from gsm to mobile which works perfectly. please explain what is possible issue I am making a project on automatic water pump on/off through gsm.
You should buy this code from our shop, it will solve your problem.
can you send it's buy link
and will it work with A7 GPS,GSM module
Hi! How can I buy this code? Because when I click into the link, It opens a page that doesnt found.
Thanks.
Hi,
The link was broken and I have corrected it. It's working now.
Thanks for mentioning.
bonjour
c'est toujours possible d'avoir le code?
Hey
I was trying to make some project by arduino and I want to send location from gps while requested only .i would love u to guide me on it
Hi David, I am trying to get a SIM800L + PIC12F1840 to switch of a relay by 1). Sending a sms from my mobile to SM800L e.g. "System Off/On" or 2). Switching Off/On relay by using the DTMF functionality of the SIM 800L e.g 1 or On and 0 for Off. All works well with ARDUINO but I am struggling with the PIC micro. Would you be able to help with the code and at what cost. Thanking you in advance.