Reputation: 31
Last night code was working, but when I tried today I got +CME ERROR: invalid input value.
I'm using arduino uno and sim900.
Code I used is from randomnerdtutorials.
`/*********
Complete project details at https://randomnerdtutorials.com
*********/
#include <SoftwareSerial.h>
// Configure software serial port
SoftwareSerial SIM900(7, 8);
void setup() {
SIM900.begin(19200);
Serial.begin(9600);
// Send the SMS
sendSMS();
}
void loop() {
}
void sendSMS() {
Serial.println("Sending SMS");
// AT command to set SIM900 to SMS mode
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.println("AT+CMGS=\"+381601xxxxxx\"");
delay(100);
SIM900.println("Hello");
delay(100);
// End AT command with a ^Z, ASCII code 26
SIM900.println((char)26);
delay(100);
SIM900.println();
// Give module time to send SMS
long int time = millis();
while ((time + 10000) > millis()) {
while (SIM900.available()) {
String response = SIM900.readString();
Serial.println(response);
}
}
Serial.println("Sent");
}`
15:41:20.146 -> Sending command: AT
15:41:22.181 -> Response:
15:41:22.181 -> OK
15:41:22.181 ->
15:41:22.181 -> Sending command: AT+CPIN?
15:41:24.156 -> Response:
15:41:24.188 -> +CPIN: READY
15:41:24.188 ->
15:41:24.188 -> OK
15:41:24.188 ->
15:41:24.188 -> Sending command: AT+CSQ
15:41:26.163 -> Response:
15:41:26.195 -> +CSQ: 25,0
15:41:26.195 ->
15:41:26.195 -> OK
15:41:26.195 ->
15:41:26.195 -> Sending command: AT+CREG?
15:41:28.170 -> Response:
15:41:28.202 -> +CREG: 0,1
15:41:28.202 ->
15:41:28.202 -> OK
15:41:28.202 ->
15:41:28.202 -> Sending command: AT+CSCA?
15:41:30.210 -> Response:
15:41:30.210 -> +CSCA: "002B00330038003100360033003100300030003100300030",145
15:41:30.275 -> Sending command: AT+CMGF=1
15:41:32.229 -> Response:
15:41:32.229 -> OK
I also tried bunch of other commands to check sim status and everything works properly:
I had also tried 2 other sim cards and got the same issue. I'm assuming that something is wrong with my sim900 module. I tried ATZ to reset the module and also tried manually turning device off and on and nothing changed.
Any suggestions?
Thank you in advance.
Upvotes: 0
Views: 101
Reputation: 1582
As per the datasheet, the command syntax is AT+CMGS=<number><CR><message><CTRL-Z>
. So it looks like you are missing the CR character (\r
) when you send the AT+CMGS
command to the modem.
Your line should be:
SIM900.println("AT+CMGS=\"+381601xxxxxx\"\r");
Maybe you should also change the CTRL-Z print to:
SIM900.println("\x1a");
Upvotes: 0