Introduction

The STS35 temperature sensor from Sensirion gives a fully calibrated, linearized, and supply-voltage-compensated digital output and has an outstanding accuracy of up to ±0.1℃.
It provides an operating temperature range of -40-125℃ and up to 1MHz I2C communication rate. Besides, the sensor can heat up itself to dehumidify the chip, which means it can function properly in a certain level of humidity.

Applications

  • Grain bin temperature monitoring
  • Precise temperature controlling in Lab
  • Ambient temperature detection in greenhouse
  • DIY ambient temperature measuring device
  • Temperature measuring in environment with changeable humidity

Features

  • Factory calibrated, accurate digital output
  • High accuracy, ±0.1℃ temperature error
  • Fast startup time, 0.5ms
  • High reliability, long-term stability

Specification

  • Detection type: temperature
  • Operating Voltage: 3.3-5.5V DC
  • Power Consumption: 0.05W (5V) //待修改
  • Heating Power Consumption: 3.6-33mW
  • Output Signal: I2C
  • Measuring Range: -40-125℃
  • Accuracy: ±0.1℃
  • Resolution: 0.01℃
  • Preheat: ≤1.5ms (Typical, 0.5ms)
  • Response Time: >2s
  • Operating Temperature: -40-125℃
  • Size: 20×17.5×2mm/0.79×0.69×0.08"
  • Mounting Hole Size: M2(2mm); Pitch 15mm

Pinout

Num Label Description
1 RST Power Positive Reset pin (pull down to reset)
2 ADDR Power Negative I2C address pin (default to be 0x4B, pull-down address is 0x4A)
3 SDA I2C data line
4 SCL I2C clock line
5 GND -
6 VCC +

Tutorial

  • Connect the wires according to the wring diagram
  • Burn the program into Arduino UNO via Arduino IDE, and open the serial monitor to view the current temperature data.

Requirements

Read Sensor Data via I2C

I2C Wiring Diagram

Sample Code

  • Connect the module to Arduino according to the wiring diagram above, you can also use it with Gravity I/O Sensor Expansion Board V7.1 to build the project more easily and quickly.
  • The default I2C address is 0x4B. If you want to modify the I2C address, you can connect the ADDR pin on the module to GND and change letter B of the code DFRobot_STS3X sts(&Wire, STS3X_IIC_ADDRESS_B) to letter A.
  • Open Arduino IDE and upload the following code to Arduino UNO.
  • Open the serial monitor of Arduino IDE, set the baud rate to 9600, and observe the temperature printing result.
/*!
 * @file getTemperature.ino
 * @brief Enable the period measurement mode of the sensor (set the period measurement frequency, equivalent to sending a command to enable the period measurement mode),
 * @n Get the measured temperature data in the sensor period measurement mode
 * 
 * @copyright    Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @licence     The MIT License (MIT)
 * @author [LuoYufeng](yufeng.luo@dfrobot.com)
 * @version  V1.0
 * @date  2021-9-01
 * @url https://github.com/DFRobot/DFRobot_STS3X
 */
#include "DFRobot_STS3X.h"

/*!
 * Determine the I2C address based on pull high or pull low of ADDR pin
 * ADDR pin pull low: STS3X_IIC_ADDRESS_A   0x4A
 * ADDR pin pull high (by default): STS3X_IIC_ADDRESS_B   0x4B
 */
DFRobot_STS3X sts(&Wire, STS3X_IIC_ADDRESS_B);


void setup(void)
{
    Serial.begin(9600);
    /*Wait for the chip to be initialized completely, and then exit*/
    while(sts.begin() != true){
        Serial.println("Failed to init chip, please check if the chip connection is fine. ");
        delay(1000);
    }

    /*!
     *@brief Set measurement frequency
     *@param freq: Select e2S, e1Hz, e2Hz, e4Hz and e10Hz modes in the enum variable eFreq_t
     */
    sts.setFreq(sts.e10Hz);

}

void loop() {
    Serial.print(sts.getTemperaturePeriodC());
    Serial.println(" ℃");
    delay(1000);
}

Result

