Problem after serializing data

I have a problem with MQTT JSON data send to a Node-red frontend ...
After some time (usually about 10 to 15 minutes) and although my sensors produce valid data(!) - in the serialized JSON Data some values change to 'null' data!

I serialize data like this:

// 4 Json Object-Buffer erstellen
DynamicJsonDocument HTU21JSON(512);
DynamicJsonDocument DHTJSON(512);
DynamicJsonDocument ADCJSON(512);
DynamicJsonDocument DSTEMPJSON(512);

/ Daten ueber JSON-MQTT an Frontend
Serial.println("--- Data packages sent via MQTT to RaspberryPi --------------");
HTU21JSON["ESP_Datapack1"] = "";
HTU21JSON["temperatur"] = String(HTU21_temperature,1);
HTU21JSON["humidity"] = String(HTU21_humidity,1);
HTU21JSON["dewpoint"] = String(HTU21_dewpoint,1);
HTU21JSON["BMP_pressure"] = String(luftdruck,1);
// JSON HTU21 Daten in eine Variable schreiben
char HTU21Daten[512];
serializeJson(HTU21JSON, HTU21Daten);
client.publish("Serra_Messdaten", HTU21Daten);

see also attached picture ...

What could be the reason for that?

The reason could be what ever is publishing the data has an issue reading a sensor.

  1. What sensors are reading the humidity and water level?
  2. What device is sending the data? (is it an esp32?)
  3. What software is running on that device?
  4. How do you have the sensor connected?

Just to clarify, are you asking for help with the code that runs in some unspecified device, or is this a problem that you think is caused by node-red?

High Colin,
you are right.... the problem is not caused by Node-Red ... it is caused inside ESP32 serializing sensor data... please apologize - I should post in the ESP32 forum...
Thanks, Alf

I'm almost sure that the issue is caused by how the ESP32 handles the buffer data which it used to serialize JSON data ... so this is not a Node-Red problem... I should post it on a ESP32 forum I guess...
Thank you,

Depending on the sensor and how you have it wired, the sensor might not have a reading. That’s why I asked what sensors you are using.

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