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?
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?
I have modify my code as following,but still it can't send any SMS and i see nothing in hypertermina,any clue?l
#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.
}
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.
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!