Repeat Mode Select

  • Adjust data repeat mode by changing the parameters in parentheses.
  • Different modes correspond to different measurement times. Measurement time: the time required for collecting samples to output the measured data once.
Mode Measurement Time
High 12.5 ms
Medium 4.5 ms
Low 2.5 ms
    /*!
     *@brief Set repeat mode
     *@param code: Select eHigh, eMedium and eLow modes in the enum variable eCode_t
     */
    sts.setRepeat(sts.eHigh);

Measurement Rate Select

  • Adjust data measurement rate by changing the parameters in parentheses.
  • Different modes correspond to different measurement rates.
Mode Measurement Rate
2S 0.5Hz
1Hz 1Hz
2Hz 2Hz
4Hz 4Hz
10Hz 10Hz
    /*!
     *@brief Set measurement frequency
     *@param freq: Select e2S, e1Hz, e2Hz, e4Hz and e10Hz modes in the enum variable eFreq_t
     */
    sts.setFreq(sts.e10Hz);

Note

  • Self-heating may occur when the measurement rate is at a maximum of 10Hz.

API Function List

    void setRepeat(eCode_t code);

    /*!
     *@brief Set clock stretching. After enabling clock stretching, the sensor won't send NAK if the measurement is not done; it will send data to implement the unfinished measurement command after the measurement is done.
     *@param clockStretch: Whether to turn on clock stretching, true for on, false for off
     */
    void setStretch(bool clockStretch);

    /*!
     *@brief Set measurement frequency, enable sensor period measurement mode (set the period measurement frequency, equivalent to sending a command to enable the period measurement mode)
     *@param freq: Select e2S, e1Hz, e2Hz, e4Hz and e10Hz modes in the enum variable eFreq_t
     */
    void setFreq(eFreq_t freq);

    /*!
     *@brief Turn on the heater
     */
    void setHeaterOn();

    /*!
     *@brief Turn off the heater
     */
    void setHeaterOff();

    /*!
     *@brief Interrupt the ongoing work of the sensor and force it into idle mode
     */
    void breakSensor();

    /*!
     *@brief Set the parameters to the default value
     */
    void resetSensor();

    /*!
     *@brief Get and save all the current statuses of the sensor
     *@n But after a while, you have to call the interface before obtaining the current sensor status through other api functions
     */
    void getStatus();

    /*!
     *@brief Get checksum status
     *@return true: checksum of last write transfer was correct
     *@n      false: checksum of last write transfer failed
     */
    bool checkSumStatus();

    /*!
     *@brief Get command status
     *@return true: last command executed successfully
     *@n      false: last command not processed.
     */
    bool commandStatus();

    /*!
     *@brief Check if the system is reset
     *@return true: no reset detected since last 'clear status register' command
     *@n      false: reset detected (hard reset, soft reset command or supply fail)
     */
    bool systemResetDetected();

    /*!
     *@brief Temp tracking alert
     *@return true: no alert
     *@n      false: alert
     */
    bool temTrackingAlert();

    /*!
     *@brief Get heater status
     *@return true: Heater OFF
     *@n      false: Heater ON
     */
    bool heaterStatus();

    /*!
     *@brief Get alert pending status
     *@return true: no pending alerts
     *@n      false: at least one pending alert
     */
    bool alertPendingStatus();

    /*!
     *@brief Get the current temp in single measurement mode, note: ensure the sensor is in idle status, you can call the relevant api: breakSensor()
     *@return Unit: ℃
     */
    float  getTemperatureSingleC();

    /*!
     *@brief Get the current temp in period measurement mode, note: set the sampling frequency in advance, you can call the relevant api: setFreq(eFreq_t freq)
     *@return Unit: ℃
     */
    float  getTemperaturePeriodC();

Precaution

  • Avoid long-term use in environments with excessive humidity (the environment is considered dry when its humidity reference is below 40% RH, and the moisture generated by the temperature difference between day and night can be removed by the self-heating function).
  • Please do not use 10Hz mode to transmit data for a long time, it will cause self-heating and then reduce the accuracy.

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents