SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic) Hookup Guide
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.
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.
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:
If your chosen microcontroller is not already Qwiic-enabled, you can add that functionality with one or more of the following items:
You will also need at least one Qwiic cable to connect your sensor to your microcontroller.
If you aren't familiar with the Qwiic system, we recommend reading here for an overview.
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).
Serial Terminal Basics
Qwiic Shield for Arduino & Photon Hookup Guide
SparkFun Qwiic Shield for Arduino Nano Hookup Guide
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.
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.
|Specified Humidity Range||0 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 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.
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.
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.
|I2C Jumper||Power LED Jumper|
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.
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.
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.
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
With our SHTC3 connected to our microcontroller we can move on to writing some code to start monitoring temperature and humidity.
SHTC3 Arduino Library
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
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!
- Schematic (PDF)
- Eagle Files (ZIP)
- Board Dimensions (PNG)
- Datasheet (PDF)
- Arduino Library
- Hardware GitHub Repository
If your product is not working as you expected or you need technical assistance or information, head on over to the SparkFun Technical Assistance page for some initial troubleshooting.
Need some inspiration for your next project? Check out some of these weather sensing related tutorials: