Using a Photon and Wire built-in package I am reading a Honeywell Temp/Humidistat over I2C. At the same time I am using I2C to write to an Adafruit LED mini matrix. After the first update following a power cycle the Honeywell device appears to freeze both temp and humidity.
There are two possibilities I have found by browsing:
- The following suggests that the Honeywell H1H6131 is crappy and stops working by getting stuck like I see. This would be fixed by replacing the device (fairly involved have to disassemble completed project) with a different brand.
2 The following suggests that there is a Wire library issue I can workaround.
I have asked for a code fragment to try this and haven't received a reply yet. This would be quite easy but would leave me uneasy about the basic reliability.
I post here now in hopes somebody has some guidance for me, or just follow me along through the struggle.
Thanks for looking.
FYI the code (not showing the Adafruit stuff)
#define TEMP_SENSOR 0x27 // Temp sensor bus address
#define readDelay 5000 // Sensor read wait, ms
#define TEMPCAL -8 // Calibrate temp sense, F
bool read; // Read, T/F
double temp = 0.0; // Sensed temp, F
int tempInt = 0; // Sensed integer temperature, F
...
void loop()
{
unsigned long now = millis(); // Keep track of time
...
static unsigned int lastRead = 0; // Last read time, ms
read = (now-lastRead) >= readDelay;
if ( read ) lastRead = now;
...
// Read sensors
if ( read )
{
delay(40);
Wire.requestFrom(TEMP_SENSOR, 4, true); // request 4 bytes information
uint8_t b = Wire.read();
uint8_t bend = Wire.endTransmission();
I2C_Status = bend;
//
int rawHum = (b << 8) & 0x3f00;
rawHum |=Wire.read();
hum = roundf(rawHum / 163.83);
//
int rawTemp = (Wire.read() << 6) & 0x3fc0;
rawTemp |=Wire.read() >> 2;
temp = (float(rawTemp)*165.0/16383.0 - 40.0)*1.8 + 32.0 + TEMPCAL; // convert to fahrenheit and calibrate
tempInt = roundf(temp);
}
...
}