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

SHT20 sensor reading fails #36

Closed
vcolella opened this issue Oct 16, 2024 · 0 comments · Fixed by #37
Closed

SHT20 sensor reading fails #36

vcolella opened this issue Oct 16, 2024 · 0 comments · Fixed by #37

Comments

@vcolella
Copy link

vcolella commented Oct 16, 2024

Running the example sht-autodetect results in an error in readSample() :

This is my PlatformIO environment:

[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 115200
lib_deps = 
	sensirion/arduino-sht@^1.2.5
build_flags =
    -D DEBUG_SHT_SENSOR

and here's my code

#include <Arduino.h>
#include <Wire.h>
#include "SHTSensor.h"

SHTSensor sht;
// To use a specific sensor instead of probing the bus use this command:
// SHTSensor sht(SHTSensor::SHT3X);

void setup() {
  // put your setup code here, to run once:

  Wire.begin();
  Serial.begin(9600);
  delay(1000); // let serial console settle

  if (sht.init()) {
      Serial.print("init(): success\n");
  } else {
      Serial.print("init(): failed\n");
  }
  sht.setAccuracy(SHTSensor::SHT_ACCURACY_MEDIUM); // only supported by SHT3x

}

void loop() {
  // put your main code here, to run repeatedly:

  if (sht.readSample()) {
      Serial.print("SHT:\n");
      Serial.print("  RH: ");
      Serial.print(sht.getHumidity(), 2);
      Serial.print("\n");
      Serial.print("  T:  ");
      Serial.print(sht.getTemperature(), 2);
      Serial.print("\n");
  } else {
      Serial.print("Error in readSample()\n");
  }

  delay(1000);
}

which outputs :

init(): failed
Error in readSample()
Error in readSample()
Error in readSample()
Error in readSample()
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

Successfully merging a pull request may close this issue.

1 participant