I'm finishing up an Sketch with the Arduino IDE and to be able to run it on UNO, I have to work with C char[]
. Which has not been easy for me and I already asked something regarding this a short while ago.
I need to create a longer char[]
by concatenating smaller parts. So far I've been able to do it by something like this:
//Declarations
#define TARGET_IP "184.106.153.149"
//Methods
void randomMethod(){
strcpy(foo, "AT+CIPSTART=\"TCP\",\"");
strcat(foo, TARGET_IP);
strcat(foo, "\",80\r\n");
Serial.println(foo);
}
However in my code I have a lot of static string which eat up most of the 2K RAM memory, so I would like to make use of the PROGMEM So I tried the following:
//Declarations
#define TARGET_IP "184.106.153.149"
static const char targetIp[] PROGMEM = TARGET_IP;
//Methods
void randomMethod(){
strcpy(foo, "AT+CIPSTART=\"TCP\",\"");
strcat(foo, targetIp);
strcat(foo, "\",80\r\n");
Serial.println(foo);
}
When printing on the serial monitor the first snippet works just fine whereas the second does not.
I've been trying to google it, but to no avail.
Any further education from you guys and gals will be most appreciate it. Thanks in advance!