0

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);
}
5
  • The RESET pin is active low, not active high. Commented Feb 3, 2021 at 22:22
  • I'm hitting both so it should be resetting. Interesting. Commented Feb 3, 2021 at 22:32
  • 1
    Except you end up on LOW so it remains stuck in reset. You need to end up on HIGH. Commented Feb 3, 2021 at 22:35
  • 1
    You should really be asking yourself why it's drifting though... it's rated at 0.03C/year drift according to the datasheet... Commented Feb 3, 2021 at 22:36
  • @Majenko It will drift 10 degrees in a matter of 15 min. I gave up on that and ordered different units all together. This is a last ditch effort to get something useful out of the device. Commented Feb 3, 2021 at 22:40

1 Answer 1

2

You need to give a brief LOW pulse, not a long HIGH pulse:

In setup:

pinMode(reset_pin, OUTPUT);
digitalWrite(reset_pin, HIGH);

When you want to reset:

digitalWrite(pin_reset, LOW);
delay(1);
digitalWrite(pin_reset, HIGH);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.