How to read a temperature FROM I2C / stts22htr component

Hello,

I'm trying to read the temperature without success with the bellow code :

  Serial.println("Scanning...");
  byte error, address;
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address<16) Serial.print("0");
      Serial.println(address,HEX);
      addr = address;
      nDevices++;
    } else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
Log :
11:07:07.672 -> Scanning...
11:07:07.672 -> I2C device found at address 0x4A

As I can see the temperature module has been detected with the address 0x4A.

    uint16_t addr = 0x4A;
    Wire.beginTransmission(addr);
    Wire.write(0); 
    Wire.endTransmission(false);
    Wire.requestFrom(addr, 2);

    byte h = Wire.read();
    byte l = Wire.read();
   Serial.println( h);
   Serial.println( l);

Log :
11:21:45.051 -> 0
11:21:45.051 -> 0

Somebody is able to help me ?
May be the wrong part is «Wire.write(0); » .... not sure to understood correctly the datasheet

Thanks in advance for your help.

the spec states

0x4A is not a valid address matching the spec.

also seems the t° is stored in registers 6 and 7

Arf, STTS22HTR mentionned on the product spec but STS30 used on the product ...
Thank for your help :wink:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.