Arduino driver for the STS3x digital temperature sensor.
The STS3x is a high-accuracy digital temperature sensor from Sensirion featuring an I²C interface, fast response time, and high measurement precision. It is designed for applications such as environmental monitoring, industrial control systems, and IoT sensing devices.
This library provides a simple interface for configuring the sensor and reading temperature values in degrees Celsius.
- High accuracy temperature measurement
- Single-shot measurement mode
- Periodic measurement mode
- Configurable measurement repeatability
- Configurable measurement rate
- Status register reading
- Sensor soft reset
- CRC data validation for reliable communication
- Arduino UNO / Mega
- ESP32
- ESP8266
- Any board supporting the Wire (I²C) library
Supported sensor:
7Semi Digital Temperature Sensor I2C Breakout – STS3x
The STS3x communicates using I²C.
| STS3x Pin | MCU Pin | Description |
|---|---|---|
| VCC | 3.3V | Sensor power |
| GND | GND | Ground |
| SCL | SCL | I²C clock |
| SDA | SDA | I²C data |
Default sensor address: 0x4A
Recommended I²C speed: 100 kHz – 400 kHz
- Open Arduino IDE
- Go to Library Manager
- Search for 7Semi STS3x
- Click Install
- Download this repository as ZIP
- Arduino IDE → Sketch → Include Library → Add .ZIP Library
#include <7Semi_STS3x.h>
STS3x_7Semi sensor;
void setup()
{
Serial.begin(115200);
if(!sensor.begin())
{
Serial.println("STS3x not detected");
while(1);
}
}
void loop()
{
float temperature;
temperature = sensor.readTemperature();
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" C");
delay(1000);
}
---
## Library Overview
### Reading Temperature
```cpp
float temperature;
temperature = sensor.readTemperature();
Serial.print("Temperature: ");
Serial.println(temperature);Returns the measured temperature in degrees Celsius.
float temperature;
sensor.measureSingleShot(REPEATABILITY_HIGH, false, temperature);Parameters:
-
Repeatability – Measurement precision level
-
Clock stretching – Enable or disable clock stretching
Repeatability options:
REPEATABILITY_LOW
REPEATABILITY_MEDIUM
REPEATABILITY_HIGHsensor.startPeriodicMeasurement(REPEATABILITY_HIGH, MPS_2);
float temperature;
sensor.blockingReadMeasurement(temperature);
Measurement rates:
MPS_0_5
MPS_1
MPS_2
MPS_4
MPS_10These correspond to measurements per second.
The sensor status register can be read for debugging and system monitoring.
uint16_t status;
sensor.readStatusRegister(status);
Serial.print("Status: ");
Serial.println(status, HEX);
The status register contains flags for:
-
Alert pending
-
Heater status
-
Temperature tracking alerts
-
Reset detection
-
Command errors
-
Write checksum errors
This performs a sensor soft reset and clears the internal state machine.
sensor.softReset();
-
Environmental temperature monitoring
-
Industrial control systems
-
IoT sensing devices
-
Data logging systems
-
HVAC systems
-
Smart home monitoring