STTS22H temperature sensor and Raspberry Pi Pico Arduino example

In this article we connect the ever popular STTS22H temperature sensor to a raspberry Pi Pico and we will then display readings via the serial monitor window. We are using the Arduino IDE.

Lets look at the sensor first

Features

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

The STTS22H is a bandgap temperature sensor coupled with an A/D converter, signal processing logic, and an I²C/SMBus 3.0 interface all in a single ASIC.

This sensor is housed in a small 2 x 2 x 0.50 mm 6-lead UDFN package with exposed pad down for a better temperature match with the surrounding environment.

The STTS22H is factory calibrated and requires no additional calibration efforts on the customer side.

The STTS22H units are 100% tested on a production setup that is NIST traceable and verified with equipment that is calibrated in accordance with the IATF 16949:2016 standard.

  • All features

    • Key features
      • Integrated high-accuracy temperature sensor
      • Factory calibrated
      • NIST traceability
      • One-shot mode for power saving
    • Electrical specifications
      • Supply voltage: 1.5 to 3.6 V
      • I²C, SMBus 3.0 with ALERT (ARA) support
      • Programmable thresholds with interrupt pin
      • Supports up to 1 MHz serial clock
      • Up to 4 I²C/SMBus slave addresses
      • Ultralow current: 1.75 µA in one-shot mode
    • Sensing specifications
      • Operating temperature -40 °C to +125 °C
      • Temperature accuracy (max.): ± 0.5 °C (-10 °C to +60 °C)
      • 16-bit temperature data output

 

 

Parts Required

Name Link
Raspberry Pi Pico
STTS22H
  • Aliexpress link
  • Ebay link
Connecting cables

 

Schematic/Connection

Here is a layout in fritzing to show this

Code Example

I used the Sparkfun STTS22H library and  this is the default example which worked, there are several examples to experiment with

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

SparkFun_STTS22H mySTTS; 

float temp; 

void setup()
{

    Wire.begin();

    Serial.begin(115200);

    if( !mySTTS.begin() )
    {
        Serial.println("Did not begin.");
        while(1);
    }

    Serial.println("Ready");

    // Other output data rates can be found in the description
    // above. To change the ODR or mode, the device must first be
    // powered down.
    mySTTS.setDataRate(STTS22H_POWER_DOWN);
    delay(10);
    mySTTS.setDataRate(STTS22H_1Hz);

    // 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.
    mySTTS.enableAutoIncrement();

    delay(100);
}

void loop()
{

    // Only use data ready for one-shot mode or 1Hz output. 
    if( mySTTS.dataReady() ) 
    {

        mySTTS.getTemperatureF(&temp);

        // Temperature in different units can be retrieved
        // using the following functions.

        //mySTTS.getTemperatureC(&temp);
        //mySTTS.getTemperatureK(&temp);

        Serial.print("Temp: "); 
        Serial.print(temp);
        Serial.println("F"); 

    } 

    // delay = 1/ODR 
    delay(1000);

}

 

Output

Temp: 66.67F
Temp: 66.63F
Temp: 66.65F
Temp: 66.61F

Links

https://www.st.com/resource/en/datasheet/stts22h.pdf

https://github.com/sparkfun/SparkFun_STTS22H_Arduino_Library

Related posts

KX134 accelerometer and Raspberry Pi Pico Arduino example

ADXL313 accelerometer and Raspberry Pi Pico Arduino example

KX132 accelerometer and Raspberry Pi Pico Arduino 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