pdf-icon

SHT30

Begin()

Description:

Initializes the SHT30 temperature and humidity sensor.

Syntax:

void Begin()

UpdateData()

Description:

Refreshes the measurement data.

  1. This API must be called to obtain new measurement values.

Syntax:

uint8_t UpdateData()

GetTemperature()

Description:

Reads the temperature measured by the SHT30 sensor.

Syntax:

float GetTemperature(TemperatureScale Degree = Cel)

GetRelHumidity()

Description:

Reads the humidity measured by the SHT30 sensor.

Syntax:

float GetRelHumidity()

Example:

#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("Temperature: %2.2f*C  Humidity: %0.2f%%\r\n", tem, hum);
    dtostrf(tem, 2, 2 , temStr);
    dtostrf(hum, 2, 2 , humStr);
    canvas.drawString("Temperature:" + String(temStr) + "*C", 100, 100);
    canvas.drawString("Humidity:" + String(humStr) , 100, 200);
    canvas.pushCanvas(0,300,UPDATE_MODE_A2);
    delay(1000);
}
On This Page