Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SHTC3 temperature and humidity i2c sensor #1967

Closed
eugentib opened this issue Feb 19, 2018 · 1 comment
Closed

Add support for SHTC3 temperature and humidity i2c sensor #1967

eugentib opened this issue Feb 19, 2018 · 1 comment

Comments

@eugentib
Copy link

eugentib commented Feb 19, 2018

I modified the code (xsns_14_sht3x.ino) to support the SHTC3 sensor

It's not very elegant, but it works.
This is the modified code

``
/*********************************************************************************************\

  • SHT3X - Temperature and Humidy
  • I2C Address: 0x44 or 0x45
    *********************************************************************************************/

#define SHT3X_ADDR_GND 0x44 // address pin low (GND)
#define SHT3X_ADDR_VDD 0x45 // address pin high (VDD)
#define SHTC3_ADDR 0x70 // address for shtc3 sensor

uint8_t sht3x_type = 0;
uint8_t sht3x_address;
uint8_t sht3x_addresses[] = { SHT3X_ADDR_GND, SHT3X_ADDR_VDD, SHTC3_ADDR};

bool Sht3xRead(float &t, float &h)
{
unsigned int data[6];

t = NAN;
h = NAN;

if(sht3x_address==SHTC3_ADDR){
Wire.beginTransmission(sht3x_address);
Wire.write(0x35); // Wake from
Wire.write(0x17); // sleep
Wire.endTransmission();
Wire.beginTransmission(sht3x_address);
Wire.write(0x78); // Dissable clock stretching ( I don't think that wire library support clock stretching )
Wire.write(0x66); // High resolution
}else{
Wire.beginTransmission(sht3x_address);
Wire.write(0x2C); // Enable clock stretching
Wire.write(0x06); // High repeatability
}
if (Wire.endTransmission() != 0) { // Stop I2C transmission
return false;
}
delay(20); // Timing verified with logic analyzer (10 is to short)
Wire.requestFrom(sht3x_address, (uint8_t)6); // Request 6 bytes of data
for (int i = 0; i < 6; i++) {
data[i] = Wire.read(); // cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc
};
t = ConvertTemp((float)((((data[0] << 8) | data[1]) * 175) / 65535.0) - 45);
h = (float)((((data[3] << 8) | data[4]) * 100) / 65535.0);
return (!isnan(t) && !isnan(h));
}

/********************************************************************************************/
`
P.S.
I don't understand why insert code doesn't work...

@arendst
Copy link
Owner

arendst commented Feb 19, 2018

In next pre-release

arendst added a commit that referenced this issue Feb 19, 2018
5.12.0b
 * Add support for sensor SHTC3 (#1967)
@arendst arendst closed this as completed Feb 23, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.12.0b
 * Add support for sensor SHTC3 (arendst#1967)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants