26 lines
511 B
Arduino
26 lines
511 B
Arduino
|
#include "Adafruit_Si7021.h"
|
||
|
|
||
|
Adafruit_Si7021 sensor = Adafruit_Si7021();
|
||
|
|
||
|
void setup() {
|
||
|
Serial.begin(115200);
|
||
|
|
||
|
// wait for serial port to open
|
||
|
while (!Serial) {
|
||
|
delay(10);
|
||
|
}
|
||
|
|
||
|
Serial.println("Si7021 test!");
|
||
|
|
||
|
if (!sensor.begin()) {
|
||
|
Serial.println("Did not find Si7021 sensor!");
|
||
|
while (true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
Serial.print("Humidity: "); Serial.print(sensor.readHumidity(), 2);
|
||
|
Serial.print("\tTemperature: "); Serial.println(sensor.readTemperature(), 2);
|
||
|
delay(1000);
|
||
|
}
|