41 lines
828 B
C++
41 lines
828 B
C++
#include "Adafruit_SHT31.h"
|
|
|
|
Adafruit_SHT31 sht31 = Adafruit_SHT31();
|
|
|
|
#define SHT31_RST_PIN 16
|
|
|
|
void resetSensor() {
|
|
pinMode(SHT31_RST_PIN, OUTPUT);
|
|
digitalWrite(SHT31_RST_PIN, LOW);
|
|
delay(10);
|
|
digitalWrite(SHT31_RST_PIN, HIGH);
|
|
delay(10);
|
|
}
|
|
|
|
void setup() {
|
|
// put your setup code here, to run once:
|
|
|
|
Serial.begin(9600);
|
|
while (!Serial);
|
|
Serial.println ("Initiating test");
|
|
|
|
if (!sht31.begin(0X44)) {
|
|
Serial.println("Couldn't find SHT31");
|
|
while (1) delay(100);
|
|
}
|
|
Serial.println("SHT31 Found!");
|
|
float t = sht31.readTemperature();
|
|
float h = sht31.readHumidity();
|
|
|
|
if (!isnan(t)) {
|
|
Serial.print("Temperature (C)= "); Serial.println(t);}
|
|
|
|
if (!isnan(h)) {
|
|
Serial.print("Humidity = "); Serial.println(h); }
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
|
|
}
|