Hi
I'm working on a project with an Arduino Mega and a Sim900 dev board. The idea is to receive a SMS message and reply to the sender. So far I have managed to get the senders phone and store in a string called phone.
The problem is that when I try to use the a compiled command, called cmd, the SIM won't react. With a hardcoded string with exactly the same looks it does work.
void sendSMS() {
String cmd = "";
cmd = '"';
cmd += "AT + CMGS= ";
cmd += char(92);
cmd += '"';
cmd += phone;
cmd += char(92);
cmd += '"';
cmd += '"';
delay(50);
Serial3.print("AT+CMGF=1\r");
delay(100);
Serial3.println(cmd); //THIS DOES NOT WORK!
//Serial3.println("AT + CMGS= \"+46705957262\""); //THIS WORKS FINE!
Serial.println(cmd);
delay(500);
Serial3.println("Galeaser i Suntak!");
delay(100);
Serial3.println((char)26);
delay(100);
Serial3.println();
}
Any idea what I miss?