mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 04:36:31 +00:00
Add HYT I2c bus2 support
This commit is contained in:
parent
2cabbc68c3
commit
f05470bf81
@ -105,7 +105,7 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip
|
|||||||
65 | USE_ADE7880 | xnrg_23 | ADE7880 | 0x38 | | Energy monitor
|
65 | USE_ADE7880 | xnrg_23 | ADE7880 | 0x38 | | Energy monitor
|
||||||
66 | USE_PCF85363 | xsns_99 | PCF85363 | 0x51 | | Real time clock
|
66 | USE_PCF85363 | xsns_99 | PCF85363 | 0x51 | | Real time clock
|
||||||
67 | USE_DS3502 | xdrv_61 | DS3502 | 0x28 - 0x2B | | Digital potentiometer
|
67 | USE_DS3502 | xdrv_61 | DS3502 | 0x28 - 0x2B | | Digital potentiometer
|
||||||
68 | USE_HYT | xsns_97 | HYTxxx | 0x28 | | Temperature and Humidity sensor
|
68 | USE_HYT | xsns_97 | HYTxxx | 0x28 | Yes | Temperature and Humidity sensor
|
||||||
69 | USE_SGP40 | xsns_98 | SGP40 | 0x59 | | Gas (TVOC) and air quality
|
69 | USE_SGP40 | xsns_98 | SGP40 | 0x59 | | Gas (TVOC) and air quality
|
||||||
70 | USE_LUXV30B | xsns_99 | LUXV30B | 0x4A | | DFRobot SEN0390 V30B lux sensor
|
70 | USE_LUXV30B | xsns_99 | LUXV30B | 0x4A | | DFRobot SEN0390 V30B lux sensor
|
||||||
71 | USE_QMC5883L | xsns_33 | QMC5883L | 0x0D | | Magnetic Field Sensor
|
71 | USE_QMC5883L | xsns_33 | QMC5883L | 0x0D | | Magnetic Field Sensor
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
struct HYT {
|
struct HYT {
|
||||||
float humidity = NAN;
|
float humidity = NAN;
|
||||||
float temperature = NAN;
|
float temperature = NAN;
|
||||||
|
uint8_t bus;
|
||||||
uint8_t valid = 0;
|
uint8_t valid = 0;
|
||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
char name[6] = "HYT";
|
char name[6] = "HYT";
|
||||||
@ -44,14 +45,16 @@ struct HYT {
|
|||||||
bool HYT_Read(void) {
|
bool HYT_Read(void) {
|
||||||
if (HYT.valid) { HYT.valid--; }
|
if (HYT.valid) { HYT.valid--; }
|
||||||
|
|
||||||
Wire.beginTransmission(HYT_ADDR);
|
TwoWire& myWire = I2cGetWire(HYT.bus);
|
||||||
Wire.requestFrom(HYT_ADDR, 4);
|
if (&myWire == nullptr) { return false; } // No valid I2c bus
|
||||||
if (Wire.available() == 4) {
|
myWire.beginTransmission(HYT_ADDR);
|
||||||
uint8_t data1 = Wire.read();
|
myWire.requestFrom(HYT_ADDR, 4);
|
||||||
uint8_t data2 = Wire.read();
|
if (myWire.available() == 4) {
|
||||||
uint8_t data3 = Wire.read();
|
uint8_t data1 = myWire.read();
|
||||||
uint8_t data4 = Wire.read();
|
uint8_t data2 = myWire.read();
|
||||||
Wire.endTransmission();
|
uint8_t data3 = myWire.read();
|
||||||
|
uint8_t data4 = myWire.read();
|
||||||
|
myWire.endTransmission();
|
||||||
|
|
||||||
// Convert the data to 14-bits
|
// Convert the data to 14-bits
|
||||||
float humidity = ((((data1 & 0x3F) * 256) + data2) * 100.0) / 16383.0;
|
float humidity = ((((data1 & 0x3F) * 256) + data2) * 100.0) / 16383.0;
|
||||||
@ -72,9 +75,13 @@ bool HYT_Read(void) {
|
|||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
|
|
||||||
void HYT_Detect(void) {
|
void HYT_Detect(void) {
|
||||||
if (I2cSetDevice(HYT_ADDR)) {
|
for (HYT.bus = 0; HYT.bus < 2; HYT.bus++) {
|
||||||
I2cSetActiveFound(HYT_ADDR, "HYT");
|
if (!I2cSetDevice(HYT_ADDR, HYT.bus)) { continue; }
|
||||||
|
if (HYT_Read()) {
|
||||||
|
I2cSetActiveFound(HYT_ADDR, "HYT", HYT.bus);
|
||||||
HYT.count = 1;
|
HYT.count = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user