Fix Valid data reading

Fix Valid data reading ()
This commit is contained in:
Theo Arends 2019-11-07 14:28:35 +01:00
parent 7581439133
commit 4b884679e6
1 changed files with 3 additions and 2 deletions

View File

@ -46,10 +46,9 @@ struct HIH6 {
bool Hih6Read(void)
{
Wire.beginTransmission(HIH6_ADDR);
// Wire.write(0x00); // Select data register
if (Wire.endTransmission() != 0) { return false; } // In case of error
// delay(40); // Wait for Valid data or use Stale data
delay(40); // Wait for Valid data (Stale data doesn't work. See #6808)
uint8_t data[4];
Wire.requestFrom(HIH6_ADDR, 4);
@ -76,10 +75,12 @@ bool Hih6Read(void)
void Hih6Detect(void)
{
if (Hih6.type) { return; }
if (I2cActive(HIH6_ADDR)) { return; }
if (uptime < 2) { delay(20); } // Skip entering power on comand mode
Hih6.type = Hih6Read();
if (Hih6.type) {
I2cSetActive(HIH6_ADDR);
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, Hih6.types, HIH6_ADDR);
}
}