I have a sht30 that will output correct temperature readings for about 5 min and then will drift off.
So I'm trying to hit the reset every few seconds to keep the readings accurate.
I am on a nano connecting d4 to the sht30 reset pin, but I don't appear to be resetting. My temp still drifts.
How do you correctly hit the reset on a sht30?
code:
#include <Wire.h>
// SHT31 I2C address is 0x44(68)
#define Addr 0x45
int reset_pin = 3; // reset pin is set to d4 on board.
int counter = 0; //reset counter
void setup()
{
// Initialise I2C communication as MASTER
Wire.begin();
// Initialise serial communication, set baud rate = 9600
Serial.begin(115200);
delay(300);
}
void loop()
{
unsigned int data[6];
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send 16-bit command byte
Wire.write(0x2C);
Wire.write(0x06);
// Stop I2C transmission
Wire.endTransmission();
delay(300);
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Stop I2C Transmission
Wire.endTransmission();
// Request 6 bytes of data
Wire.requestFrom(Addr, 6);
// Read 6 bytes of data
// temp msb, temp lsb, temp crc, hum msb, hum lsb, hum crc
if (Wire.available() == 6)
{
data[0] = Wire.read();
data[1] = Wire.read();
data[2] = Wire.read();
data[3] = Wire.read();
data[4] = Wire.read();
data[5] = Wire.read();
}
// Convert the data
int temp = (data[0] * 256) + data[1];
float cTemp = -45.0 + (175.0 * temp / 65535.0);
float fTemp = (cTemp * 1.8) + 32.0;
float humidity = (100.0 * ((data[3] * 256.0) + data[4])) / 65535.0;
// Output data to serial monitor
Serial.print("Temperature in Celsius :");
Serial.print(cTemp);
Serial.println(" C");
Serial.print("Temperature in Fahrenheit :");
Serial.print(fTemp);
Serial.println(" F");
Serial.print("Relative Humidity :");
Serial.print(humidity);
Serial.println(" %RH");
delay(500);
if(counter == 25){
digitalWrite(reset_pin, HIGH); // sets the digital pin 13 on
delay(1000); // waits for a second
digitalWrite(reset_pin, LOW); // sets the digital pin 13 off
delay(1000);
counter = 0;
}
counter++;
Serial.println(counter);
}