Itead 3g module error cannot send sms

Hi
I am using itead 3g module for sending sms.
it shows error after executing the program. I am using the following coding

#include <SoftwareSerial.h>

#define rxPin 6
#define txPin 7
#define baudrate 9600
const int buttonPin = 2;
int buttonState = 0;

SoftwareSerial mySerial(rxPin, txPin); // RX, TX

char AtCommand[] = “ATI\r”;
void setup()
{
pinMode(buttonPin, INPUT_PULLUP);
// Open serial communications and wait for port to open:
Serial.begin(baudrate);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);

Serial.println(AtCommand);

// set the data rate for the SoftwareSerial port
Serial.println(“wait 5s for modem to wake up”);
delay(5000);
mySerial.begin(115200);
mySerial.println(“AT+IPR=9600\r\n”); // chnage baudrate to 9600 baud

Serial.println(“Changing baudrate”);
mySerial.begin(baudrate);
mySerial.println(AtCommand);

}

void loop() // run over and over
{
if (mySerial.available())
{
Serial.write(mySerial.read());
}
if (Serial.available())
{
mySerial.write(Serial.read());
}
buttonState = !digitalRead(buttonPin);
if (buttonState == HIGH) {SendSMS();}
}

void SendSMS()
{
mySerial.println(‘AT+CMGF=1’); // Sets the GSM Module in Text Mode
delay(1000); // Delay a 1 second to give the module time to execute the above command
mySerial.println(“AT+CMGS=“61**************”\r”); // Replace x with mobile number THIS IS WHERE IT SEEMS TO BREAK
delay(1000);
mySerial.println(“Hello world SMS message”); // The SMS text (you’ve got 140 characters)
delay(100);
mySerial.println((char)26);// This is the ASCII code for CTRL+Z
delay(1000);
Serial.println(“sent”);

}

I’ve looked at the Wiki and the Command Manual but your code looks right.

mySerial.println("AT+CMGS=\"61**************\"\r");

What is the exact error shown?

You have correctly added a carriage return character \r. Should println be print instead? println will send an end of line mark, but print would not. I’m not sure it matters, since you’d just get a blank line at the start of your text.

What does the status LED show? If it is blinking, how fast is it blinking? e.g. count how many blinks in about ten seconds.

Does the same SIM work in a phone for sending text messages?

Yes the sim is working 100% as i am using it in my phone and got unlimited sms and calls.

Great. And my other questions? :smile:

All 4 leds are on and none of them blinks.

All 4 leds are on and none of them blinks

Oh! Wiki says that non-flashing LED means “Searching Network/Call Connect”. You might connect keyboard directly to module and use other commands to check that the module can scan the network (p132), and that the network has accepted the module (p92). For that you will need a serial adapter.

If you have don’t have a serial adapter, but you do have an Arduino, you can use it as a serial adapter using a passthrough sketch, like this;

//
// Passthrough serial adapter for Arduino Uno
//
// 1.  configures serial pins as input, ignored by Arduino, so they can be used by a device
//
// 2.  monitors serial pins and flashes the D13 LED when activity is seen.
//
// quozl@laptop.org 2013-12-18
//

byte show;              // show a D13 LED flash
unsigned short then;    // when to finish the LED flash

void setup() {
  pinMode(0, INPUT);    // release serial pins for use by external device
  pinMode(1, INPUT);
  pinMode(13, OUTPUT);  // prepare the D13 LED for use
  show = 0;
}

void loop()
{
  // take note of the time since boot in milliseconds
  unsigned short now = millis() & 0xffff;

  // detect serial pin activity (pins are high when inactive)
  if ((PIND & B11) != B11) {
    if (!show++) digitalWrite(13, HIGH);
    then = now + 50;
  }

  // show the LED flash
  if (show) {
    if (now > then) {
      if (!--show) digitalWrite(13, LOW);
    }
  }
}

And change the UART multiplexor pins to match. When finished testing, and you are back to using your sketch, put the multiplexor back the way it was.