Unable to send data array via MQTT - ESP32

I have issues with ESP32 PubsClient.h where i am publishing some 768 arrays. Here is my below snippet.

  StaticJsonDocument<1000> doc;
 
  doc["device"] = "ESP32";
  doc["sensor"] = "IR";
  JsonArray data = doc.createNestedArray("data");
  
  for (int i = 0; i < 768; i++) {
     data.add(dataArray[i]);
  }
  
  char JSONmessageBuffer[1200];
  serializeJson(doc, JSONmessageBuffer);

    Serial.println(JSONmessageBuffer);
 
  if (client.publish(MQTT_IR, JSONmessageBuffer) == true) {
    Serial.println("Success sending message");
  } else {
    Serial.println("Error sending message");
  }

Issue is i am only able to send max of 59 data points. If i try to increase the StaticJsonDocument - i run into runtime issues. Pls suggest me how i can send my 768 data pints.

i even tried using JSONArray - but no significant changes.

  DynamicJsonDocument doc(13000);  
 
  doc["sensor"] = "IR";
  
  for (int i = 0; i < 768; i++) {
    if (((i % 32) == 0) && (i != 0)) {
      Serial.println(" ");
    }
   // data.add((int)tempValues[i]);
    doc["values"][i] = (int)tempValues[i];  
    Serial.print((int)tempValues[i]);
    Serial.print(" ");
  }
  Serial.println("\r\n=========================== <<STOP>> MLX90640 Thermal Camera===============================");

  char JSONmessageBuffer[3* 1024];
  serializeJson(doc, Serial);
  size_t n =serializeJson(doc, JSONmessageBuffer);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.