use unit constants

This commit is contained in:
Patrick Haßel 2025-02-14 13:31:44 +01:00
parent 70761270e2
commit e2fbd8f799
2 changed files with 7 additions and 7 deletions

View File

@ -45,12 +45,12 @@ public:
if (bme.remainingReadingMillis() == 0) { if (bme.remainingReadingMillis() == 0) {
if (bme.endReading()) { if (bme.endReading()) {
const auto humidityAbsolute = calculateHumidityAbsolute(bme.temperature, bme.humidity); const auto humidityAbsolute = calculateHumidityAbsolute(bme.temperature, bme.humidity);
mqttPublish(name + "/temperature", bme.temperature, "\xB0""C"); mqttPublish(name + "/temperature", bme.temperature, "TEMPERATURE_CELSIUS");
mqttPublish(name + "/pressure", bme.pressure / 100.0, "hPa"); mqttPublish(name + "/pressure", bme.pressure / 100.0, "PRESSURE_HPA");
mqttPublish(name + "/humidity/relative", bme.humidity, "%"); mqttPublish(name + "/humidity/relative", bme.humidity, "HUMIDITY_RELATIVE_PERCENT");
mqttPublish(name + "/humidity/absolute", humidityAbsolute, "mg/L"); mqttPublish(name + "/humidity/absolute", humidityAbsolute, "HUMIDITY_ABSOLUTE_MGL");
mqttPublish(name + "/gas", bme.gas_resistance / 1000.0, "KOhms"); mqttPublish(name + "/gas", bme.gas_resistance, "RESISTANCE_OHMS");
mqttPublish(name + "/altitude", bme.readAltitude(1013.25), "m"); mqttPublish(name + "/altitude", bme.readAltitude(1013.25), "ALTITUDE_M");
} else { } else {
Log.printf("BME680 \"%s\": Failed to complete reading\n", name.c_str()); Log.printf("BME680 \"%s\": Failed to complete reading\n", name.c_str());
setup(); setup();

View File

@ -48,7 +48,7 @@ private:
Log.printf("TSL2561 \"%s\": Failed to read.\n", name.c_str()); Log.printf("TSL2561 \"%s\": Failed to read.\n", name.c_str());
setup(); setup();
} else { } else {
mqttPublish(name + "/illuminance", illuminance, "lux"); mqttPublish(name + "/illuminance", illuminance, "ILLUMINANCE_LUX");
} }
} }