Skip to content

Commit

Permalink
Add I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
arendst committed Oct 21, 2023
1 parent bd90363 commit bec0c27
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- I2C bus2 support to ADS1115 A/D Converter
- I2C bus2 support to SHTxX temperature and humidity sensor
- I2C bus2 support to HYTxxx temperature and humidity sensor
- I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor

### Breaking Changed

Expand Down
6 changes: 3 additions & 3 deletions I2CDEVICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip
16 | USE_TSL2561 | xsns_16 | TSL2561 | 0x29, 0x39, 0x49 | | Light intensity sensor
17 | USE_MGS | xsns_19 | Grove | 0x04 | | Multichannel gas sensor
18 | USE_SGP30 | xsns_21 | SGP30 | 0x58 | | Gas (TVOC) and air quality sensor
19 | USE_SI1145 | xsns_24 | SI1145 | 0x60 | | Ultra violet index and light sensor
19 | USE_SI1145 | xsns_24 | SI1146 | 0x60 | | Ultra violet index and light sensor
19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | | Ultra violet index and light sensor
19 | USE_SI1145 | xsns_24 | SI1145 | 0x60 | Yes | Ultra violet index and light sensor
19 | USE_SI1145 | xsns_24 | SI1146 | 0x60 | Yes | Ultra violet index and light sensor
19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | Yes | Ultra violet index and light sensor
20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | | Temperature sensor
21 | USE_APDS9960 | xsns_27 | APDS9960 | 0x39 | | Proximity ambient light RGB and gesture sensor
22 | USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x26 | | 8-bit I/O expander
Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- I2C bus2 support to ADS1115 A/D Converter
- I2C bus2 support to SHTxX temperature and humidity sensor
- I2C bus2 support to HYTxxx temperature and humidity sensor
- I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor

### Breaking Changed

Expand Down
33 changes: 16 additions & 17 deletions tasmota/tasmota_xsns_sensor/xsns_24_si1145.ino
Original file line number Diff line number Diff line change
Expand Up @@ -188,27 +188,24 @@ uint16_t si1145_infrared;
uint16_t si1145_uvindex;

bool si1145_type = false;
uint8_t si1145_bus = 0;
uint8_t si1145_valid = 0;

/********************************************************************************************/

uint8_t Si1145ReadByte(uint8_t reg)
{
return I2cRead8(SI114X_ADDR, reg);
uint8_t Si1145ReadByte(uint8_t reg) {
return I2cRead8(SI114X_ADDR, reg, si1145_bus);
}

uint16_t Si1145ReadHalfWord(uint8_t reg)
{
return I2cRead16LE(SI114X_ADDR, reg);
uint16_t Si1145ReadHalfWord(uint8_t reg) {
return I2cRead16LE(SI114X_ADDR, reg, si1145_bus);
}

void Si1145WriteByte(uint8_t reg, uint16_t val)
{
I2cWrite8(SI114X_ADDR, reg, val);
void Si1145WriteByte(uint8_t reg, uint16_t val) {
I2cWrite8(SI114X_ADDR, reg, val, si1145_bus);
}

uint8_t Si1145WriteParamData(uint8_t p, uint8_t v)
{
uint8_t Si1145WriteParamData(uint8_t p, uint8_t v) {
Si1145WriteByte(SI114X_WR, v);
Si1145WriteByte(SI114X_COMMAND, p | SI114X_SET);
return Si1145ReadByte(SI114X_RD);
Expand Down Expand Up @@ -324,13 +321,15 @@ bool Si1145Read(void)
return true;
}

void Si1145Detect(void)
{
if (!I2cSetDevice(SI114X_ADDR)) { return; }
void Si1145Detect(void) {
for (si1145_bus = 0; si1145_bus < 2; si1145_bus++) {
if (!I2cSetDevice(SI114X_ADDR, si1145_bus)) { continue; }

if (Si1145Begin()) {
si1145_type = true;
I2cSetActiveFound(SI114X_ADDR, "SI1145");
if (Si1145Begin()) {
si1145_type = true;
I2cSetActiveFound(SI114X_ADDR, "SI1145", si1145_bus);
return;
}
}
}

Expand Down

0 comments on commit bec0c27

Please sign in to comment.