Home » Connecting a STTS22H temperature sensor to an ESP32 example

Connecting a STTS22H temperature sensor to an ESP32 example

by shedboy71
esp32 and STTS22H_bb

In this article we look at a temperature sensor, the STTS22H sensor from ST and connect it to an ESP32 board

Sensor Information

The STTS22H is an ultralow-power, high-accuracy, digital temperature sensor offering high performance over the entire operating temperature range.

The STTS22H Temperature Sensor is an ultralow-power, high-accuracy, digital temperature sensor from ST Microelectronics and is housed in our standard Qwiic form factor. Thanks to its factory calibration the STTS22H offers high-end accuracy performance over the entire operating temperature range, reaching as low as ±0.5°C without requiring any further calibration at the application level.

The sensor operating mode is user-configurable and allows selecting between different ODRs (down to 1Hz) or the one-shot mode for battery saving. In one-shot mode, the sensor current consumption falls to 1.75µA. Peripheral addresses are also user-configurable and allow up to four different addresses to be specified by manipulating the jumpers on the back of the breakout. In addition, an interrupt pin is available to signal the application whenever the user-selectable high or low threshold has been exceeded.


  • Uses I2C interface (Qwiic-enabled)
  • Four selectable addresses
    • 0x3C (default), 0x3E, 0x38, 0x3F
  • Operating temperature: -40°C to +125°C
  • Temperature accuracy (max): ± 0.5°C (-10°C to +60°C)
  • Operating voltage: 1.5V to 3.6V
    • Typically 3.3V if using the Qwiic cable
  • Ultralow current: 1.75µA in one-shot mode
  • Programmable thresholds with interrupt pin
  • Programmable operating modes
    • Freerun, one-shot, and Low-ODR
  • NIST traceability

Parts Required

You can connect to the sensor using DuPont-style jumper wire.

I use an ESP32 board from Wemos, the Lolin32 – it should work with any ESP32 board


Name Link

Connecting cables



I used 3.3v from the ESP32 board

I also used a Qwiic cable, but if you do not have one, there is an unpopulated set of pins you can solder a header to. This is how you would wire this up

esp32 and STTS22H_bb

esp32 and STTS22H_bb


Code Example

I installed the Sparkfun library using the Arduino ide

Click the Manage Libraries … menu item, search for STTS22H, and select the Sparkfun STTS22H library like this

This is one of the examples that gets installed with the library, with a  few comments and unused lines removed.

#include <Wire.h>
#include "SparkFun_STTS22H.h"

SparkFun_STTS22H mySTTS; 

float temp; 

void setup()



    if( !mySTTS.begin() )
        Serial.println("Did not begin.");


    // Other output data rates can be found in the description
    // above. To change the ODR or mode, the device must first be
    // powered down.

    // Enables incrementing register behavior for the IC.
    // It is not enabled by default as the datsheet states and
    // is vital for reading the two temperature registers.


void loop()

    // Only use data ready for one-shot mode or 1Hz output. 
    if( mySTTS.dataReady() ) 
        // Temperature in different units can be retrieved
        // using the following functions.
        Serial.print("Temp: "); 




When run you will see something like this in the serial monitor window

Temp: 68.68F
Temp: 68.67F
Temp: 68.74F
Temp: 68.70F
Temp: 68.72F
Temp: 68.72F




You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.