Arduino Forum

Using Arduino => Programming Questions => Topic started by: trapiz_proj on Jul 09, 2013, 11:44 am

Title: GSM module,SIM300-code to make a call
Post by: trapiz_proj on Jul 09, 2013, 11:44 am
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 :-)
Title: Re: GSM module,SIM300-code to make a call
Post by: wildbill on Jul 09, 2013, 01:05 pm
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.
Title: Re: GSM module,SIM300-code to make a call
Post by: trapiz_proj on Jul 10, 2013, 08:12 pm
hi,
This is my first time working with a GSM module. Can you please explain,further, what you mean by that??

thanks in advance :-)
Title: Re: GSM module,SIM300-code to make a call
Post by: trapiz_proj on Jul 10, 2013, 08:14 pm
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?
Title: Re: GSM module,SIM300-code to make a call
Post by: Zapro on Jul 10, 2013, 08:37 pm
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.
Title: Re: GSM module,SIM300-code to make a call
Post by: trapiz_proj on Jul 10, 2013, 08:53 pm
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!!  :P  But, do i still need to use the library to be able to use other digital pins?? Is the code alright?







Title: Re: GSM module,SIM300-code to make a call
Post by: Zapro on Jul 10, 2013, 08:58 pm
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.

Title: Re: GSM module,SIM300-code to make a call
Post by: wildbill on Jul 10, 2013, 11:27 pm
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.
Title: Re: GSM module,SIM300-code to make a call
Post by: trapiz_proj on Jul 11, 2013, 08:01 am
hello wildbill,
I understand what you mean ,now.
Thanks a bunch for this :-D.
Title: Re: GSM module,SIM300-code to make a call
Post by: trapiz_proj on Jul 11, 2013, 08:44 am
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
Title: Re: GSM module,SIM300-code to make a call
Post by: trapiz_proj on Jul 11, 2013, 04:23 pm
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!
Title: Re: GSM module,SIM300-code to make a call
Post by: PaulS on Jul 11, 2013, 05:09 pm
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.