Hi all,
I'm doing a project where i have to send an HTTP request to my GSM module through arduino. When I use the serial monitor to manually send the commands everything goes smoothly but whenever I try to let the arduino send these commands by its own, one command don't get send and I think the reason is the large size of the command
here is the code I wanna send
(I included only the parts for the communication with the module since my code is quite long
SoftwareSerial MYGSM(7, 8); //Define virtual serial port name as MYGSM,Rx is port 7, Tx is port 8
void sendGSM(const char* msg) { //a function that communicated with the GSM
MYGSM.println(msg);
}
//somewhere inside my loop().......
char *first_part = "AT+HTTPPARA=\"URL\",\"https://smartbreathalyzer.000webhostapp.com/GETID.php?TakenID=";
char *closing = "\"";
String url = first_part + IC + closing; //the IC here is a number that the user will input through a keypad
const char *url_complete = url.c_str();
// the commands to be sent
sendGSM("AT+HTTPTERM"); //to make sure it is off first
delay(100);
sendGSM("AT+HTTPINIT"); //START HTTP
delay(100);
// Serial.println(url_complete);
sendGSM(url_complete); //SEND THE LINK
delay(100);
as you can see the url_complete is quite long
After googling for a while, I came out to a solution that is basically increasing the buffer size from 64 to 256 BUT that is going to take too much size in the SRAM and when I try to use the F() function to store the variables to the flash memory I get this error:
cannot convert 'const __FlashStringHelper*' to 'const char*' for argument '1' to 'void sendGSM(const char*)'
I add the F() function like this:
sendGSM(F(url_complete)); //SEND THE LINK
Even when I try to place the F() function at other locations like:
const char *url_complete = F(url).c_str();
I still get errors
So, any suggestions to solve this issue?
Also, I think when the module communicates back to the Arduino it would also carry large statements so probably I need to somehow find a way to allow these large statements to happen (The buffer size increment could solve it, however I don't want to risk using lots of SRAM)
EDIT: I SAW ON GOOGLE, that Flash (PROGMEM) memory can only be populated at program burn time. You can’t change the values in the flash after the program has started running.
It seems bad idea to use it in my case since every time I will have a different IC, right?