Don't use String
. Temptingly easy to use, but you will eventually be sorry. :-( They are slower, use more RAM, and add 1.6k to your program size. Just stick with plain old C strings, also known as char
arrays.
You can break your print statement up into three parts:
char telephone_number[] = "111232113";
Serial.print( "AT+CMGS=\"" );
Serial.print( telephone_number );
Serial.println( "\"\r" );
You can save even more RAM space by using the F
macro around the print of double-quoted strings:
char telephone_number[] = "111232113";
Serial.print( F("AT+CMGS=\"") ); // Saves 10 bytes of RAM
Serial.print( telephone_number );
Serial.println( F("\"\r") ); // Saves 3 bytes of RAM
Any place you print a double-quoted string like that, just wrap it with the F
macro.
BTW, I assume the telephone number(s) is not a constant, so you need to keep it in RAM, as the char
array shown here.