Update xsns_11_veml6070.ino (#23581)

* Update xsns_11_veml6070.ino

in Veml6070Detect check for the presence of both addresses in the bus to avoid misdetection of ATH20/21 (anyone with the device, please confirm this change still detect the device when present)

* Update xsns_16_tsl2561.ino

check the correct ID was returned to avoid misdetection of other sensors.

* Update xsns_57_tsl2591.ino - report channel values in JSON as in TSL2561

Add the raw infrared and broadband channels of the sensor to the JSON report like is done in the driver for TSL2561

* Update xsns_57_tsl2591.ino

Fix var name

* Update xsns_57_tsl2591.ino

Fix variable name
This commit is contained in:
Pedro Ribeiro 2025-07-05 14:15:27 +01:00 committed by GitHub
parent ac51cd7340
commit 407c274229
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View File

@ -30,6 +30,8 @@
--------------------------------------------------------------------------------------------
Version Date Action Description
--------------------------------------------------------------------------------------------
1.0.0.4 20250521 fixed - in Veml6070Detect check for the presence of both addresses in
the bus to avoid misdetection with ATH20/21
1.0.0.3 20181006 fixed - missing "" around the UV Index text
- thanks to Lisa she had tested it on here mqtt system.
@ -128,7 +130,9 @@ char str_uvrisk_text[10];
void Veml6070Detect(void)
{
if (!I2cSetDevice(VEML6070_ADDR_L)) { return; }
// check for presence of both addresses do avoid misdetection
if (!I2cSetDevice(VEML6070_ADDR_L)
|| !I2cSetDevice(VEML6070_ADDR_H)) { return; }
// init the UV sensor
Wire.beginTransmission(VEML6070_ADDR_L);

View File

@ -73,6 +73,9 @@ void Tsl2561Detect(void)
uint8_t id;
Tsl.begin();
if (!Tsl.id(id)) return;
// check the correct ID was returned
// datasheet says reg 0xA (ID) returns 0x1r (r = nibble revision)
if ((id & 0xF0) != 0x10) return;
if (Tsl.on()) {
tsl2561_type = 1;
I2cSetActiveFound(Tsl.address(), tsl2561_types);

View File

@ -38,6 +38,8 @@ Adafruit_TSL2591 tsl = Adafruit_TSL2591();
uint8_t tsl2591_type = 0;
uint8_t tsl2591_valid = 0;
float tsl2591_lux = 0;
uint16_t tsl2591_lux_bb = 0;
uint16_t tsl2591_lux_ir = 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};
@ -62,6 +64,8 @@ void Tsl2591Read(void)
ir = lum >> 16;
full = lum & 0xFFFF;
tsl2591_lux = tsl.calculateLux(full, ir);
tsl2591_lux_bb = full;
tsl2591_lux_ir = ir;
tsl2591_valid = 1;
}
@ -81,7 +85,8 @@ 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,\"IR\":%u,\"Broadband\":%u}"),
lux_str,tsl2591_lux_ir,tsl2591_lux_bb);
#ifdef USE_DOMOTICZ
if (0 == TasmotaGlobal.tele_period) { DomoticzSensor(DZ_ILLUMINANCE, tsl2591_lux); }
#endif // USE_DOMOTICZ