diff --git a/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.h b/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.h index bb4f846e54b1..d7076a9e2e36 100644 --- a/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.h +++ b/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.h @@ -1,6 +1,6 @@ /**************************************************************************/ /*! - @file Adafruit_TSL2591.h + @file Adafruit_TSL2591.h @author KT0WN (adafruit.com) This is a library for the Adafruit TSL2591 breakout board diff --git a/lib/lib_i2c/BlueRobotics_MS5837_Library/MS5837.cpp b/lib/lib_i2c/BlueRobotics_MS5837_Library/MS5837.cpp index 3431e81272ab..b93f2656a74b 100644 --- a/lib/lib_i2c/BlueRobotics_MS5837_Library/MS5837.cpp +++ b/lib/lib_i2c/BlueRobotics_MS5837_Library/MS5837.cpp @@ -223,11 +223,11 @@ float MS5837::temperature() { // In order to calculate the correct depth, the actual atmospheric pressure should be measured once in air, and // that value should subtracted for subsequent depth calculations. float MS5837::depth() { - return (pressure(MS5837::Pa)-101300)/(fluidDensity*9.80665); + return (pressure(MS5837::Pa)-101300)/(fluidDensity*9.80665f); } float MS5837::altitude() { - return (1-pow((pressure()/1013.25),.190284))*145366.45*.3048; + return (1-pow((pressure()/1013.25f),.190284f))*145366.45f*.3048f; } diff --git a/tasmota/tasmota_xsns_sensor/xsns_128_ms5837.ino b/tasmota/tasmota_xsns_sensor/xsns_128_ms5837.ino index c36c21a966e4..61c179efd67a 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_128_ms5837.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_128_ms5837.ino @@ -56,8 +56,11 @@ void MS5837init(void) { } #ifdef USE_WEBSERVER -const char HTTP_SNS_MS5837[] PROGMEM = - "{s}MS5837 Temperature {m}%s " D_UNIT_DEGREE "%c{e}{s}MS5837 Pressure {m}%s %s{e}{s}Inches Water {m}%s in{e}"; // {s} = , {m} = , {e} = +const char HTTP_SNS_MS5837_DEFAULT[] PROGMEM = + "{s}MS5837 Temperature {m}%s " D_UNIT_DEGREE "%c{e}{s}MS5837 Pressure {m}%s %s{e}"; // {s} = , {m} = , {e} = +const char HTTP_SNS_MS5837_INCHES_WATER[] PROGMEM = + "{s}Inches Water {m}%s in{e}"; // {s} = , {m} = , {e} = +char HTTP_SNS_MS5837_DUAL[118]; #endif // USE_WEBSERVER void MS5837Show(bool json) { @@ -65,34 +68,44 @@ void MS5837Show(bool json) { float ms5837Pres; float pressure_delta; float inches_water; - - sensor_ms5837.read(); - ms5837Temp = ConvertTemp(sensor_ms5837.temperature()); - ms5837Pres = ConvertPressure(sensor_ms5837.pressure()); - if (I2cEnabled(XI2C_88)) { //pick up here - pressure_delta = sensor_ms5837.pressure() - bmp_sensors[0].bmp_pressure + pressureOffset; - inches_water = pressure_delta*0.401463078662f; - AddLog(LOG_LEVEL_DEBUG, PSTR("Pressure Delta: %f | Inches Water: %f"), pressure_delta, inches_water); - } char temperature_str[8]; - ext_snprintf_P(temperature_str, sizeof(temperature_str), PSTR("%1_f"), &ms5837Temp); char pressure_str[8]; - ext_snprintf_P(pressure_str, sizeof(pressure_str), PSTR("%1_f"), &ms5837Pres); char inchesWater_str[8]; - ext_snprintf_P(inchesWater_str, sizeof(inchesWater_str), PSTR("%1_f"), &inches_water); - if (json) { - // consolidate to one line - ResponseAppend_P(PSTR(",\"MS5837\":{\"Temperature\":%s,"), temperature_str); - ResponseAppend_P(PSTR("\"Pressure\":%s,"), pressure_str); - ResponseAppend_P(PSTR("\"Inches Water\":%s}"), inchesWater_str); + + if (I2cEnabled(XI2C_88)) { + sensor_ms5837.read(); + ms5837Temp = ConvertTemp(sensor_ms5837.temperature()); + ms5837Pres = ConvertPressure(sensor_ms5837.pressure()); + ext_snprintf_P(temperature_str, sizeof(temperature_str), PSTR("%1_f"), &ms5837Temp); + ext_snprintf_P(pressure_str, sizeof(pressure_str), PSTR("%1_f"), &ms5837Pres); + if (json) { + ResponseAppend_P(PSTR(",\"MS5837\":{\"Temperature\":%s,\"Pressure\":%s"), temperature_str, pressure_str); + } + if (I2cEnabled(XI2C_10)) { + pressure_delta = sensor_ms5837.pressure() - bmp_sensors[0].bmp_pressure + pressureOffset; + inches_water = pressure_delta*0.401463078662f; + ext_snprintf_P(inchesWater_str, sizeof(inchesWater_str), PSTR("%1_f"), &inches_water); + if (json) { + ResponseAppend_P(PSTR(",\"Inches Water\":%s"),inchesWater_str); + } + } + if (json) { + ResponseAppend_P(PSTR("}")); + #ifdef USE_WEBSERVER } else { - WSContentSend_PD(HTTP_SNS_MS5837, temperature_str, TempUnit(), pressure_str, PressureUnit().c_str(), inchesWater_str); + if (I2cEnabled(XI2C_10)) { + strncat(HTTP_SNS_MS5837_DUAL,HTTP_SNS_MS5837_DEFAULT,sizeof(HTTP_SNS_MS5837_DUAL)); + strncat(HTTP_SNS_MS5837_DUAL,HTTP_SNS_MS5837_INCHES_WATER,sizeof(HTTP_SNS_MS5837_DUAL)); + WSContentSend_PD(HTTP_SNS_MS5837_DUAL, temperature_str, TempUnit(), pressure_str, PressureUnit().c_str(), inchesWater_str); + } + else { + WSContentSend_PD(HTTP_SNS_MS5837_DEFAULT, temperature_str, TempUnit(), pressure_str, PressureUnit().c_str()); + } #endif // USE_WEBSERVER } - AddLog(LOG_LEVEL_DEBUG, PSTR("BMP Pressure: %f"), bmp_sensors[0].bmp_pressure); + } } - /*********************************************************************************************\ * Interface \*********************************************************************************************/ diff --git a/tasmota/tasmota_xsns_sensor/xsns_57_tsl2591.ino b/tasmota/tasmota_xsns_sensor/xsns_57_tsl2591.ino index 4dc4d1abb4c3..3cde6de9bca1 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_57_tsl2591.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_57_tsl2591.ino @@ -39,8 +39,8 @@ uint8_t tsl2591_type = 0; uint8_t tsl2591_valid = 0; float tsl2591_lux = 0; -tsl2591Gain_t gain_enum_array[4] = {TSL2591_GAIN_LOW,TSL2591_GAIN_MED,TSL2591_GAIN_HIGH,TSL2591_GAIN_MAX}; -tsl2591IntegrationTime_t int_enum_array[6] = {TSL2591_INTEGRATIONTIME_100MS,TSL2591_INTEGRATIONTIME_200MS,TSL2591_INTEGRATIONTIME_300MS,TSL2591_INTEGRATIONTIME_400MS,TSL2591_INTEGRATIONTIME_500MS,TSL2591_INTEGRATIONTIME_600MS}; +tsl2591Gain_t const gain_enum_array[4] PROGMEM = {TSL2591_GAIN_LOW,TSL2591_GAIN_MED,TSL2591_GAIN_HIGH,TSL2591_GAIN_MAX}; +tsl2591IntegrationTime_t const int_enum_array[6] PROGMEM = {TSL2591_INTEGRATIONTIME_100MS,TSL2591_INTEGRATIONTIME_200MS,TSL2591_INTEGRATIONTIME_300MS,TSL2591_INTEGRATIONTIME_400MS,TSL2591_INTEGRATIONTIME_500MS,TSL2591_INTEGRATIONTIME_600MS}; void Tsl2591Init(void) { @@ -81,7 +81,7 @@ void Tsl2591Show(bool json) char lux_str[10]; dtostrf(tsl2591_lux, sizeof(lux_str)-1, 3, lux_str); if (json) { - ResponseAppend_P(PSTR(",\"TSL2591\":{\"" D_JSON_ILLUMINANCE "\":%s}"), lux_str); + ResponseAppend_P(PSTR(",\"TSL2591\":{\"" D_JSON_ILLUMINANCE "\":%s}"), lux_str); #ifdef USE_DOMOTICZ if (0 == TasmotaGlobal.tele_period) { DomoticzSensor(DZ_ILLUMINANCE, tsl2591_lux); } #endif // USE_DOMOTICZ diff --git a/tools/decode-status.py b/tools/decode-status.py index e6d90d7e721c..00804006a0f0 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -246,8 +246,8 @@ "USE_INA219","USE_SHT3X","USE_MHZ19","USE_TSL2561", "USE_SENSEAIR","USE_PMS5003","USE_MGS","USE_NOVA_SDS", "USE_SGP30","USE_SR04","USE_SDM120","USE_SI1145", - "USE_SDM630","USE_LM75AD","USE_APDS9960","USE_TM1638","USE_MS5837" - ],[ + "USE_SDM630","USE_LM75AD","USE_APDS9960","USE_TM1638" + ],[ "USE_MCP230xx","USE_MPR121","USE_CCS811","USE_MPU6050", "USE_MCP230xx_OUTPUT","USE_MCP230xx_DISPLAYOUTPUT","USE_HLW8012","USE_CSE7766", "USE_MCP39F501","USE_PZEM_AC","USE_DS3231","USE_HX711",