Measure temperature and humidity with the Sensiron SHT20 sensor.
- Temperature range: -40 to 125 C (-40 to 257 F)
- Humidity range: 0 to 100 % RH
- Temperature accuracy: ± 0.5% C
- Humidity accuracy: ± 5% RH
- Interface: I2C
- Voltage range: 2.1 - 3.6 V
The attached Qwiic connector is keyed and can only be inserted one way.
I2C Bus Pull-ups
The device has no pull-up resistors; it is intended to be used as an accessory to a uFire board which already has pull-up resistors installed.
To start using the device, you need to install a library for your board/platform.
Arduino IDE: go to the library manager (Sketch / Include Library / Manage Libraries...) and search for
PlatformIO: install the library using the library manager (PlatformIO / PlatformIO Home / Libraries) and search for
Particle.io: search for
uFire SHT20in the Libraries section of the IDE.
Raspberry Pi: clone the GitHub repo. The library is located in the
python/RaspberryPidirectory. Have a look at the README for instructions. Be sure to read the section below for instructions.
Rust: Download/install/documentation for the crate
Any other SHT2x library will work as well.
The shell Example
An interactive shell interface is provided and is a quick and easy way to get started using the device. You will find the equivalent commands in the code area below when applicable. Upload it to your device, start a serial terminal and you will get a
> prompt where you can enter commands and receive a response like a terminal or REPL. It is often quicker to experiment with things this way rather than rewriting, compiling, and uploading new versions every time.
The device has 4 resolution modes, 8, 10, 11, and 12. By default, the libraries all use 12 bit. To change the mode, it can be done in the class initialization by passing RESOLUTION_8BITS, RESOLUTION_10BITS, RESOLUTION_11BITS or RESOLUTION_12BITS as can be seen in the next section.
- C++: There are several class constructors available.
- Change resolution:
- ESP32 I2C Pins (SDA, SCL):
uFire_SHT20 sht20(19, 23);
- ESP32 I2C Pins and resolution(SDA, SCL):
uFire_SHT20 sht20(19, 23, sht20.RESOLUTION_10BITS);
- Raspberry Pi Python: You can optionally pass the bus and resolution.
ec = uFire_EC()
- I2C System Bus:
ec = uFire_EC(i2c_bus=3)
ec = uFire_EC(resolution=SHT20.RESOLUTION_10BITS)
- Rust: Always pass the I2C system bus.
let mut sht20 = SHT20::new("/dev/i2c-3");
The device comes pre-calibrated from the factory and cannot be changed.