micro:bit and SHT11 digital humidity sensor example

The SHT1x digital humidity sensor is a reflow solderable sensor. The SHT1x series consists of a low-cost version with the SHT10 humidity sensor, a standard version with the SHT11 humidity sensor, and a high-end version with the SHT15 humidity sensor. As with every other Sensirion sensor type from the SHTxx humidity sensor family, they are fully calibrated and provide a digital output.

The humidity sensors are seamlessly coupled to a 14-bit-analog-to-digital converter and a serial interface circuit. This results in superior signal quality, a fast response time, and insensitivity to external disturbances (EMC).

One thing to note is that these sensors have been effectively replaced by others in sensirion’s range such as the SHT31 but they are still usable and for the hobbyist






You need to install the library from – https://github.com/practicalarduino/SHT1x

This is the built in example


[codesyntax lang="cpp"]
#include <SHT1x.h>

// Specify data and clock connections and instantiate SHT1x object
#define dataPin 3
#define clockPin 4
SHT1x sht1x(dataPin, clockPin);

void setup()
 Serial.begin(38400); // Open serial connection to report values to host
 Serial.println("Starting up");

void loop()
 float temp_c;
 float temp_f;
 float humidity;

 // Read values from the sensor
 temp_c = sht1x.readTemperatureC();
 temp_f = sht1x.readTemperatureF();
 humidity = sht1x.readHumidity();

 // Print the values to the serial port
 Serial.print("Temperature: ");
 Serial.print(temp_c, DEC);
 Serial.print("C / ");
 Serial.print(temp_f, DEC);
 Serial.print("F. Humidity: ");





Open the serial monitor , all going well you should see something like this

Temperature: 25.5599994659C / 78.1159973145F. Humidity: 49.05%
Temperature: 26.1399993896C / 79.1599960327F. Humidity: 50.94%
Temperature: 28.5199985504C / 83.6599960327F. Humidity: 68.56%
Temperature: 30.2299976349C / 86.6119918823F. Humidity: 75.35%
Temperature: 31.2499980927C / 88.3939971924F. Humidity: 77.40%



Leave a Comment

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :