So I am sending data to my php script hosted on 000WebHost via HTTP POST on my ESP32+SIM800L set up. I am recording sensor data at 800Hz and storing it in an character array like: a[]=3&a[]=5&a[]=8... which becomes my payload array for the POST request.
For some reason I can only send 161 values which is a Content Length of roughly 1449.
The code is a bit lengthy so I have reduced it here: I am using the TinyGSM Library
//Start GSM:
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
SerialMon.println("Initializing modem...");
modem.init();
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" success");
if (modem.isGprsConnected()) {
SerialMon.println("GPRS connected");
}
SerialMon.print("Connecting to ");
SerialMon.println(server);
if (!client.connect(server, port)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" success");
// Record Sensor values for one second
//Send the character array to the httpPost function:
if (client.connect(server,port)) {
Serial.println("connected");
client.println("POST /upload.php? HTTP/1.1");
client.println("Host: epiblastic-reactor.000webhostapp.com");
client.println("User-Agent: TTGO-TCALL/1.0");
client.println("Content-Type: application/x-www-form-urlencoded;");
client.print("Content-Length: ");
client.println(String(acceldata).length());
client.println();
client.println(acceldata);
uint32_t timeout = millis();
while (client.connected() && millis() - timeout < 10000L) {
// Print available data
while (client.available()) {
char c = client.read();
SerialMon.print(c);
timeout = millis();
}
If I send more than 161 values the Serial Monitor prints:
#Available: 0 on 1
continuously.
What is going wrong? Can Someone please help me?
The MTU of an Ethernet is typically at 1500, but for SIM800, I believe it is set to 1460 bytes(You can check the value using
AT+CIPSEND?
). The TCP/HTTP client that TinyGSM used does not seems to break the data longer than one MTU into chunks, so it will be user's responsibility to do it.Here is an example on how to send data in multiple chunks.
Code has been updated from initial input