Open LaZoark opened 3 months ago
It seems like the init problem in the JSON object.
JSON Document: https://github.com/LaZoark/IOT-sensor/blob/6808f192d02ca5fafadfa239d696468ac687e24d/src/main_dht11_mqtt.cpp#L116
Since the snippet here always reuse the object.
String sensor_logger(bool state, float temperature, float humidity) {
if (state) {
log_doc["t"] = round2(temperature);
log_doc["rh"] = round2(humidity);
} else {
log_doc["err"] = "Please check the hardware or use <help> & <info> under </cmd> to debug.";
}
char json_output[measureJson(log_doc) + 1]; // Account for null-terminator, else trailing garbage is returned
serializeJson(log_doc, json_output, sizeof(json_output));
return json_output;
}
Further observation:
Althought the err
occurred, the sensor still worked fine.
{
"node": "esp8266-sensor-3083988EC133",
"ssid": "ED716-AP",
"ip": "192.168.50.26",
"gw": "192.168.50.1",
"free_heap": 33480,
"cpu_mhz": 80,
"pub_ms": 20000,
"compile": "Jan 20 2024 00:48:11",
"model": "esp01s_dht22",
"ver": "1.8.5",
"boot_ms": 1540187
}
The issue seems to be fixed.
Let's see if it will break in the future...
NTP check and OTA check was working fine.
The following topic
/data
shows error and sensor values at the same time, which is very weird...Also the
/state
indicated the"sensor":true
all the time.