-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
In the file "WEMOS_SHT3x_Arduino_Library/src/WEMOS_SHT3X.cpp", in the function "get()", the second test does not work.
When requesting 6 bytes, it is impossible that more than 6 bytes will be received. After 6 bytes have been read, the Wire.available() always returns zero. In case of an I2C bus error, the Wire.available() also returns zero.
I suggest to remove those lines.
A test can be added to check if the Wire.requestFrom() was okay:
// Request 6 bytes of data
Wire.requestFrom(_address, (uint8_t) 6);
// Test if 6 bytes are received
if (Wire.available()!=6)
return 2;
// Read 6 bytes of data
// cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc
for (int i=0;i<6;i++) {
data[i]=Wire.read();
};
// Convert the data
cTemp = ((((data[0] * 256.0) + data[1]) * 175) / 65535.0) - 45;
fTemp = (cTemp * 1.8) + 32;
humidity = ((((data[3] * 256.0) + data[4]) * 100) / 65535.0);
return 0;
I have not tested it.
This issue started in the forum: https://forum.arduino.cc/index.php?topic=614231.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels