SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic) Hookup Guide

Pages
Contributors: El Duderino
Favorited Favorite 0

Introduction

Looking to keep a log of the climate in your greenhouse, create a humidor control system or want to track temperature and humidity data for a weather station project? The SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic) may be the perfect option for you! The SHTC3 is a low cost, easy-to-use, highly accurate digital humidity and temperature sensor. The SHTC3 communicates via I2C so, as you can tell by the name, we have broken out the pins on the sensor to Qwiic connectors so you can easily connect it to SparkFun's ever growing Qwiic Ecosystem.

SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic)

SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic)

SEN-16467
$10.95
1

In this guide we will highlight some of the unique features of this breakout, how to connect and use it as well as an Arduino library with four examples to get you started with your next environmental monitoring project.

Required Materials

To follow along with this guide you will need a microcontroller to communicate with the SHTC3. Below are a few options that come Qwiic-enabled out of the box:

SparkFun Thing Plus - ESP32 WROOM (Micro-B)

SparkFun Thing Plus - ESP32 WROOM (Micro-B)

WRL-15663
$22.50
14
SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

DEV-15795
$21.50
12
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$21.50
20
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$21.50
10

If your chosen microcontroller is not already Qwiic-enabled, you can add that functionality with one or more of the following items:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$8.95
22
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.60
5
SparkFun Qwiic Shield for Arduino

SparkFun Qwiic Shield for Arduino

DEV-14352
$7.50
9

SparkFun Qwiic Shield for Arduino Nano

DEV-16130
Retired

You will also need at least one Qwiic cable to connect your sensor to your microcontroller.

Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95

Qwiic Cable - 200mm

PRT-14428
Retired

Qwiic Cable - 500mm

PRT-14429
1 Retired

Suggested Reading

If you aren't familiar with the Qwiic system, we recommend reading here for an overview.

Qwiic Connect System

We would also recommend taking a look at the following tutorials if you aren't familiar with them. If you are using one of the Qwiic Shields listed above, you may want to read through their respective Hookup Guides as well before you get started with the SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic).

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

Serial Terminal Basics

This tutorial will show you how to communicate with your serial devices using a variety of terminal emulator applications.

Qwiic Shield for Arduino & Photon Hookup Guide

Get started with our Qwiic ecosystem with the Qwiic shield for Arduino or Photon.

SparkFun Qwiic Shield for Arduino Nano Hookup Guide

Hookup Guide for the SparkFun Qwiic Shield for Arduino Nano.

Hardware Overview

The SHTC3 Humidity and Temperature Sensor from Sensirion is an highly accurate digital humidity and temperature sensor that communicates using the I2C protocol. It is designed to work exceptionally well in battery powered applications such as wearables or remote environmental monitoring. In this section we will cover the operating characteristics of the SHTC3 along with the hardware present on the breakout board.

Sensor Specifications

The table below outlines some of the SHTC3's humidity and temperature sensor specifications. For a complete list and details about recommended operating conditions, review the SHTC3 Datasheet.

ParameterValue
Specified Humidity Range0 to 100 %RH
Specified Temperature Range-40 to +125 °C
Relative Humidity Accuracy Tolerance± 2.0%RH (Typ.)
Temperature Accuracy Tolerance± 0.2°C (Typ.)

Power

Power for the SHTC3 is provided over the Qwiic interface or if you would prefer you can power it with 1.62-3.6V through the pins labeled 3.3V and GND. We recommend powering the board with a regulated 3.3V source, especially if you are using it with other Qwiic boards.

Power Input

Qwiic and I2C Interface

The SHTC3 communicates via I2C and these pins are broken out to the two Qwiic connectors on the board as well as the SDA and SCL pins. The SHTC3's I2C interface supports clock frequencies between 0 to 1MHz with clock stretching to match the Fast Mode Plus specification. The I2C address is 0x70 (1110000 bin) and is hardware-defined. If you have other I2C devices with the same address or wish to use multiple SHTC3 breakouts on a single I2C bus, you'll want to use a multiplexer/mux. If you need to use more than one SHTC3 sensor or other devices sharing the same address in your project, consider using the Qwiic Mux Breakout - 8-Channel. Note, the Qwiic Mux Breakout's default I2C address is also 0x70 so it must be adjusted to work properly with the SHTC3.

Highlighting Qwiic and I2C Interface

Jumpers

If you have never worked with solder jumpers and PCB traces before or would like a quick refresher, check out our How to Work with Solder Jumpers and PCB Traces tutorial for detailed instructions and tips.

The SparkFun Humidity Sensor - SHTC3 (Qwiic) has two solder jumpers on the board labeled I2C and PWR (or PWRLED if you are looking at the schematic). The I2C jumper pulls the SDA and SCL pins to VDD (normally 3.3V) through two 2.2K Ohm resistors. If you have many peripheral devices on the same bus you may want to disable these by opening the jumper (assuming they are also operating at 3.3V logic).

The PWRLED jumper connects the power LED to VDD (normally 3.3V) through a 1K Ohm resistor. To disable the power LED simply open the jumper by severing the trace between the two solder pads. This is particularly useful for lower power applications where current draw needs to be kept at a minimum.

Highlighting the Red Tactile Button Highlighting the Power LED Jumper
I2C Jumper Power LED Jumper

Board Dimensions

This breakout is designed to our Qwiic standard 1x1" sizing to easily stack with other Qwiic products. There are four mounting holes on the board that fit a 4-40 screw.

Board Dimensions

Now that we have a solid understanding of the hardware present on the breakout, we'll get it hooked up in the next section and move swiftly on to programming and talking to the sensor.

Hardware Assembly

