Pages: [1]   Go Down
Author Topic: GSM module,SIM300-code to make a call  (Read 924 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
We're working on an LPG gas detector.We're using a GSM module(SIM300,to alert the owner,of the gas leak) and arduino uno .We were trying to make a call to a phone using the module,but the process failed (as in,the commands appeared on the serial monitor with the delays but no call was received).
Our GSM module works fine as we tested it by making a call to it after inserting the SIM.

Here's the code we used:
char phone[]="xxxxxxxxxx";//phone number to make a call to

void setup()
{
 Serial.begin(9600);
 delay(2000);
 Serial.println("AT");
 Serial.print("ATD");
 Serial.print(phone);
 Serial.println(";");
 delay(10000);
 Serial.println("ATH");
}

void loop()
{
 
}
Is this code correct??


we connected the rx of the arduino to the tx of the SIM300 and vice-versa. We connected the grounds of both the arduino and the module together.Keeping the ground intact we disconnected the serial pins during the uploading of the code and reconnected once uploading was done.
Is this correct?? and does the serial monitor have to be in the "carriage return" mode?

Hope you can help us!
Thanks :-)
Logged

New Jersey
Online Online
Faraday Member
**
Karma: 50
Posts: 3429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's generally not a good idea to share the serial port with multiple devices. Try using SoftwareSerial to talk to the GSM module and then you can echo any responses back to the terminal.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,
This is my first time working with a GSM module. Can you please explain,further, what you mean by that??

thanks in advance :-)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Connections were made between the arduino board and the module.Can you please tell me,Why  that's not a good idea and how else  i can
make the connections?
Logged

Denmark
Offline Offline
God Member
*****
Karma: 8
Posts: 546
Please don't send questions as PM!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Only two devices can use the RS232 link at a time. If you connect the Arduino to the PC via the serial terminal, then you cannot use the serial port on pins 0&1 for the GSM modem. You need to setup an soft-serial port for the modem.

//Per.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I read up now , that the software serial library is used to make serial connections on pins other than just 0 and 1 when multiple serial connections are in use. But in this case, my arduino is connected to the computer via a USB cable and is communicating serially with just the module through pins 0 and 1.
So sorry if my questions seem repetitive and basic!!  smiley-razz  But, do i still need to use the library to be able to use other digital pins?? Is the code alright?







Logged

Denmark
Offline Offline
God Member
*****
Karma: 8
Posts: 546
Please don't send questions as PM!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are using the Arduino board just to communicate with the modem from the serial terminal, put a wire between the RESET pin and one of the GND pins.

This way the ATMega processor is disabled and won't interfere with communications. Then you can connect the modem on the pins 0 & 1.

I don't understand what you mean by "other digital pins" ?

// Per.

Logged

New Jersey
Online Online
Faraday Member
**
Karma: 50
Posts: 3429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The USB serial connection uses pins 0 and 1 to communicate with your PC. You have apparently used 0 and 1 again to talk to your GSM module. Thus the suggestions to use softserial.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello wildbill,
I understand what you mean ,now.
Thanks a bunch for this :-D.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey zapro,
Wire in between the reset and ground?? Alright i'll try that as well. So far, i connected the 2 grounds together, that is, the one on the module and the one on the board. And i used to press the reset button every time i wanted it to make a new call,so the AT,ATD,ATH commands appeared anew on the serial monitor. I'll try connecting the reset pin and ground as well,Thanks.Hope i can make a call,atleast now! :-p
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hey,
So i tried connecting pins 10 and 11 to the tx and rx of the module and uploaded the following code..Still, no action. I think i might be missing a major point ,conceptually or in the code..so, could really use some help now ,although i know this is like, the 5th question on the same topic,sorry 'bout that :-p
Here's the code..
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);
void setup()
{
mySerial.begin(9600); // the GPRS baud rate
delay(2000);
mySerial.println("AT");
delay(2000);
mySerial.println("AT+CSMP=17,167,0,0");
delay(2000);
}
void loop()
{
  mySerial.println("AT+CMGF=1"); // set the SMS mode to text
delay(2500);
mySerial.write("AT+CMGS=");
mySerial.write(34); //ASCII of “
mySerial.write("+91xxxxxxxxxx");
mySerial.write(34);
mySerial.write(13);
mySerial.write(10);
delay(2500);
mySerial.println("hello"); //this is the message to be sent
delay(2500);
mySerial.write(26);
mySerial.write(13);
mySerial.write(10);//Ascii code of ctrl+z to send the message
delay(2500);
while(1);
}
..Thanks in advance!
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46257
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think i might be missing a major point
Yes. The one about how to properly post code, as explained in the sticky at the top of this forum.
Logged

Pages: [1]   Go Up
Jump to: