Home Code STM32 Nucleo and SHTC1 digital humidity sensor example using the Arduino IDE

STM32 Nucleo and SHTC1 digital humidity sensor example using the Arduino IDE

by shedboy71

In this article we look at an SHTC1 digital humidity sensor and we will connect it to a Nucleo

Lets look at some information about the sensor

The SHTC1 is a digital humidity sensor designed especially for high-volume consumer electronics applications. This humidity sensor is strictly designed to overcome conventional limits for size, power consumption, and price-performance ratio, in order to fulfill the current and future requirements of the consumer electronics market.

Sensirion’s CMOSens® technology offers a complete sensor system on a single chip, consisting of a capacitive humidity sensor, a band-gap temperature sensor, analog and digital signal processing, A/D converter, calibration data memory, and a digital communication interface supporting I2C fast mode. The ultra-small, 2 × 2 × 0.75 mm3 DFN package enables applications to be placed in even the most limited of spaces. The sensor covers a humidity measurement range of 0 to 100 %RH and a temperature measurement range of –30°C to 100°C with a typical accuracy of ±3 %RH and ±0.3°C.

The operating voltage of 1.8 V and an energy budget below 1 µJ per measurement make the SHTC1 suitable for mobile or wireless applications running on the lowest power budgets. With the industry-proven quality and reliability of Sensirion’s humidity sensors and constant accuracy over a large measurement range, the SHTC1 humidity sensor offers an unprecedented price-performance ratio. Tape and reel packaging together with suitability for standard SMD assembly processes make the SHTC1 predestined for high-volume applications.

Features

Interface I²C
Supply voltage 1.8 V
Power consumption 2µW (at 1 reading per second in low power mode)
Measuring range (RH) 0 – 100% relative humidity
Measuring range (T) -30 to +100°C (-22 to +212°F)
Response time (RH) 8s (tau63%)

Parts Required

 

Name Link
NUCLEO-L496ZG 1/PCS LOT NUCLEO-L496ZG Nucleo development board STM32L4 series development board
SHTC1 CJMCU-189 SHTC1 Digital Temperature and Humidity Humidity Temperature Sensor I2C Communication
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic/Connection

 

Nucleo Sensor
3v3 Vcc
Gnd Gnd
I2C1_SDA SDA
I2C1_SCL SCL

 

Code Example

This uses the library from https://github.com/Sensirion/arduino-sht

[codesyntax lang=”cpp”]

#include <Wire.h>

#include “SHTSensor.h”

SHTSensor sht;
// To use a specific sensor instead of probing the bus use this command:
// SHTSensor sht(SHTSensor::SHT3X);

void setup() {
// put your setup code here, to run once:

Wire.begin();
Serial.begin(9600);
delay(1000); // let serial console settle

if (sht.init()) {
Serial.print(“init(): success\n”);
} else {
Serial.print(“init(): failed\n”);
}
sht.setAccuracy(SHTSensor::SHT_ACCURACY_MEDIUM); // only supported by SHT3x

}

void loop() {
// put your main code here, to run repeatedly:

if (sht.readSample()) {
Serial.print(“SHT:\n”);
Serial.print(” RH: “);
Serial.print(sht.getHumidity(), 2);
Serial.print(“\n”);
Serial.print(” T: “);
Serial.print(sht.getTemperature(), 2);
Serial.print(“\n”);
} else {
Serial.print(“Error in readSample()\n”);
}

delay(1000);
}

[/codesyntax]

 

Output

Open the serial monitor and you should see something like this

init(): success
SHT:
RH: 42.01
T: 23.05
SHT:
RH: 42.04
T: 23.02
SHT:
RH: 42.06
T: 23.02

Links

Share

You may also like