<solved> SHT20 & ESPGuido
Posted: Tue Oct 06, 2015 12:09 pm
I'm attempting to connect an SHT20 (compatible with SHT21) with an ESP8266 in Arduino mode. I have 3 identical boards - on all of them, the IAQ sensor and barometric pressure sensor works perfectly, so I know the i2c bus is OK, but none of the SHT20's work. I'm using the standard SHT21 library - has anyone tried/been able to get an SHT to work with an ESP?
Here's the relevant library function - Wire.begin() has already been called - it was hanging on the commented-out //wait so I substituted the return -999 code instead, and that's what it returns: -999.
Here's the relevant library function - Wire.begin() has already been called - it was hanging on the commented-out //wait so I substituted the return -999 code instead, and that's what it returns: -999.
Code: Select all
unsigned int SHT21Class::readData(byte command)
{
unsigned int result;
Wire.beginTransmission(0x40); //begin
Wire.write(command); //send the pointer location
delay(100);
Wire.endTransmission(); //end
if (Wire.requestFrom(0x40, 3) != 3) { // Request three bytes
return -999;
}
// Wire.requestFrom(0x40, 3);
// while(Wire.available() < 3)
// {
// //wait
// }
//Store the result
result = ((Wire.read()) << 8);
result += Wire.read();
result &= ~0x0003; // clear two low bits (status bits)
return result;
}