Using the Qwiic system, assembling the hardware is simple. All you need to do is connect your SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic) to your chosen development board with a Qwiic cable or adapter cable. Otherwise, you can use the I2C pins broken out if you prefer. If you are not using a Qwiic-enabled board, make sure your input voltage and logic are either running at 3.3V or you are running both controller and SHTC3 at the same logic level.

SHTC3 connected to a RedBoard Qwiic

If you prefer to use the PTH pins broken out on the Humidity Sensor you will need to either solder to them or, if you want a temporary connection for prototyping, these IC Hooks are a perfect option to make that connection. If you are not familiar with through-hole soldering, take a look at this tutorial:

How to Solder: Through-Hole Soldering

September 19, 2013

This tutorial covers everything you need to know about through-hole soldering.

With our SHTC3 connected to our microcontroller we can move on to writing some code to start monitoring temperature and humidity.

SHTC3 Arduino Library

Note: This library assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

The SparkFun SHTC3 Arduino library can be downloaded with the Arduino library manager by searching 'SparkFun SHTC3' or you can grab the zip here from the GitHub repository:

Once the library is installed, we can move on to working with the included example sketches and take some sensor readings.

Example 1: Basic Readings

Open the first example by heading to File > Examples > SparkFun SHTC3 Humidity and Temperature Sensor Library > Example1_BasicReadings. Select your board (in our case, the Arduino/Genuino Uno) and the COM port that it enumerated on. Then hit upload. Open the Arduino Serial Monitor at 115200 baud to start viewing the humidity and temperature!

Try holding your hand over the sensor or breathe lightly on to the SHTC3 and watch the values change.

Example 2: Verify Checksums

This example is very similar to the Basic Readings but also enables and returns checksum data calculated by the sensor to ensure the data is valid. Open it by following the instructions for Example 1 but instead select Example2_VerifyChecksums. The checksum pass indicators are passIDcrc, passRHcrc and passTcrc for the sensor ID, relative humidity and temperature, respectively.

Using checksums is not absolutely necessary but can be helpful for troubleshooting any I2C communication errors. Once the code is uploaded, it will print out over serial all checksum data and whether or not it has passed or failed so you can identify if something such as the device ID is not returned properly.

Example 3: Changing Options

The third example builds on the previous two and demonstrates how to configure the SHTC3 using the setMode function as well as selecting your Wire port and clock speed. Again, open the example by navigating to the SHTC library and selecting Example2_ChangingOptions.

Below are the available modes available on the SHTC3:

language:c
SHTC3_CMD_CSE_RHF_NPM = 0x5C24,   // Clock stretching, RH first, Normal power mode
SHTC3_CMD_CSE_RHF_LPM = 0x44DE,   // Clock stretching, RH first, Low power mode
SHTC3_CMD_CSE_TF_NPM = 0x7CA2,    // Clock stretching, T first, Normal power mode
SHTC3_CMD_CSE_TF_LPM = 0x6458,    // Clock stretching, T first, Low power mode

SHTC3_CMD_CSD_RHF_NPM = 0x58E0,   // Polling, RH first, Normal power mode
SHTC3_CMD_CSD_RHF_LPM = 0x401A,   // Polling, RH first, Low power mode
SHTC3_CMD_CSD_TF_NPM = 0x7866,    // Polling, T first, Normal power mode
SHTC3_CMD_CSD_TF_LPM = 0x609C   // Polling, T first, Low power mode

By default, the code sets the SHTC3 up to use clock stretching, report temperature data first and run on low power mode. To change to another mode, refer to the settings above and change this line:

language:c
mySHTC3.setMode(SHTC3_CMD_CSE_TF_LPM) == SHTC3_Status_Nominal

Once you have selected which mode you want the SHTC3 to operate in, upload it and open a serial monitor to 115200 baud. You should see the checksum data print and then whether or not the setMode function was successful. Note that the code defaults to print out "Choosing low-power measurements with T first: " so if you use a different mode, you may want to alter that print statement to avoid confusion.

If all of that is successful, the code will start printing out humidity and temperature data.

Example 4: Using Callback

The fourth example in the library demonstrates how to use the callback feature on the SHTC3. You may be wondering, what is a callback? It is a way that a library can provide a place for the user to do something. The library was written with a function that is called (nearly) every time a function is exited. How is that useful? You can overwrite the function with your own definition that allows you to do things like debug or watch the program execute.

Make a function with this signature:

language:c
void SHTC3_exitOp_Callback(SHTC3_Status_TypeDef status, bool inProcess, char * file, uint16_t line)

Then write in it some code that might help you. The example helps us watch the code execute by displaying the line number, file, and status every time that a function finishes.

Including these functions is particularly helpful for debugging but can be taxing on your processor and slow down your code.

Resources & Going Further

That's all for this guide. Hopefully by now you have the know-how and circuit to start your own humidity and temperature monitoring. For further information about the SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic), check out the links below. Thanks for reading!

Need some inspiration for your next project? Check out some of these weather sensing related tutorials:

Hazardous Gas Monitor

Build a portable gas monitor to check for dangerous levels of hazardous gases.

CCS811/BME280 (Qwiic) Environmental Combo Breakout Hookup Guide

Sense various environmental conditions such as temperature, humidity, barometric pressure, eCO2 and tVOCs with the CCS811 and BME280 combo breakout board.

SparkFun gator:soil Hookup Guide

The gator:soil is analog soil moisture sensor. This tutorial will get you started using the gator:soil with the micro:bit platform.

Qwiic Kit for Raspberry Pi V2 Hookup Guide

Get started with the SGP40, BME280, VCNL4040, and microOLED via I2C using the Qwiic system and Python on a Raspberry Pi! Measure VOC Index, light, temperature, humidity, and pressure from the environment. Then display them on the microOLED, serial terminal, or the cloud with Cayenne!