Repository for Sensirion temperature sensor support on Arduino
Adapted from arduino-sht library
Jan Stegenga,
EVAbits,
26-6-2017
Download arduino-sts either via git and place it in your Arduino/libraries directory. After restarting the Arduino IDE, you will see the new STSSensor menu items under libraries and examples.
Assuming you installed the library as described above, the following steps are necessary:
STSSensor
class (STSSensor sts;
)setup()
, make sure to init the Wire library with Wire.begin()
Serial.begin(9600)
sts.readSample()
in the loop()
function, which reads a temperature sample from the sensorsts.getTemperature()
to get the values from the last sampleImportant: getTemperature()
do not read a new sample from the sensor, but return the values read last. To read a new sample, make
sure to call readSample()
#include <Wire.h>
#include <STSSensor.h>
SHTSensor sts;
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(9600);
sta.init();
}
void loop() {
// put your main code here, to run repeatedly:
sht.readSample();
Serial.print("STS:\n");
Serial.print(" T: ");
Serial.print(sts.getTemperature(), 2);
Serial.print("\n");
delay(1000);
}