We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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
`` /*********************************************************************************************\
#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...
The text was updated successfully, but these errors were encountered:
In next pre-release
Sorry, something went wrong.
v5.12.0b - Add support for sensor SHTC3
664cdeb
5.12.0b * Add support for sensor SHTC3 (#1967)
d3a9b80
5.12.0b * Add support for sensor SHTC3 (arendst#1967)
No branches or pull requests
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
``
/*********************************************************************************************\
*********************************************************************************************/
#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...
The text was updated successfully, but these errors were encountered: