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 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 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.
Note:
- I have also posted on How to Receive SMS with AT Commands using SIM900 and Arduino.
- If you are working on PIC Microcontroller then you should read How to Receive SMS with SIM900 & PIC Microcontroller.
Components Used
I have shared the list of components used in this project. I am giving a comparison of three vendors below, you can buy from any of them:Components List | Amazon | Ali Express |
---|---|---|
Arduino UNO R3 | [dt_button link="http://amzn.to/2vuKOQu" target_blank="false" button_alignment="default" animation="fadeIn" size="medium" style="default" bg_color_style="default" bg_hover_color_style="default" text_color_style="default" text_hover_color_style="default" icon="fa fa-chevron-circle-right" icon_align="left"]Click Here to Buy[/dt_button]Price: $10.99 | [dt_button link="http://s.click.aliexpress.com/e/urJAeYb" target_blank="false" button_alignment="default" animation="fadeIn" size="medium" style="default" bg_color_style="default" bg_hover_color_style="default" text_color_style="default" text_hover_color_style="default" icon="fa fa-chevron-circle-right" icon_align="left"]Click Here to Buy[/dt_button]Price: $2.79 |
GSM Module Sim900 | [dt_button link="http://amzn.to/2vuqbUt" target_blank="false" button_alignment="default" animation="fadeIn" size="medium" style="default" bg_color_style="default" bg_hover_color_style="default" text_color_style="default" text_hover_color_style="default" icon="fa fa-chevron-circle-right" icon_align="left"]Click Here to Buy[/dt_button]Price: $28.99 | [dt_button link="http://s.click.aliexpress.com/e/bIEQJ6M" target_blank="false" button_alignment="default" animation="fadeIn" size="medium" style="default" bg_color_style="default" bg_hover_color_style="default" text_color_style="default" text_hover_color_style="default" icon="fa fa-chevron-circle-right" icon_align="left"]Click Here to Buy[/dt_button]Price: $10 |
Connect Arduino UNO with SIM900D
- First of all, connect Arduino UNO with SIM900D module, which isn't much difficult. If you have the module in hand then 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 its blinking fast, it means the modules hasn'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 you 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.
- That's all for today, in the coming post, we will have a look how to receive SMS with SIM900 and Arduino.
Leave a Reply
Leave a Reply
You must be logged in to post a comment.
Comments on ‘’Send SMS with Arduino UNO and SIM900D using AT Commands‘’
( 90 )
what is the pkey used for? Can you please write a small description as to explaining the code. Any help would be appreciated.
thankyou
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.
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.
hey i wanna send multiple receptionist message using arduino and gsm module please help me.
please send me on mail id…
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
How to work out with sim900a in sending sms?
this code not working give error as mentioned by Muhamamd Ali please guide a bit..
Hi,
Remove these signs ” ” and then place them again and it will start working. Let me know if you still find any problem.
Thanks.
will this code work for arduino mega ?
Yes it will.
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. 🙂
You are most welcome and thanks for your precious comment.
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.
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
How did you solve this “atatatatat” problem ?
simpi.personal4@gmail.com
Kindly can you send me the working code ?
The above code is perfectly working bro.
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.
It is saying that index variable is not declared, check the code if it’s not declared then declare it
Int index = 0;
Thanks.
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.
Can’t say anything, but seems like you are quite close and need to do more testing.
same problem
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.
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.
It means it’s not working, you are doing some mistake , double check your schematic and make sure sim 900 is active
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
Also i am using sim900A in india
Same problem as Srijesh,
arduino mega,
sim900,
indian no.
double checked the connections
AT
AT+CMGF=1
AT+CMGS=”+918600782780″
A new post is created by Zain.
But not receiving any msg
Nice answers in return of this query with real arguments and telling the whole thing on the topic of that.
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.
Hi,
Add me on skype and we will discuss it in detail. My Skype id is ” theenggprojects “. We can provide you this complete project.
Thanks.
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’
Hi,
Bro, in your code you will find these symbols “” simply delete them and put them again and these errors will be resolved.
Thanks.
The replacement of ” ” works but still the errors remain. I am using a SIM300 with arduino atmega8.
What are the errors you are getting now ???
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 Sir!!! Issue solved. Thank you very very much.
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!!!!!!
It normally means that your module is burnt out so its not working, you have to change your sim300 module.
Hello I used you rcode and it worked how can I add another switch so I have 2 switches working
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.
Yeah it is burnt …. you need to change your sim900 module.
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 ?
jay how do you solve that errors i also got that same but cant fix it,i also change and rewrite the “”
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.
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
Add delay of 2000 between send sms commands if it still does not work increase it to 4000 it will work.
I am using SIM 900A.Eventhough after making the corrections mentioned earlier i am getting errors.
My module keeps saying AT … Any help ?
No idea. Check your connections and also increase the delay. Some modules have a slow response.
Which delay did you mean sir? My serial monitor also kept showing ATATATA
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?
It means you have to buy a new module. Sorry to say but it’s burnt.
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
Thanks for sharing the code.
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 .
Syedbhai u r really very helpful …. sharing knowledge is very good .. THANKS.. good wishes..
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..
Please tell what changes are required if we someone is using Arduino Mega 2560?
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.
Hi Syed, have you been able to do anything with the m590? It is usually marketed as sim900 kit, so I wonder if it works the same then?
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);
}
Can we give arduino 5 volts from arduino?
if i used itead sim900 gprs/gsm module..so the programming can used on it
hi…!!mujhse connect nahi horha gsm coding mein error arha hai
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,
Kindly add me on Skype and we will discuss it in detail. My Skype id is theenggprojects. I have to check the hardware.
Thanks.
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,
Contact me on Skype and I will help you out. My Skype id is theenggprojects.
Thanks.
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.
Hi,
If you need help in your final year project then you can add us on Skype or can use our Forums and our team members will help you out.
Thanks.
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
Hi,
Kindly add me on Skype and we will discuss it in detail. My Skype ID is theenggprojects. Btw yes it works on AT commands.
Thanks.
Hi,
Kindly add me on Skype and we will discuss it in detail. My Skype ID is theenggprojects. Btw yes it works on AT commands.
Thanks.
sir this code is not working missing terminting error occur. help me sir
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!
can you please tell me some got site or place where gsm/sim808,and ardiuno is availabe