Chipkit Uno and SHT31 temperature and humidity sensors example

SHT31 is the next generation of Sensirion’s temperature and humidity sensors. It builds on a new CMOSens® sensor chip that is at the heart of Sensirion’s new humidity and temperature platform.

The SHT3x-DIS has increased intelligence, reliability and improved accuracy specifications compared to its predecessor. Its functionality includes enhanced signal processing, two distinctive and user selectable I2C addresses and communication speeds of up to 1 MHz. The DFN package has a footprint of 2.5 x 2.5 mm2 while keeping a height of 0.9 mm.

This allows for integration of the SHT3x-DIS into a great variety of applications.

Features

Fully calibrated, linearized, and temperature compensated digital output
Wide supply voltage range, from 2.4 V to 5.5 V
I2C Interface with communication speeds up to 1 MHz and two user selectable addresses

I bought the following module

If you’re using an Lolin32 simply connect the VIN pin to the 3v3 voltage pin, GND to ground, SCL to I2C Clock (22) and SDA to I2C Data (21).

Here is a layout drawn up in fritzing to illustrate this

Layout

chipkit and sht31

Code

 

This example uses the adafruit sht31 library – https://github.com/adafruit/Adafruit_SHT31

 

[codesyntax lang=”cpp”]

#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"

Adafruit_SHT31 sht31 = Adafruit_SHT31();

void setup()
{
Serial.begin(9600);
if (! sht31.begin(0x44))
{
Serial.println("Couldn't find SHT31");
while (1) delay(1);
}
}

void loop()
{
float t = sht31.readTemperature();
float h = sht31.readHumidity();

if (! isnan(t))
{
Serial.print("Temp *C = "); Serial.println(t);
}
else
{
Serial.println("Failed to read temperature");
}

if (! isnan(h))
{
Serial.print("Hum. % = "); Serial.println(h);
}
else
{
Serial.println("Failed to read humidity");
}
Serial.println();
delay(1000);
}

[/codesyntax]

 

 

Output

Open the serial monitor and you should see something like this

Temp *C = 19.46
Hum. % = 45.33

Temp *C = 19.71
Hum. % = 46.29

Temp *C = 24.44
Hum. % = 61.38

Temp *C = 26.48
Hum. % = 71.29

Temp *C = 27.99
Hum. % = 76.13

Link

AliExpress.com Product – 1PCS/LOT SHT31 Temperature & SHT31-D Humidity Sensor module Breakout Weather for Arduino

Related posts

Chipkit Max32 and ADXL335 accelerometer example

Chipkit Max32 and LSM303 Accelerometer example

Chipkit Max32 and LSM303 Magnetometer example

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More