Browse Source

mqtt: only publish json

main
Hendrik Langer 5 years ago
parent
commit
63384559a0
  1. 59
      src/main.cpp

59
src/main.cpp

@ -678,60 +678,6 @@ void sendValues() {
mqtt.publish(topic_json.c_str(), buf, strlen(buf), 1, 1);
delay(10);
/* send values MQTT */
if (sensors_active.bme280 || sensors_active.bme680) {
String topic_temperature = String("thomas/sensor/") + ota.getMAC() + String("/temperature");
String topic_humidity = String("thomas/sensor/") + ota.getMAC() + String("/humidity");
String topic_pressure = String("thomas/sensor/") + ota.getMAC() + String("/pressure");
mqtt.publishf(topic_temperature.c_str(), "%.2f", sensor_readings.temperature);
delay(10);
mqtt.publishf(topic_humidity.c_str(), "%.2f", sensor_readings.humidity);
delay(10);
mqtt.publishf(topic_pressure.c_str(), "%.2f", sensor_readings.pressure);
delay(10);
}
if (sensors_active.bme680) {
String topic_voc = String("thomas/sensor/") + ota.getMAC() + String("/voc");
mqtt.publishf(topic_voc.c_str(), "%.2f", sensor_readings.voc / 1000.0F);
delay(10);
}
if (sensors_active.uv) {
String topic_uvi = String("thomas/sensor/") + ota.getMAC() + String("/uvi");
String topic_uva = String("thomas/sensor/") + ota.getMAC() + String("/uva");
String topic_uvb = String("thomas/sensor/") + ota.getMAC() + String("/uvb");
mqtt.publishf(topic_uvi.c_str(), "%.2f", sensor_readings.uvi);
mqtt.publishf(topic_uva.c_str(), "%.2f", sensor_readings.uva);
mqtt.publishf(topic_uvb.c_str(), "%.2f", sensor_readings.uvb);
delay(10);
}
if (sensors_active.light) {
String topic_lux = String("thomas/sensor/") + ota.getMAC() + String("/lux");
mqtt.publishf(topic_lux.c_str(), "%.2f", sensor_readings.lux);
delay(10);
}
if (sensors_active.sds) {
String topic_pm10 = String("thomas/sensor/") + ota.getMAC() + String("/pm10");
String topic_pm25 = String("thomas/sensor/") + ota.getMAC() + String("/pm25");
mqtt.publishf(topic_pm10.c_str(), "%.2f", sensor_readings.pm10);
mqtt.publishf(topic_pm25.c_str(), "%.2f", sensor_readings.pm25);
delay(10);
}
{
String topic_battery = String("thomas/sensor/") + ota.getMAC() + String("/battery");
mqtt.publishf(topic_battery.c_str(), "%.2f", (sensor_readings.battery/4096.0)*2*3.42);
delay(10);
}
{
String topic_rssi = String("thomas/sensor/") + ota.getMAC() + String("/rssi");
mqtt.publishf(topic_rssi.c_str(), "%d", sensor_readings.rssi);
delay(10);
}
}
/**
@ -879,11 +825,6 @@ void setup()
if (!ota.getMAC().equals("246f28d1a080")) mqtt.subscribe("thomas/sensor/246f28d1a080/json", receiveMqtt);
if (!ota.getMAC().equals("246f28d1eff4")) mqtt.subscribe("thomas/sensor/246f28d1eff4/json", receiveMqtt);
/* temp: publish version */
String topic_version = String("thomas/sensor/") + ota.getMAC() + String("/version");
const char* fw_version_str = String(FW_VERSION).c_str();
mqtt.publish(topic_version.c_str(), fw_version_str, strlen(fw_version_str));
if (WiFi.SSID() == "LNet") {
station_height = 135;
} else if (WiFi.SSID() == "Galaktisches Imperium") {

Loading…
Cancel
Save