请给我一段SHT30温湿度传感器周期采集模式的代码
时间: 2023-11-30 17:05:16 浏览: 69
好的,以下是一个基于Arduino的SHT30温湿度传感器周期采集模式的代码,每5秒读取一次数据:
```
#include <Wire.h>
#include "Adafruit_SHT31.h" // SHT30 library
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup() {
Serial.begin(9600);
while (!Serial) delay(10);
if (!sht31.begin(0x44)) {
Serial.println("Could not find SHT31 sensor!");
while (1) delay(10);
}
sht31.setAccuracy(SHT31_ACCURACY_HIGH);
Serial.println("SHT31 reading every 5 seconds:");
}
void loop() {
delay(5000);
float temperature = sht31.readTemperature();
float humidity = sht31.readHumidity();
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" *C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
}
```
阅读全文