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.
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.
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.
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"?
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.
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