This post shows the basic use of GSM Modem interfaced with Arduino Uno which Sends and receives SMS .You could select the sending or receiving mode and you can even Chat with your Buddies . Yup , i have tried :-)
Get the right things.....
1. Arduino Uno
2. GSM modem SIM 900 with a 12v battery supply or 12v Adapter
3. Bread board(Optional)
4. Jumper wires.
5. Arduino IDE software (latest version).
6. And Enthusiasm :-)
Be careful while selecting your GSM modem . The modem that i am using needs 12v/1A supply .
There are also other types which could run on just 5V. So be careful and don't burn your board .
Download Link--> https://drive.google.com/file/d/0BxsMZLQokV3CX2Ewc0EzWTZJMUk/view?usp=sharing
or just copy paste it into Arduino IDE
// LK's code
// lookforlk.blogspot.com
// lookforlk.blogspot.com
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10); // tx,rx
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600);
delay(100);
}
void loop()
{
if (Serial.available()>0)
switch(Serial.read())
{
case 's':
SendMessage();
break;
case 'r':
RecieveMessage();
break;
}
if (mySerial.available()>0)
Serial.write(mySerial.read());
}
void SendMessage()
{
mySerial.println("AT+CMGF=1");
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+91 x \"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am LK Karthikeya texing from GSM module");// The SMS text you want to send change any msg
delay(100);
mySerial.println((char)26);
delay(1000);
}
void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0");
delay(1000);
}
1.Connect TX to Arduino digital pin 9
2.Connect RX to Arduino Digital pin 10
3.Connect GND to Arduino's GND
And don't forget to insert sim into GSM modem
Upload code into arduino then connect the GSM modem otherwise you may encounter error like "Error" .
Check and Arduino's serial monitor and Screenshot
If you face any issues, you can contact me.I can help you online .
Get the right things.....
Components needed :-
1. Arduino Uno
2. GSM modem SIM 900 with a 12v battery supply or 12v Adapter
3. Bread board(Optional)
4. Jumper wires.
5. Arduino IDE software (latest version).
6. And Enthusiasm :-)
GSM modem |
Power Supply GMS Modem SIM 900 :-
Be careful while selecting your GSM modem . The modem that i am using needs 12v/1A supply .
There are also other types which could run on just 5V. So be careful and don't burn your board .
12 V Adaptor to power GSM Modem |
Coding :-
Connect the arduino to PC while uploading
or just copy paste it into Arduino IDE
// LK's code
// lookforlk.blogspot.com
// lookforlk.blogspot.com
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10); // tx,rx
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600);
delay(100);
}
void loop()
{
if (Serial.available()>0)
switch(Serial.read())
{
case 's':
SendMessage();
break;
case 'r':
RecieveMessage();
break;
}
if (mySerial.available()>0)
Serial.write(mySerial.read());
}
void SendMessage()
{
mySerial.println("AT+CMGF=1");
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+91 x \"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am LK Karthikeya texing from GSM module");// The SMS text you want to send change any msg
delay(100);
mySerial.println((char)26);
delay(1000);
}
void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0");
delay(1000);
}
Code Screenshot , the code looks like this :-) |
Connection:-
Hardware wiring is very simple. It needs just 3 wiring :1.Connect TX to Arduino digital pin 9
2.Connect RX to Arduino Digital pin 10
3.Connect GND to Arduino's GND
And don't forget to insert sim into GSM modem
Note :-
Upload code into arduino then connect the GSM modem otherwise you may encounter error like "Error" .
Execution :-
Before execution make sure the hardware connection and coding part is done correctly
1.In arduino ,Open the Serial monitor (Ctrl +Shift + M) or tools -->Serial Monitor
2. Now Type and enter 's' for sending text (Check the Image)
The text that we entered in program has not been displayed but the full text will be sent no worries |
Now check your mobile, you would have received an sms
3 To receive Sms from someone , just open serial monitor again and Type 'r' . This will show the sms and the number of the sim (Check the Image)
Yup i succeeded doing it . check My SS(ScreenShot) last image
Check and Arduino's serial monitor and Screenshot
If you face any issues, you can contact me.I can help you online .
Regards,
lkkarthikeya@gmail.com
#SMS
#Send
#Receive
#DIY
#Wireless
#Arduino
#project
#Code
#Send
#Receive
#DIY
#Wireless
#Arduino
#project
#Code
Wow !!! Thats great explanation. Clear and neat
ReplyDeleteGreat work:-)
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI tried this code but it did not work. I followed all the steps mentioned.
ReplyDeleteok Which part is not working ? sending or receiving ?
Deletei tried the code as well. But it did not work. in my case only the receiving part is not working.
ReplyDeleteCheck with the code
Deleteeven for me receive part not working
Deleteno work
ReplyDelete