I have the TEL0124 SIM7600 modem 4G LTE module connected to an Arduino board. will.
While I am able to send AT and get an OK, I would like to use a php to transfer data to the server. I am not able to send any data to the server
void setup()
{
Serial.begin(115200);
Serial1.begin(115200);
sendData("AT+CCID", 3000, DEBUG);
sendData("AT+CREG?", 3000, DEBUG);
sendData("AT+CGATT=1", 1000, DEBUG);
sendData("AT+CGACT=1,1", 1000, DEBUG);
sendData("AT+CGDCONT=1,"IP","TM"", 1000, DEBUG);
sendData("AT+CIPSTART="TCP","www.sxxxxde/data2mysql.php?key=xxx",80", 2000, DEBUG);
Serial.println("4G HTTP Test Begin!");
}
void loop()
string http_str = "AT+HTTPPARA=*URL","HTTPP://www.sxxxxde.de/data2mysql.php?key=xxxx&ID=9999A0200A1300A21024A324A426A510A614A714A828A90A10A110A120""rn";
Serial.println(http_str);
sendData("AT+HTTPINITrn", 2000, DEBUG);
sendData(http_str, 2000, DEBUG);
sendData("AT+HTTPACTION=0rn", 3000, DEBUG);
sendData("AT+HTTPTERMrn", 3000, DEBUG);}
String sendData(String command, const int timeout, boolean debug){
String response = "";
Serial1.println(command);
long int time = millis();
while ( (time + timeout) > millis())
{
while (Serial1.available())
{
char c = Serial1.read();
response += c;
}
}
This is simply an example (written here), but it somewhat illustrates what I am doing. ,sendingg a string of data tto the server via a PHP call.
I want to send data via 4g but as GSM isn’t working anymore for my modems SIM800 SIM900. This is why I opted for the 4G LTE version.
Any idea on how to send a string of data stream to the server on 4G?
Any help is much appreciated!
2
Answers
There are several severe issues with your AT command handling.
1a)
The command line should be terminated with
r
only and notrn
. The V.250 specification says:Notice the language here, "the termination character". ONE, not two characters1.
And just to emphasis how important that document is: Even after working with implementing AT commands in mobile phones in Ericsson for over a decade I and my colleagues still consulted that document regularly!
In fact, stop reading the rest of this answer right now and instead read all of chapter 5 in V.250 first, and then continue reading the rest here.
1b)
The command lines attempted to be invoked in your
setup
function all lack a termination character and thus will not be recognized as a command line. In other words all the command lines attempted to be executed are ignoredby the modem as garbage input.
2)
You should never use waiting a certain amount of time as a substitute for reading and parsing responses from a modem.
You must implement code to read the response sent back from the modem and parse it to properly recognize and wait for Final result codes. Nothing else will work.
Using
Serial1.available()
(+ time) as a framing mechanism is guarantied not to work. You must buffer modem response data character by character until you have a complete response line, and then you can go ahead and parse/process that line.1
And you should never change
S3
from its default value 13, so in practice you never have to deal with that register.In my opinion, the next line is incorrect:
string http_str = "AT+HTTPPARA=*URL","HTTPP://www.sxxxxde.de/data2mysql.php?key=xxxx&ID=9999A0200A1300A21024A324A426A510A614A714A828A90A10A110A120""rn";
In C string, if you want use a quotation mark, you must write a backslash + quotation mark combination, around the URL and HTTP…. parameters.
(I wrote the corrected line before, but this editor has modified my string to bad.)