/Arduino-SHT2x

An Arduino compatible library for the Sensirion SHT2x, Silicon Labs Si702x and Measurement Specialties HTU21 temperature sensors

Primary LanguageC++GNU General Public License v3.0GPL-3.0

Sensirion SHT2x Arduino Library

Note: These devices are all NRD except for the TE parts.

This repository contains an Arduino library for the following Sensirion devices:

The library uses I²C transactions and allows to select the I²C controller if there is more than one.

Usage

#include <Wire.h>   // #include <i2c_t3.h> on the Teensy platform.
#include "src/SHT2x.h"

SHT2x sensor(Wire);
//HTU2x sensor(Wire);
//Si702x sensor(Wire);

void setup() {
  Wire.begin();
  Serial.begin(115200);
}

void loop() {
  // The call to readTemp() will automatically block for the time the measurement takes to complete
  Serial.print(sensor.readTemp());  // Read the temperarture as a float in °C
  Serial.println(" °C");
  Serial.print(sensor.readHumdity());  // Read the humidity as a float in %rH
  Serial.println(" %rH");
  delay(2000);
}

Installation

Currently the library does not support the Arduino library manager, so it is highly recommended to copy the full library to a subfolder called

src/

within your Arduino project.