Arduino Guide
Library Installation
- Launch Arduino IDE.
- Open the Library Manager:
Sketch➔Include Library➔Manage Libraries.... - Search for
Sensirion I2C SHT4xin theFilter your search...field, then clickInstall.
Wiring Diagram
The wiring diagram will be added here.
Example
Low-Precision Temperature and Humidity Measurement
Read temperature and humidity in low-precision mode for lower power consumption and faster response. The measured values are printed to the serial port.
cpp
#include <Arduino.h>
#include <SensirionI2cSht4x.h>
#include <Wire.h>
// macro definitions
// make sure that we use the proper definition of NO_ERROR
#ifdef NO_ERROR
#undef NO_ERROR
#endif
#define NO_ERROR 0
SensirionI2cSht4x sensor;
static char errorMessage[64];
static int16_t error;
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(100);
}
Wire.begin();
sensor.begin(Wire, SHT40_I2C_ADDR_44);
sensor.softReset();
delay(10);
uint32_t serialNumber = 0;
error = sensor.serialNumber(serialNumber);
if (error != NO_ERROR) {
Serial.print("Error trying to execute serialNumber(): ");
errorToString(error, errorMessage, sizeof errorMessage);
Serial.println(errorMessage);
return;
}
Serial.print("serialNumber: ");
Serial.print(serialNumber);
Serial.println();
}
void loop() {
float aTemperature = 0.0;
float aHumidity = 0.0;
delay(20);
error = sensor.measureLowestPrecision(aTemperature, aHumidity);
if (error != NO_ERROR) {
Serial.print("Error trying to execute measureLowestPrecision(): ");
errorToString(error, errorMessage, sizeof errorMessage);
Serial.println(errorMessage);
return;
}
Serial.print("aTemperature: ");
Serial.print(aTemperature);
Serial.print("\t");
Serial.print("aHumidity: ");
Serial.print(aHumidity);
Serial.println();
}