Communication between Arduino with Wavecom Q2303A GSM modem

Guys,i need help with my project
I have connected my arduino AtMega328 to Wavecom Q2303A GSM Modem using rs232 level converter(http://extremeelectronics.co.in/avr-tutorials/rs232-communication-the-level-conversion/),but i still can't configure my gsm modem to send SMS to my desired phone number.I'm using arduino 1.0 btwFollowing is my coding for the project:

#include <SoftwareSerial.h>

const int rxpin = 2; // pin used to receive
const int txpin = 3; // pin used to transmit
SoftwareSerial gsm(rxpin, txpin); // new serial port on pins 2 and 3
char phoneNumber[] = "0128950630";
void setup()
{
Serial.begin(9600); // 9600 baud for the built-in serial port
gsm.begin(9600); //initialize the software serial port also for 9600
delay(35000);
}
void loop()
{

gsm.println("AT");
delay(500);
gsm.println("AT+CMGF=1"); // set SMS mode to text
delay(500);
gsm.print("AT+CMGS="); // now send message...
gsm.write((byte)34);// ASCII equivalent of "
gsm.print(phoneNumber);
gsm.write((byte)34); // ASCII equivalent of "
gsm.println();
delay(500);
gsm.print("Hello, This is your Arduino"); // our message to send
gsm.write((byte)26); // ASCII equivalent of Ctrl-Z
// this will send the following to the GSM module
// on the Cellular Shield: AT+CMGS=”phonenumber”
// message<CTRL+Z>
gsm.println();
delay(15000); // The GSM module needs to return to an OK status

{
delay(1);
}
while (1>0); // if you remove this you will get a text message every 30 seconds or so.
}

I have connected Tx and Rx wire from the rs232 level converter to pin 2 and pin 3 of the arduino respectively,is this correct? Can anyone point out what's wrong with my coding? :sweat_smile:

Can anyone point out what's wrong with my coding?

It's posted incorrectly, for one thing. Use the # icon when posting code.

There's no indenting, to make the code readable.

{
delay(1);
}

Why are these curly braces here?

Without them, you have:

delay(15000); // The GSM module needs to return to an OK status
delay(1);

Why is the second delay even there?

Most importantly, there is no feedback.

gsm.println("AT");

Yo, phone, do something.

gsm.println("AT+CMGF=1"); // set SMS mode to text

Yo, phone, do something else.

What if the first command resulting in the phone telling you to take a hike?

Why do you not read whatever the phone might be trying to tell you?

Oh,you suggesting using read command "gsm.read"?but how it actually works?i mean do i have to put that command everytime before sending any AT command to the gsm?

You posted a question. Clearly, you expected a reply. You got one. You read it.

You sent the modem a command. It is not unreasonable to expect a reply. In fact, every AT command generates a response.

Yes, I expect you to read it. All of it. I expect that you will not send command # 2 unless comman # 1 returns "OK".

I have modify my code as following,but still it can't send any SMS and i see nothing in hypertermina,any clue?l :roll_eyes:

#include <SoftwareSerial.h>

const int rxpin = 2; // pin used to receive 
const int txpin = 3; // pin used to transmit 
SoftwareSerial gsm(rxpin, txpin); // new serial port on pins 2 and 3
char phoneNumber[] = "0128950630";
void setup()
{
Serial.begin(9600); // 9600 baud for the built-in serial port
gsm.begin(9600); //initialize the software serial port also for 9600
delay(35000);
}
void loop()
{  

gsm.println("AT");
while(gsm.available())
    Serial.write((byte)gsm.read());
Serial.println();
delay(500);
gsm.println("AT+CMGF=1"); // set SMS mode to text
while(gsm.available())
    Serial.write((byte)gsm.read());
Serial.println();
delay(500);
gsm.print("AT+CMGS="); // now send message...
gsm.write((byte)34);// ASCII equivalent of "
gsm.print(phoneNumber);
gsm.write((byte)34); // ASCII equivalent of "
gsm.println();
while(gsm.available())
    Serial.write((byte)gsm.read());
Serial.println();
delay(500);
gsm.print("Hello, This is your Arduino"); // our message to send
gsm.write((byte)26); // ASCII equivalent of Ctrl-Z
// this will send the following to the GSM module
// on the Cellular Shield: AT+CMGS=”phonenumber”<CR>
// message<CTRL+Z><CR>
gsm.println();
while(gsm.available())
    Serial.write((byte)gsm.read());
Serial.println();
delay(15000); // The GSM module needs to return to an OK status

{
delay(1);
}
while (1>0); // if you remove this you will get a text message every 30 seconds or so.
}
gsm.println("AT");
while(gsm.available())
    Serial.write((byte)gsm.read());
Serial.println();
delay(500);

I want an answer, and I want it RIGHT NOW!!!

Move the delay to right after you write to the device.

This won't solve your problem, but at least you'll wait for a response.

Do you have any documentation on that modem? Google is just flooded with ads that I don't feel like wading through.

By the way, cross-posting is frowned on, here.

Oh,sorry about that.I'm still quite new to this forum.I bought my modem from
http://www.ebay.com/itm/180629645054?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649#ht_3610wt_1293,basically all the specifications are stated there.

Found it!

Do you have a schematic showing how you have connected the device to the RS232 chip, and how that is connected to the Arduino?

However, the use of RX, TX, CTS and RTS signals is mandatory

Are these all connected?

I don't see in your code where you are checking the CTS pin or setting the RTS pin.

Interestingly, on page 26 of the pdf file, it mentions a baud rate that should be used to talk to the modem. Compare that with your baud rate.

You have not mentioned whether you were successful at communicating with the modem using a PC. An important data point, to be sure.

it can't communicate with the PC using the settings in page 26.Instead it manage received AT-command and send message using bit rate:9600,8,None,1,None on hyperterminal.
This is the rs232 level converter that i used http://sodoityourself.com/max232-serial-level-converter/
I don't have the schematic but i can explain briefly on how i connect it,the RX,TX from rs232 level converter are connected to TX,RX pin on arduino which is pin 3 and 2 respectively,5v were supplied to rs232 level converter from arduino and grounded as usual,seriel port from rs232 level converter connects to Gsm modem.

Serial port from rs232 level converter were connected to GSM modem using DB9 to sub-hd 15-pin converter wire

Problem solved!!apparently i had wrongly construct the rs232 level converter,i fixed it and now it is working.Nevertheless,many thanks to PaulS,you have been a great help! :smiley:

Problem solved!!

Yeah!

hi
@xemse89
I want use a wavecom also but not comunicate with arduino, can you tell me if you use CTS and RTS

However, the use of RX, TX, CTS and RTS signals is mandatory

regards
stefano