I've been scratching my head on trying to get a SHT25 humidity sensor to work.
First off, according to many sources, its I2C address should be 0x40. When using the I2C scanner, I found that the address is in reality 0x38. Must have to do with the fact that it is probably a chinese version...
I've tried almost all the libraries that I could find..... Everytime, I get data that do not seem to make sense.
I have tried with 3 differents sensors.... Same result.
According to the Datasheet, command shall be 0xE3, 0xE5, 0xF3 or 0xF5....None of them worked.... no matter what I do, the only thing that happen, is that I get a value of 24 as the first byte.
Anyone has an idea of what I'm doing wrong ???
This is the latest code that I've tried, hoping to be able to see each bytes being read ...
#include<Wire.h>
// SHT25 I2C address is normally 0x40(64)
#define Addr 0x38 // SHT25 I2C address is 0x38 as per I2C scanner
// unsigned int data[8];
//char data[8];
byte data[8];
void setup()
{
// Initialise I2C communication as MASTER
Wire.begin();
// Initialise serial communication, set baud rate = 9600
Serial.begin(9600);
Serial.println("Init done..");
}
void loop()
{
Wire.beginTransmission(Addr); // Send humidity measurement command, NO HOLD master
Wire.write(0xe3); // tries 0xF3, 0XF5, 0xE3, 0xE5
delay(1);
Wire.endTransmission();
delay(500);
Wire.requestFrom(Addr, 2); // Request 2 bytes of data
if(Wire.available() == 2)
{
data[0] = Wire.read();
data[1] = Wire.read();
//data[2] = Wire.read();
//data[3] = Wire.read();
}
Serial.print("Byte 1 = ");
Serial.println(data[0]);
Serial.print("Byte 2 = ");
Serial.println(data[1]);
//Serial.print("Byte 3 = ");
//Serial.println(data[2]);
//Serial.print("Byte 4 = ");
//Serial.println(data[3]);
delay(300);
}
According to the datasheet, you need to combine the 2 bytes in order to calculate the Humidity/Temperature....
"Default resolution is set to 12 bit relative humidity and
14 bit temperature reading. Measured data are transferred
in two byte packages, i.e. in frames of 8 bit length where
the most significant bit (MSB) is transferred first (left
aligned). Each byte is followed by an acknowledge bit. The
two status bits, the last bits of LSB, must be set to ‘0’
before calculating physical values. In the example of
Figure 15 and Figure 16, the transferred 16 bit relative
humidity data is ‘0110’0011’0101’0000’ = 25424.
And also, no matter if I try to read RH or Temp, I always, always get 24 & 0
That doesn't make sense, as values should be different and/or changes...
2 bytes for each value. Humidity is a different call. The 14 bit temperature is in the 2 bytes you receive. Hex will be easier to see exactly what you are getting.
I believe that's what I'm doing: look at page 8 of the datasheet, where they mention the potential commands. The ones that end by '1' are all read command, while those that finish by '0' are write command....
Am I correct in my assumptions ?
And it looks like like most libraries does .... begin transmission then follow with a command...