#include "mgos.h"
const char *s_url = "https://script.google.com/macros/s/AKfycbw4aaRW5x-oHimo-kOw29SDOHa
qhFUEgb1zT_wHtq3jcyAXa/exec";
static int counter1 = 0;
static void timer_cb(void *arg) {
char buf[100];
struct json_out out = JSON_OUT_BUF(buf, sizeof(buf));
json_printf(&out, "[%d]", counter1);
LOG(LL_INFO, ("counter1: %d", counter1)); // log to console to compare with what logged to Google Spreadsheep
mg_connect_http(mgos_get_mgr(), NULL, NULL, s_url, NULL, buf);
counter1++ ;
(void) arg;
}
enum mgos_app_init_result mgos_app_init(void) {
mgos_set_timer(10000, MGOS_TIMER_REPEAT, timer_cb, NULL);
return MGOS_APP_INIT_SUCCESS;
}
And indeed there some records missed in Google Spreadsheet:
Here is what I get in Spreadsheet:
|19/09/2019 23:20:50|0|
|19/09/2019 23:21:11|2|
|19/09/2019 23:21:22|3|
|19/09/2019 23:21:31|4|
|19/09/2019 23:21:42|5|
|19/09/2019 23:21:53|6|
|19/09/2019 23:22:10|7|
|19/09/2019 23:25:32|28|
|19/09/2019 23:25:42|29|
|19/09/2019 23:25:52|30|
|19/09/2019 23:26:03|31|
|19/09/2019 23:26:23|33|
|19/09/2019 23:26:49|35|
|19/09/2019 23:27:30|39|
My connection is rock solid, this can’t be an issue.
Any thoughts?
Start from zero means that ESP8266 reboot itself.
It looks like post to Google Spreadsheet doesn’t have any mechanism to prevent missed jammed packets?
Okay, the problem is that ESP8266 is out of RAM after 7-8 records sent. It looks like the exampe is RAM hungry.
ESP32 works stable. The example needs at least 60 kb of free RAM to work.
But ESP32 but still loses about one on 200 jsons sent to Google Spreadsheet. Is there a solution for this problem? Should I use MQTT to eliminate data loss?
Also can you give an example how to write two values in 2 separate cells on each row?
I have tried this: json_printf(&out, “[%d], [%d]”, counter1, counter2);
but it doesn’tn work.