Hello friends, today's post as the name suggests is about how to send SMS with Arduino UNO and SIM900D using AT Commands. There are different types of SIM900D modules available in the market, so it doesn't matter which module you are using. All SIM900D modules work at AT commands basically so today I am going to show you how to send an SMS via AT commands without using any Arduino library. You should first read the AT commands manual which will give you an idea about AT commands. AT commands are special sets of commands which are used for communicating with SIM900 module. Using these AT commands we let our GSM work for us. Like if you want to send SMS then there's a specific AT command for sending the SMS similarly if you want to change the PIN code for your GSM module then you have a different AT command. So, there are lots of AT commands available. We can interface this GSM module with any microcontroller like PIC Microcontroller or 8051 Microcontroller but here I have interfaced it with an Arduino board. You should also check How to Send SMS with PIC Microcontroller if you wanna use PIC Microcontroller instead of Arduino board.
You must also check GSM Library for Proteus, using this library you can easily simulate your GSM module in Proteus ISIS. Moreover, also have a look at Send SMS with Sim900D in Proteus ISIS in which I have designed a simulation of SMS sending in Proteus ISIS.
First of all, connect Arduino UNO with SIM900D module, which isn't much difficult. If you have the module in hand then the first thing you need to do is to power it up and wait for the module to get connected.
Usually, an LED is placed on the SIM900D module which keeps on blinking. If it's blinking fast, it means the modules haven't yet captured the signal. When the module captures the signal then the LED keeps on blinking but at lower speed.
Now find the TX and RX pins of your SIM900D module and connect the TX of module with RX of Arduino UNO, which is pin # 0 and similarly RX of module with TX of Arduino UNO, which is pin # 1.
The module, which I have used for my project is shown in the below figure, with labelled pin configurations and if you want to buy it in Pakistan then click here.
One other thing mentioned in above figure is pKey, connect it with ground.
Once your connections are ready, then upload the below sketch in your Arduino UNO and start sending messages.
void setup()
{
Serial.begin(9600);
}
void loop()
{
delay(1200);
Serial.print("AT");
delay(1200);
bool bOK = false;
while (Serial.available() > 0)
{
char inChar = (char)Serial.read();
bOK = true;
}
if(bOK)
{
index = 0;
Serial.println();
Serial.println("AT+CMGF=1"); // sets the SMS mode to text
delay(100);
delay(1200);
bool bOK = false;
while (Serial.available() > 0) {
//Serial.write(Serial.read());
char inChar = (char)Serial.read();
bOK = true;
}
if(bOK)
{
Serial.println();
Serial.print("AT+CMGS=""); // send the SMS number
Serial.print("+923004772379");
Serial.println(""");
delay(1000);
Serial.print("A new post is created by Zain."); // SMS body
delay(500);
Serial.write(0x1A);
Serial.write(0x0D);
Serial.write(0x0A);
}
}
}
Change the mobile number with the number, on which you want to send the SMS, I have written mine.
You should also change the body of the SMS and can write anything you wanna send as an SMS.
The AT commands are required to send the SMS. I have added the comments in front of these commands but still if you get into any trouble, ask in comments.
pKey is a trigger for starting GSM shield, you need to send a LOW pulse on it for 2 to 3 seconds and the GSM will get on. Code is quite self explanatory, we are sending AT commands to send sms using GSM shield. Let me know where you are having problems. Thanks.
i send the low pulse rate to pkey for 2 to 3 second but my GSM shield will turn off after 2 to 3 seconds. and tell me that how to check the conectivity of GSM and arduino. i think their is a problem with conectivity. i did not recieve message on cell phone
First of all, let me know that you are using the same gsm shield. In some gsm shields, pkey needs to remain grounded. So try this as well. As the connectivity is concerned, you need to make sure that ground of gsm and arduino should be connected.
Moreover, check the tx and rx pins connectivity using multimeter.
Thanks.
its not working .....
what i should choose the library bc your library file is not mentioned..
After compiling it gives error like bellow...
Sim900_Arduino:11: error: stray '\' in program
Sim900_Arduino:11: error: stray '\' in program
Sim900_Arduino:24: error: stray '\' in program
Sim900_Arduino:24: error: stray '\' in program
Sim900_Arduino:36: error: stray '\' in program
Sim900_Arduino:36: error: stray '\' in program
Sim900_Arduino:36: error: stray '\' in program
Sim900_Arduino:36: error: stray '\' in program
Sim900_Arduino:37: error: stray '\' in program
Sim900_Arduino:37: error: integer constant is too large for 'long' type
Sim900_Arduino:37: error: stray '\' in program
Sim900_Arduino:38: error: stray '\' in program
Sim900_Arduino:38: error: stray '\' in program
Sim900_Arduino:38: error: stray '\' in program
Sim900_Arduino:38: error: stray '\' in program
Sim900_Arduino:40: error: stray '\' in program
Sim900_Arduino:40: error: stray '\' in program
Sim900_Arduino.ino: In function 'void loop()':
Sim900_Arduino:11: error: 'u201cAT' was not declared in this scope
Sim900_Arduino:22: error: 'index' was not declared in this scope
Sim900_Arduino:24: error: 'CMGF' was not declared in this scope
Sim900_Arduino:36: error: 'CMGS' was not declared in this scope
Sim900_Arduino:36: error: 'u201d' was not declared in this scope
Sim900_Arduino:37: error: 'u201c' was not declared in this scope
Sim900_Arduino:38: error: expected `)' before 'u201d'
Sim900_Arduino:40: error: 'u201cA' was not declared in this scope
when i copied program in arduino software the it display error like
"sketch_jan07a:8: error: stray '\' in program"
so what it indicate
pls let me know,,
Thanks,
Zain, can't thank you enough for this code. I've been at this for the last three weeks and have had only bad luck - sometimes my SIM board used to conk off, on other occasions standard GSM codes would not run. Today's the day when things are finally running and a big impasse has been broken. Thanks a lot for posting this code as open source to help out us newbies. :-)
Sir Kindly tell me why this error masg is coming when i verify this code in software .And how can i solve it.
SendSMS.ino: In function 'void loop()':
SendSMS.ino:19:1: error: 'index' was not declared in this scope
Error compiling.
I am getting like this in serial monitor :
ATAT
AT+CMGF=1
AT+CMGS="+9194xxxxxxx"
motor is on
AT
AT+CMGF=1
ATATATATAT
AT+CMGF=1
AT+CMGS="+9194xxxxxx"
motor is on
AT
AT+CMGF=1
ATATATATAT
AT+CMGF=1
AT+CMGS="+9194xxxxxxx"
motor is on
But iam not getting any sms to mobile.please do reply.
Hy, i am new in arduino. Can you explain me what means these lines of code :
Serial.write(0x1A);
Serial.write(0x0D);
Serial.write(0x0A);
I can't understand you explication(i know i'm stupid):The text mentioned in blue color are all AT commands, which are required to send the SMS. I have added the comments infront of these commands but still if you get into any trouble, ask in comments.
Thank you.
Serial.write(0x1A);
Serial.write(0x0D);
Serial.write(0x0A);
Sir.what does the last 3 codes mean??I am using arduino uno and sim900..But this code not send the sms.
Hello sir , i am facing a problem when i upload this program in my arduino uno .
Repeatedly AT is being displayed in the serial monitor . looks something like this ATATATATAT.......and so on.
Thanks for sharing the code,
how to fix the error
unknown escape sequence: '40'
occurs in the following command
Serial.print(" AT+CMGS=\ "); // send the SMS number
how to fix this error as well
Error compiling
core.a(main.cpp.o): In function `main':
C:\Program Files\Arduino\hardware\arduino\cores\arduino/main.cpp:40: undefined reference to `setup'
Sir,
I'm new commer for arduino.but i want make home securite system with my arduino and sim 900 .
I want make some warning input(heat,micro swtch,ect......) to arduino ,sim900 through sms ,call to my mobil and send from mobil to sim900,arduino get some action through arduino
Please help me sir
Have you schematic same like this
I will hope your help sir
Thankyou............m.
I am getting the foll. errors. PLEASE solve my problem. I can send u a copy of my program if u want me to via mail.
sketch_mar25b.ino:8:1: error: stray '\' in program
sketch_mar25b.ino:8:1: error: stray '\' in program
sketch_mar25b.ino:10:1: error: stray '\' in program
sketch_mar25b.ino:10:1: error: stray '\' in program
sketch_mar25b.ino:17:1: error: stray '\' in program
sketch_mar25b.ino:17:1: error: stray '\' in program
sketch_mar25b.ino:17:1: error: stray '\' in program
sketch_mar25b.ino:18:1: error: stray '\' in program
sketch_mar25b.ino:18:1: error: stray '\' in program
sketch_mar25b.ino:19:1: error: stray '\' in program
sketch_mar25b.ino:19:1: error: stray '\' in program
sketch_mar25b.ino:19:1: error: stray '\' in program
sketch_mar25b.ino: In function 'void setup()':
sketch_mar25b.ino:8:17: error: 'u201cAT' was not declared in this scope
sketch_mar25b.ino:10:25: error: 'CMGF' was not declared in this scope
sketch_mar25b.ino: In function 'void loop()':
sketch_mar25b.ino:17:15: error: 'u201cAT' was not declared in this scope
sketch_mar25b.ino:17:23: error: 'CMGS' was not declared in this scope
sketch_mar25b.ino:17:30: error: 'u201d' was not declared in this scope
sketch_mar25b.ino:18:15: error: 'u201c' was not declared in this scope
sketch_mar25b.ino:19:24: error: expected ')' before 'u201c'
Thank u for a prompt reply. The errors i have mentioned above exist even after replacing the "". the main errors are restated
sketch_mar25b.ino: In function ‘void setup()':
sketch_mar25b.ino:8:17: error: ‘u201cAT’ was not declared in this scope
sketch_mar25b.ino:10:25: error: ‘CMGF’ was not declared in this scope
sketch_mar25b.ino: In function ‘void loop()':
I can send u copy of my program if u can provide me with ur email ID or i can write the whole program here itself in the comments.
hey! am really sorry to ask this question as it might not be that relevant but i need instant help on this!!!!!!!
PROB:- THE NETWORK LED OF MY SIM300 IS NOT BLINKING. I TRIED 3-4 SIMCARDS OF DIFFERENT OPERATORS BUT STILL NOT WORKING. PLEASE HELP ON THIS ASAP!!!!!!
The LED starts to glow but remains ON throughout. Does not blink. Does it still mean that my module is burnt because the LED does turn ON and remains ON all time.
Arduino: 1.5.7 (Windows 7), Board: "Arduino Uno"
gpsop18.ino: In function 'void loop()':
gpsop18.ino:96:1: error: 'boolbOK' was not declared in this scope
gpsop18.ino:100:1: error: 'bOK' was not declared in this scope
gpsop18.ino:102:4: error: 'bOK' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
hello
I need to help me
I have project in university
i am used ardunio uno with sim900
if i am connected them open sim900 but without send sms
i try your code and still have problem
GSM_GPRSLibrary_SMS.ino:35:1: error: stray '\' in program
GSM_GPRSLibrary_SMS.ino:35:1: error: stray '\' in program
GSM_GPRSLibrary_SMS.ino:35:1: error: stray '\' in program
GSM_GPRSLibrary_SMS.ino:35:1: error: stray '\' in program
GSM_GPRSLibrary_SMS.ino: In function 'void loop()':
GSM_GPRSLibrary_SMS.ino:19:1: error: 'index' was not declared in this scope
GSM_GPRSLibrary_SMS.ino:35:17: error: 'u201c' was not declared in this scope
Error compiling.
how can solve problem ?
hellow, i created a code to send sms they work fine, but the problem is i want to send the same text to more that one number so i have a function accepting the number, sadly the text wont reach some number. I read somewhere that i need to check the status of availability of gsm before giving it another command. can you help me how to do it using AT command as i find it hard to work with gsm libraries in arduino as per my gsm configuration and connection
Hi MS,
May I have your complete code? As I am still new with Arduino. I have tried to figure out Zain's code based on the comments, but still it doesnt work.
Really need your kind help.
Thank you.
we have same module of sim900D. After making all the connection as mentioned above the red and yellow led continuously glow but the green Led is not glowing what does it mean?
i have the same module of sim900D .after making all the connections with Arduino mega 2560 .the LED and yellow LED are continuously glowing while green LED in not on what does is mean? .
Thanx
Hi friends
i am moni from delhi First of all, connect Arduino UNO with SIM900D module, which isn’t much difficult. If you have the module in hand then first thing available in the market, so it doesn’t matter which module you are using.
thanks you
i am ravindra dwivedi from delhi mohan garden
hi friends- i am using arduino uno this is very veneficial and i trust for arduino uno because i solve the big to big my problam with arduino uno
Some people think of the entire arduino board as a microcontroller, but this is inaccurate. The arduino board actually is a specially designed circuit board for programming and prototyping with .
on serial monitor I am getting this
AT.
AT
AT+CMGF=1
AT+CMGS="+923*********"
Zain.
AT
AT+CMGF=1
AT+CMGS="+923**********"
A new post is created by Zain.
AT
AT+CMGF=1
but not receiving any sms..
Can you please show us your code, because we tried this code (compiled and uploaded) but serial monitor isn't working fine. It is showing ATATATATATATATA over and over.
Regards
Maryam
I am Neville from Sri Lanka. I purchased a Neoway M590 gsm gprs module through aliexpress. Impossible to send any sms with the gsm module connected to arduino UNO. Do you have any experience with this gsm module? I feel that a special software is needed for this module. They sent some software but was in chinese. Other gsm modules are above US$20 and this module is only US$8. Nothing works for this module.
Hi,
I haven't worked on this module, but I would love to place my hands over it. So, add me on skype and I will check it out. My Skype id is "theenggprojects".
Thanks.
is it true this code ?
void SendMessage()
{
float intensite = ((5.0 / 1024) * analogRead(A3) * 5);
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"40427343\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
delay(100);
mySerial.print("Tension=");
mySerial.print(volt); // voltage
mySerial.println(" V");
mySerial.print("Courant=");
mySerial.print(intensite); // current
mySerial.println(" A");
mySerial.print("Ensol.=");
mySerial.print(ensol); // ensoleillement
mySerial.println("W/m^2 ");
mySerial.print("Temperature=");
mySerial.print(temp); // temperature
mySerial.print((char)223);
mySerial.println("C");
//mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to recieve a live SMS
delay(1000);
}
Hi,
I am using arduino Uno and GSM SIM 900a module to send a text msg or to call a number,but unable to do so.
I checked the modem using RS-232 by sending AT commands,it works fine and sends OK.But the problem is that when I try to send msg or call using arduino, it fails.It doesn't send any msg or call.I don't know what is the problem?
I know that the GSM module and network is okay as both the power and network leds behave the way they should.But can't send any text msg/call using arduino.
I have made only 3 connections between the two i.e. Tx(arduino)->Rx(GSM) and vice-versa and common gnd to both and used an external 12V adapter to power GSM module.
Please help me in finding out where I am going wrong.
I would be extremely thankful to you.
Hi Zain,
I am very beginner to IOT projects , my task is send and receive messages through arduino uno with GSM shield.
But,I don't know how to pass mobile number/mail id through arduino code and i tried basic GSM send/receive example codes it is not connected to GSM & it is not displaying the "GSM not connected" message also.
Please help me and reply me early as possible.
Hi Zain,
Is it possible to use Neoway M590 in replacement for the GSM board you used for the code? I'm experimenting an alarm utilizing GSM GPS with SW-420 vibration sensor. Many Thanks!
No, you have to design a new code because this one will only work with SIM900 module. If you need the code for your project then add me on Skype and we will discuss it in detail. My Skype id is theenggprojects.
Thanks.
Hi!
thank you for your help,Could you make a new project about the GPS by NEO M6 through SIM 900a ' sms by arduino uno.
beside,i added your skype ID and hope your acceptance from you as soon as possible.
thanks a lot.
Hello Syed Zain Nasir
I'd like to help Neville from Sri Lanka with M590.
Could you send him my e-mail: koyaan@op.pl,
or send me his e-mail, please
Marek
hi syed,this is divya. Iam working with microduino. I have stacked microduino core +and microduino bt .i trying to develop a point to point and multihop communication using Bluetooth for my masters research. One of my Phd studentd suggested that it can be done with AT commands within the program. I need to help...!!! please
hello Mr Syed
I'm totally new with arduino - working on it for my final project
so the GSM code it little bit difficult
anyways - how do i declare the index=0;
by putting int index=0; , its not declaring the " Int "
this is the error
(
C:\Users\H00272752\Desktop\LEvel 8\PRJ DSG\GSM\libraries---\GSMSHIELD\examples\GSM_GPRSLibrary_AT\GSM_GPRSLibrary_AT.ino: In function 'void loop()':
GSM_GPRSLibrary_AT:19: error: 'Int' was not declared in this scope
Int index = 0;
^
exit status 1
'Int' was not declared in this scope
)
could you help please
I got the idea of sending SMS to a mobile number using GSM/GPRS interface with Arduino. I think it is possible to send SMS to multiple recipients (numbers) at a time. Can anybody help me to achieve this? I am using Arduino UNO & SIM900A GSM/GPRS shield.
Hi Syed Zain Nasir!
i'm working on my FYP that is GSM based project. plz guide me how to interface GSM sim900 to Arduino Mega 2560? what will connection and code.. please make it simple for me!
Hi Siva
I am also the beginner, and have assigned same task as you.
If you you have done it, could you please help me out???
Hope for best response.
waiting for acknowledgement, with pleasures.
Regards: Aqsa.