Arduino Guide
功能:
初始化SHT30温湿度传感器
函数原型:
void Begin()
功能:
刷新检测数据
1.需要调用该API后才能获取新的检测数值
函数原型:
uint8_t UpdateData()
功能:
读取SHT30检测到的温度
函数原型:
float GetTemperature(TemperatureScale Degree = Cel)
功能:
读取SHT30检测到的湿度
函数原型:
float GetRelHumidity()
使用示例:
#include <M5EPD.h>
char temStr[10],humStr[10];
float tem,hum;
M5EPD_Canvas canvas(&M5.EPD);
void setup(){
M5.begin();
M5.SHT30.Begin();
M5.EPD.SetRotation(90);
M5.EPD.Clear(true);
canvas.createCanvas(400, 300);
canvas.setTextSize(2);
}
void loop(){
M5.SHT30.UpdateData();
tem = M5.SHT30.GetTemperature();
hum = M5.SHT30.GetRelHumidity();
Serial.printf("Temperatura: %2.2f*C Humedad: %0.2f%%\r\n", tem, hum);
dtostrf(tem, 2, 2 , temStr);
dtostrf(hum, 2, 2 , humStr);
canvas.drawString("Temperatura:" + String(temStr) + "*C", 100, 100);
canvas.drawString("Humedad:" + String(humStr) , 100, 200);
canvas.pushCanvas(0,300,UPDATE_MODE_A2);
delay(1000);
}