Simple example for the SHT30
#include "Adafruit_SHT31.h" | |
Adafruit_SHT31 sht30 = Adafruit_SHT31(); | |
void setup() { | |
Serial.begin(9600); | |
while (!Serial) | |
delay(10); // will pause until serial console opens | |
Serial.println("SHT30 test"); | |
if (! sht30.begin(0x45)) { | |
Serial.println("Couldn't find SHT30"); | |
while (1) delay(1); | |
} | |
} | |
void loop() { | |
float t = sht30.readTemperature(); | |
float h = sht30.readHumidity(); | |
if (! isnan(t)) { // check if 'is not a number' | |
Serial.print("Temp *C = "); Serial.println(t); | |
} else { | |
Serial.println("Failed to read temperature"); | |
} | |
if (! isnan(h)) { // check if 'is not a number' | |
Serial.print("Hum. % = "); Serial.println(h); | |
} else { | |
Serial.println("Failed to read humidity"); | |
} | |
Serial.println(); | |
delay(4000); // wait 4 seconds before coming back into the loop | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment