HELP Please!!! SMS Not Sending from Mega2560

Please I need help with my project. Trying to send SMS from my modem to my mobile phone but not receiving anything on my mobile phone.

What could be wrong?

See the code attached:

void SendSMS()
{
  digitalWrite(22, HIGH); //Turn pin22 LED ON to indicate SMS sending
   Serial1.println("AT"); // Send AT command to wake up modem
  delay(500);
  Serial1.println("AT+CMGF=1"); // set SMS mode to text
  delay(1000);
  Serial1.print("AT+CMGS=\"+447xxxxxxx92\"");  // send message command...
  delay(1000); // wait to receive ">"
  Serial1.print("Use Detected");   // message to send
  Serial1.write(byte(26));  // ASCII equivalent of Ctrl-Z
  digitalWrite(22, LOW); //Turn pin22 LED OFF to indicate done
}

Some Background Info:
Arduino Mega2560
GSM Modem attached to pin 18 and 19 (Serial 1)
SIM responding as modem LED blinks faster when I dial the number showing it’s responding.

That snippet of code looks fine as it stands. What modem are you using, and can you post the rest of your code?

I'm using just a cheap unbranded modem. But the modem communicates as I said earlier.

Also about the code, I observe on Serial monitor that it actually runs the codes. So the problem is likely that the modem is not responding to the codes from the Arduino. My connection is also correct.

Any other ideas?

Are you certain this should not be a Serial1.println() call? These commands are normally terminated by a cr/lf.

  Serial1.print("AT+CMGS=\"+447xxxxxxx92\"");  // send message command...

Does the baud rate is ok? Did you tried to send a sms using a hyperterminal like putty to test it in your computer?

SurferTim: Are you certain this should not be a Serial1.println() call? These commands are normally terminated by a cr/lf.

  Serial1.print("AT+CMGS=\"+447xxxxxxx92\"");  // send message command...

Good catch!

I blame not enough coffee!

SurferTim: Are you certain this should not be a Serial1.println() call? These commands are normally terminated by a cr/lf.

  Serial1.print("AT+CMGS=\"+447xxxxxxx92\"");  // send message command...

Thanks. I have corrected that but I still cant seem to get the modem to send the sms via the arduino. Using hyperterminal I could send the sms to my phone using the exact same codes.

Using logic probe I could sense the Arduino sending signals along the TX pin but no response on the RX pin.

Then you need to post all your code, and a link to the GSM device.

SurferTim: Then you need to post all your code, and a link to the GSM device.

here's my sketch. Just a segment of something bigger. But this is the one I'm using to test out the SMS thing.

/*
SECTION NOTE GOES HERE
 */

volatile int Detected = true;//Flag to indicate use

void setup()
{
  Serial.begin(9600);//Terminal serial interface for on-screen debugging
  Serial1.begin(9600);//GSM Modem Serial Connection  
  Serial.println("System Initializing...");
  delay(3000); time for peripherals to settle 
  Serial.println("System Ready");
}

void loop()
{
  while(1)
  {
    if (Detected)//enter loop only if variable Detected is true
    {
      Serial.println("Use Detected");
      delay(3000);
      SendSMS();
      Detected = false;//set Detected back to false
      delay(3000);
    }

  }
}

void SendSMS()
{
  digitalWrite(22, HIGH); //Turn pin22 LED ON to indicate SMS sending
  Serial.println("Sending SMS");
  Serial1.println("AT"); // Sends AT command to wake up cell phone
  delay(500);
  Serial1.println("AT+CMGF=1"); // set SMS mode to text
  delay(500);
  Serial1.println("AT+CMGS=\"+447xxxxxxx92\"");  // send message command...
  delay(500); // wait to receive ">"
  Serial1.println("Use Detected");   // our message to send
  Serial1.write(byte(26));  // ASCII equivalent of Ctrl-Z
  Serial.println("SMS Sent");
  digitalWrite(22, LOW); //Turn pin22 LED OFF to indicate done
}

I suspect this Serial1.write(byte(26));  // ASCII equivalent of Ctrl-Z Does this line follow with an "Enter"?

About the gsm device, it's a cheap Chinese version of Wavecom Modem. No datasheet accompanied it. Here's an ebay link http://www.ebay.com/itm/GSM-Modem-Wavecom-Q2303A-Module-COM-RS232-AT-Commands-/320925367142

What device are you using to convert the RS-232 signal levels to TTL?

SurferTim: What device are you using to convert the RS-232 signal levels to TTL?

I have been trying unsuccessfully with a MAX 232 chip. Just doesnt seem to communicate.

I spent some hours this afternoon troubleshooting. Everything else works well and so I assume there must be a problem with the level converter. Don't know what else to do.

Here is a link to a normal circuit for using the MAX232. Insure you have C1 and C2 caps (both 1uf) or it won't work. http://www.maximintegrated.com/en/products/interface/transceivers/MAX232.html#

edit: And don't forget C3 and C4. They are also 1uf.

kreativ: Serial1.write(byte(26));  // ASCII equivalent of Ctrl-Z  digitalWrite(22, LOW); //Turn pin22 LED OFF to indicate done }

I should mention this too. The Ctrl-Z wasnt terminating with a CR. So I added an extra blank line to force the "ENTER" as shown below: It worked. Monitored it on the scope. Sorting out my connection problems. Thanks everyone.

Serial1.write(byte(26));  // ASCII equivalent of Ctrl-Z
Serial1.println ()
  digitalWrite(22, LOW); //Turn pin22 LED OFF to indicate done