I'm working on a project based on this:
[https://www.instructables.com/Simple-BLE-Temp-Sensor-for-Beginners-5-Years-on-Co/](Simple BLE temp sensor)
I also use the nRF52832 module to scan for my sensors.
It is then connected to a ESP-01 module to send the data to my server.
I also have a 2.9" e-ink display connected to show some values from the sensors.
Once I've sent the data, I then put the ESP-01 module to deep-sleep for 3 minutes.
Each sensor wakes up once a minute and report temperature and such.
The whole system works fine, for some time.
Then out of nowhere, my "base-station" is unable to build the string for the HTTP POST data body.
There is a sample of what a good POST body looks like:
USR=user&PWD=7&SENSOR[0][NAME]=3815727166&SENSOR[0][VALUE][0]=19.20&SENSOR[0][VALUE][1]=50.50&SENSOR[0][VALUE][2]=992.80&SENSOR[0][VALUE][3]=0.00&SENSOR[0][VALUE][4]=0.00&SENSOR[1][NAME]=814192120&SENSOR[1][VALUE][0]=19.30&SENSOR[1][VALUE][1]=39.50&SENSOR[1][VALUE][2]=992.80&SENSOR[1][VALUE][3]=0.00&SENSOR[1][VALUE][4]=0.00&SENSOR[2][NAME]=36015720&SENSOR[2][VALUE][0]=19.80&SENSOR[2][VALUE][1]=38.00&SENSOR[2][VALUE][2]=993.00&SENSOR[2][VALUE][3]=0.00&SENSOR[2][VALUE][4]=0.00&SENSOR[3][NAME]=3815727166&SENSOR[3][VALUE][0]=19.20&SENSOR[3][VALUE][1]=50.50&SENSOR[3][VALUE][2]=992.80&SENSOR[3][VALUE][3]=0.00&SENSOR[3][VALUE][4]=0.00&SENSOR[4][NAME]=36015720&SENSOR[4][VALUE][0]=19.80&SENSOR[4][VALUE][1]=38.00&SENSOR[4][VALUE][2]=993.00&SENSOR[4][VALUE][3]=0.00&SENSOR[4][VALUE][4]=0.00&SENSOR[5][NAME]=814192120&SENSOR[5][VALUE][0]=19.30&SENSOR[5][VALUE][1]=39.60&SENSOR[5][VALUE][2]=992.80&SENSOR[5][VALUE][3]=0.00&SENSOR[5][VALUE][4]=0.00&SENSOR[6][NAME]=3815727166&SENSOR[6][VALUE][0]=19.20&SENSOR[6][VALUE][1]=50.50&SENSOR[6][VALUE][2]=992.80&SENSOR[6][VALUE][3]=0.00&SENSOR[6][VALUE][4]=0.00&POTATO=YES
Then after some time, i just get this:
USR=user&PWD=22&SENSOR[0][NAME]=8
or
USR=user&PWD=22&SENSOR[0][NAME
Sometimes it happens after 30 min, sometimes after 8 hours.
At first I was using String, like the lazy man I am.
I've then tried just printing the data directly to the output as well as
using both SafeString and PString (currently).
I've had the same behavior no matter what arppoche i used to create the POST body.
For me, this sounds like an issue with the memory, like overflow or fragmentation maybe?
I have oversized buffers for the POST body buffer (I have 15000 bytes allocated, that should be ~94 datapoints, that most I've seen is around 20-25).
I've also tried to avoid creating variables and such inside voids to reduce memory fragmentation.
I also disabled the e-ink display to save some memory.
I was also getting the user-set name for each sensor from the server, so I can display on the e-ink
but that has also been disabled right now to save memory.
But nothing has helped.
This is the code that currently is generating the POST body data
httpStr.begin();
httpStr.print(F("USR=user&PWD="));
httpStr.print(sensorIndex);
int count = 0;
for (int j = sensorIndex -1; j >= 0; j--) {
httpStr.print(F("&SENSOR["));
httpStr.print(count);
httpStr.print(F("][NAME]="));
httpStr.print(readArr[j].getMacLong());
for (int i = 0; i < NUM_SENSORS; i++) {
httpStr.print(F("&SENSOR["));
httpStr.print(count);
httpStr.print(F("][VALUE]["));
httpStr.print(i);
httpStr.print(F("]=")) ;
httpStr.print(readArr[j].getValue(i));
}
count++;
}
httpStr.print(F("&POTATO=YES"));
The complete code can be found on [https://github.com/endlessmind/WeatherStation](my Github by clicking this link)
Any ideas on what to try next would be much appreciated.