From 5c54b04fe024bb7f366d06a9aad25a9cff3347ed Mon Sep 17 00:00:00 2001 From: Matthias Prinke Date: Sun, 9 Jul 2023 09:17:30 +0200 Subject: [PATCH] Added lightning sensor --- .../BresserWeatherSensorMQTT/BresserWeatherSensorMQTT.ino | 6 ++++++ .../BresserWeatherSensorMQTTCustom.ino | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/examples/BresserWeatherSensorMQTT/BresserWeatherSensorMQTT.ino b/examples/BresserWeatherSensorMQTT/BresserWeatherSensorMQTT.ino index f4cc83a2..9b7cf3e6 100644 --- a/examples/BresserWeatherSensorMQTT/BresserWeatherSensorMQTT.ino +++ b/examples/BresserWeatherSensorMQTT/BresserWeatherSensorMQTT.ino @@ -483,6 +483,12 @@ void publishWeatherdata(bool complete) if (weatherSensor.sensor[i].moisture_ok || complete) { sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"moisture\":%d", weatherSensor.sensor[i].moisture); } + if (weatherSensor.sensor[i].lightning_ok || complete) { + sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"lightning_count\":%d", weatherSensor.sensor[i].lightning_count); + sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"lightning_distance_km\":%d", weatherSensor.sensor[i].lightning_distance_km); + sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"lightning_unknown1\":\"0x%03X\"", weatherSensor.sensor[i].lightning_unknown1); + sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"lightning_unknown2\":\"0x%04X\"", weatherSensor.sensor[i].lightning_unknown2); + } sprintf(&mqtt_payload[strlen(mqtt_payload)], "}"); sprintf(&mqtt_payload2[strlen(mqtt_payload2)], "}"); diff --git a/examples/BresserWeatherSensorMQTTCustom/BresserWeatherSensorMQTTCustom.ino b/examples/BresserWeatherSensorMQTTCustom/BresserWeatherSensorMQTTCustom.ino index 7ec9549a..87437b89 100644 --- a/examples/BresserWeatherSensorMQTTCustom/BresserWeatherSensorMQTTCustom.ino +++ b/examples/BresserWeatherSensorMQTTCustom/BresserWeatherSensorMQTTCustom.ino @@ -488,6 +488,12 @@ void publishWeatherdata(bool complete) if (weatherSensor.sensor[i].moisture_ok || complete) { sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"moisture\":%d", weatherSensor.sensor[i].moisture); } + if (weatherSensor.sensor[i].lightning_ok || complete) { + sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"lightning_count\":%d", weatherSensor.sensor[i].lightning_count); + sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"lightning_distance_km\":%d", weatherSensor.sensor[i].lightning_distance_km); + sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"lightning_unknown1\":\"0x%03X\"", weatherSensor.sensor[i].lightning_unknown1); + sprintf(&mqtt_payload[strlen(mqtt_payload)], ",\"lightning_unknown2\":\"0x%04X\"", weatherSensor.sensor[i].lightning_unknown2); + } sprintf(&mqtt_payload[strlen(mqtt_payload)], "}"); sprintf(&mqtt_payload2[strlen(mqtt_payload2)], "}");