GSM module,SIM300-code to make a call

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 :slight_smile:

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.

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

thanks in advance :slight_smile:

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?

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.

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!! :stuck_out_tongue: But, do i still need to use the library to be able to use other digital pins?? Is the code alright?

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.

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.

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

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

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!

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.