Send SMS with Arduino UNO and SIM900D using AT Commands
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.
Note:
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | SIM900 | Amazon | Buy Now |
2 | Arduino Uno | Amazon | Buy Now |
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:
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 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.
- That's all for today, in the coming post, we will have a look how to receive SMS with SIM900 and Arduino.