mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-29 16:37:17 +02:00
use "arduino-sht" library for sht3x and sht4x
This commit is contained in:
@ -1,29 +1,33 @@
|
||||
#include <AirGradient.h>
|
||||
|
||||
#if defined(ESP8266)
|
||||
AirGradient ag(DIY_BASIC);
|
||||
#else
|
||||
AirGradient ag(ONE_INDOOR);
|
||||
#endif
|
||||
|
||||
void failedHandler(String msg);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Hello");
|
||||
Wire.begin(ag.getI2cSdaPin(), ag.getI2cSclPin());
|
||||
|
||||
if (ag.sht3x.begin(Wire, Serial) == false) {
|
||||
if (ag.sht.begin(Wire) == false) {
|
||||
failedHandler("SHT3x init failed");
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (ag.sht3x.measure()) {
|
||||
float hum = ag.sht3x.getRelativeHumidity();
|
||||
float temp = ag.sht3x.getTemperature();
|
||||
|
||||
if (ag.sht.measure()) {
|
||||
float hum = ag.sht.getRelativeHumidity();
|
||||
float temp = ag.sht.getTemperature();
|
||||
Serial.printf("Get temperature: %f\r\n", temp);
|
||||
Serial.printf(" Get humidity: %f\r\n", hum);
|
||||
} else {
|
||||
Serial.println("Measure sht3x failed");
|
||||
Serial.println("Measure failed");
|
||||
}
|
||||
delay(5000);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void failedHandler(String msg) {
|
Reference in New Issue
Block a user