forked from Elron_dev/elbear_arduino_bsp
33 lines
587 B
C++
33 lines
587 B
C++
|
|
/*
|
|
The AHT10 temperature and humidity sensor connected to I2C is used for this test.
|
|
*/
|
|
|
|
#include "AHT10.h"
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
Serial.println();
|
|
|
|
Wire.begin();
|
|
if (! AHT10::begin()) {
|
|
Serial.println(F("AHT10 not detected!"));
|
|
Serial.flush();
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
float temp, hum;
|
|
|
|
delay(2000);
|
|
if (AHT10::measure(&temp, &hum)) {
|
|
Serial.print(F("Temperature is "));
|
|
Serial.print(temp);
|
|
Serial.print(F(" C, humidity is "));
|
|
Serial.print(hum);
|
|
Serial.println('%');
|
|
} else {
|
|
Serial.println(F("AHT10 read error!"));
|
|
}
|
|
}
|