In this article we look at another digital humidity sensor – this time its the SHTC1 and we will connect it to our Microbit
This is the sensor that I will be using
Lets look at the sensor
The SHTC1 is a digital humidity sensor designed especially for high-volume consumer electronics applications. This humidity sensor is strictly designed to overcome conventional limits for size, power consumption, and price-performance ratio, in order to fulfill the current and future requirements of the consumer electronics market.
Sensirion’s CMOSens® technology offers a complete sensor system on a single chip, consisting of a capacitive humidity sensor, a band-gap temperature sensor, analog and digital signal processing, A/D converter, calibration data memory, and a digital communication interface supporting I2C fast mode.
The ultra-small, 2 × 2 × 0.75 mm3 DFN package enables applications to be placed in even the most limited of spaces. The sensor covers a humidity measurement range of 0 to 100 %RH and a temperature measurement range of –30°C to 100°C with a typical accuracy of ±3 %RH and ±0.3°C.
The operating voltage of 1.8 V and an energy budget below 1 µJ per measurement make the SHTC1 suitable for mobile or wireless applications running on the lowest power budgets. With the industry-proven quality and reliability of Sensirion’s humidity sensors and constant accuracy over a large measurement range, the SHTC1 humidity sensor offers an unprecedented price-performance ratio.
Features
Interface | I²C |
Supply voltage | 1.8 V |
Power consumption | 2µW (at 1 reading per second in low power mode) |
Measuring range (RH) | 0 – 100% relative humidity |
Measuring range (T) | -30 to +100°C (-22 to +212°F) |
Response time (RH) | 8s (tau63%) |
Parts Required
Once again for ease of use I connect an expansion board to the microbit, I feel this makes it easier to connect to a sensor like the one pictured above using connecting wire
Schematic/Connection
Microbit | Sensor |
3v3 | Vcc |
Gnd | Gnd |
SDA – 20 | SDA |
SCL – 19 | SCL |
Code Example
This uses the library from https://github.com/Sensirion/arduino-sht
[codesyntax lang=”cpp”]
#include <Wire.h> #include "SHTSensor.h" SHTSensor sht; // To use a specific sensor instead of probing the bus use this command: // SHTSensor sht(SHTSensor::SHT3X); void setup() { // put your setup code here, to run once: Wire.begin(); Serial.begin(9600); delay(1000); // let serial console settle if (sht.init()) { Serial.print("init(): success\n"); } else { Serial.print("init(): failed\n"); } sht.setAccuracy(SHTSensor::SHT_ACCURACY_MEDIUM); // only supported by SHT3x } void loop() { // put your main code here, to run repeatedly: if (sht.readSample()) { Serial.print("SHT:\n"); Serial.print(" RH: "); Serial.print(sht.getHumidity(), 2); Serial.print("\n"); Serial.print(" T: "); Serial.print(sht.getTemperature(), 2); Serial.print("\n"); } else { Serial.print("Error in readSample()\n"); } delay(1000); }
[/codesyntax]
Output
Open the serial monitor and you should see something like this
SHT:
RH: 40.45
T: 23.96
SHT:
RH: 40.56
T: 23.92
SHT:
RH: 40.68
T: 23.84
SHT:
RH: 40.80
T: 23.80
Links