Get the last value from the bucket: Some questions

Hi @George_Santiago,

I’ll try to be brief as it seems you have done your research and thoroughly tested the possibilities.

  1. I believe there is no functionality at the moment in the Arduino Thinger.io library to read from a data bucket.

  2. You can create a new standalone client for this request and as per the documentation from Thinger.io good coding practices use a non locking structure:

void loop() {
  thing.handle();

  // Execute every 20 seconds
  if (millis() %20000==0) {
    WiFiClient client;
    HTTPClient http;

    if (http.begin(client, url)) {  // HTTP
      Serial.println("[HTTP] GET...");
      int httpCode = http.GET();

      // httpCode will be negative on error
      if (httpCode > 0) {
        // HTTP header has been send and Server response header has been handled
        Serial.printf("[HTTP] GET... code: %d\n", httpCode);
        // file found at server?
        if (httpCode == HTTP_CODE_OK) {
          String payload = http.getString();
          Serial.println(String("[HTTP] Received payload: ") + payload);
        }
      } else {
        Serial.printf("[HTTP] GET... failed, error: %s\n\r", http.errorToString(httpCode).c_str());
      }

      http.end();
    } else {
      Serial.printf("[HTTP] Unable to connect\n\r");
    }
  }
}
  1. Sadly is does seem possible nor I was successful while testing without breaking connection with Thinger.io. It seems that the ESP8266 is not able to handle two secure clients (which is what Thinger.io library uses if SSL is not disabled) simultaneously due to RAM requirements, as the official documentation states. I’ll leave a couple of additional references: link1 and link2. Let me know if you are willing to live with the breaking connection against Thinger.io, if the request is not to often, and I’ll post the code.

Sorry I can not help you with points 4 and 5, but let me give you a couple of extra ideas in case you haven’t yet thought of them, based on writing the data to the device instead of the device retrieving it.

If you have access to either the plugins in the platform or are willing to self-host a Node-RED instance, since last published version you are able to read the last item from a data bucket and write the message to a device. I believe this could solve both your issues regarding the secure connection and the JSON rounding error.

Another option would be to have an additional server that could periodically read the last item of the bucket and send it to the device through the API, similarly as to how you are retrieving the data from the bucket.

Hope it helps