SENSIRION STS4x is a 4th generation, high-accuracy, ultra-low-power, Humidity and Temperature digital sensor platform for measuring humidity and temperature at different accuracy classes. The STS4X provides different accuracy classes. The STS4X operates in i2C protocol interface and provides multiple preconfigured i2C addresses and enables the ULTRA-LOW power features. This sensor is suitable for use in instrumentation’s, Indoor Applications, Handheld Devices, and environmental pieces of equipment.
Requirements and Alternatives
- Arduino IDE | PlatformIO
- Test Boards :
- Note: The Diagram below is using ATMEGA328TQFP / ATMEGA4809. (please refer to each MCU’s respective pin-outs & bus configuration)
- Resistors (See below diagram for required value)
- Capacitor(See below diagram for required value)
Wiring Guide
The below diagram is the typical application configuration for STS4X, after reaching the minimal voltage supply and allowing for the maximal power-up time of 1 millisecond the sensor is initialized and ready to read the data out from the i2C communication protocol.
Test Source Code
The test code below will initialize the digital signal and translate into relative humidity and temperature readings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
#include <Arduino.h> #include <SensirionI2CSts4x.h> //This library can be download below #include <Wire.h> SensirionI2CSts4x sts4x; //This library can be download below void setup() { Serial.begin(115200); while (!Serial) { delay(100); } Wire.begin(); // sts4x.begin(Wire, ADDR_STS4X_ALT); Serial.print("14CORE - TEST CODE FOR STS4X"); Serial.print("----------------------------"); delay(2000); uint16_t error; char errorMessage[256]; sts4x.begin(Wire); /* * to set sts4 with alternate address * * //STS40-CD1B: ADDR_STS4X (I2C address: 0x46) * //STS40-AD1B: ADDR_STS4X_ALT (I2C address: 0x44) * //STS40-BD1B: ADDR_STS4X_ALT2 (I2C address: 0x45) */ // sts4x.begin(Wire, ADDR_STS4X_ALT); uint32_t serialNumber; error = sts4x.serialNumber(serialNumber); if (error) { Serial.print("Error trying to execute serialNumber() : "); errorToString(error, errorMessage, 256); Serial.println(errorMessage); } else { Serial.print("Serial Number : "); Serial.println(serialNumber); } } void loop() { uint16_t error; char errorMessage[256]; delay(1000); float temperature; error = sts4x.measureHighPrecision(temperature); if (error) { Serial.print("ERROR : trying to execute measureHighPrecision(): "); errorToString(error, errorMessage, 256); Serial.println(errorMessage); } else { Serial.print("Temperature > "); Serial.println(temperature); } } |