Adafruit SHT31-D Temperature & Humidity Sensor Breakout Created by lady ada Last updated on 2018-03-07 05:34:42 PM UTC
Guide Contents Guide Contents Overview Pinouts 2 3 6 Power Pins: I2C Logic pins: Other Pins: 6 6 6 Assembly 8 Prepare the header strip: Add the breakout board: And Solder! Arduino Code Download Adafruit_SHT31 Load Demo Library Reference CircuitPython Code Usage Downloads Datasheets & Files Schematic Fabrication Print © Adafruit Industries https://learn.adafruit.
Overview Sensirion Temperature/Humidity sensors are some of the finest & highest-accuracy devices you can get. And, finally we have some that have a true I2C interface for easy reading. The SHT31-D sensor has an excellent ±2% relative humidity and ±0.3°C accuracy for most uses. © Adafruit Industries https://learn.adafruit.
Unlike earlier SHT sensors, this sensor has a true I2C interface, with two address options. It also is 3V or 5V compliant, so you can power and communicate with it using any microcontroller or microcomputer. Such a lovely chip - so we spun up a breakout board with the SHT31-D and some supporting circuitry such as pullup resistors and capacitors. Each order comes with one fully assembled and tested PCB breakout and a small piece of header.
© Adafruit Industries https://learn.adafruit.
Pinouts The HTU21D-F is a I2C sensor. That means it uses the two I2C data/clock wires available on most microcontrollers, and can share those pins with other sensors as long as they don't have an address collision. For future reference, the default I2C address is 0x44 and you can also select address 0x45 by connecting the ADDR pin to a high voltage signal. Power Pins: Vin - this is the power pin. The chip can use 2.5-5VDC for power.
© Adafruit Industries https://learn.adafruit.
Assembly Prepare the header strip: Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down © Adafruit Industries https://learn.adafruit.
Add the breakout board: Place the breakout board over the pins so that the short pins poke through the breakout pads © Adafruit Industries https://learn.adafruit.
And Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (https://adafru.it/aTk)). You're done! Check your solder joints visually and continue onto the next steps © Adafruit Industries https://learn.adafruit.
Arduino Code You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, just make sure it has I2C, then port the code - its pretty simple stuff! Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V Connect GND to common power/data ground Connect the SCL pin to the I2C clock SCL pin on your Arduino.
Place the Adafruit_SHT31 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. We also have a great tutorial on Arduino library installation at: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use Load Demo Open up File->Examples->Adafruit_SHT31->SHT31test and upload to your Arduino wired up to the sensor Thats it! Now open up the serial terminal window at 9600 speed to begin the test.
You can try breathing on the sensor to increase the humidity. The sensor reacts very fast! Library Reference The library we have is simple and easy to use You can create the Adafruit_SHT31 object with: Adafruit_SHT31 sht31 = Adafruit_SHT31(); There are no pins to set since you must use the I2C bus! Then initialize the sensor with: sht31.
and adding 32 as you have learned in grade school! Reading the humidity is equally simple. Call sht31.readHumidity() to read the humidity also as a floating point value between 0 and 100 (this reads % humidity) We also have a few helper functions. Want to soft-reset the sensor? Use sht31.reset() There's also a heater built into the sensor, used to heat/evaporate any condensation. You can turn it on or off with sht31.heater(true) sht31.heater(false) © Adafruit Industries https://learn.adafruit.
CircuitPython Code It's easy to use the SHT31-D sensor with CircuitPython and the Adafruit CircuitPython SHT31D module. This module allows you to easily write Python code that reads the humidity and temperature from the sensor. First wire up a SHT31-D to your board exactly as shown on the previous pages for Arduino using an I2C connection.
Next connect to the board's serial REPL so you are at the CircuitPython >>> prompt. Usage To demonstrate the usage of the sensor we'll initialize it and read the humidity and temperature from the board's Python REPL. Run the following code to import the necessary modules and initialize the I2C connection with the sensor: import board import busio import adafruit_sht31 i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_sht31.
import import import import time board busio adafruit_sht31 # Create library object using our Bus I2C port i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_sht31.SHT31(i2c) loopcount = 0 while True: print("\nTemperature: %0.1f C" % sensor.temperature) print("Humidity: %0.1f %%" % sensor.relative_humidity) loopcount += 1 time.sleep(2) # every 10 passes turn on the heater for 1 second if loopcount == 10: loopcount = 0 sensor.heater = True print("Sensor Heater status =", sensor.heater) time.
Downloads Datasheets & Files SHT31-DIS dataheet EagleCAD PCB Files on GitHub Fritzing object available in the Adafruit Fritzing Library Schematic Click to enlarge Fabrication Print Dimensions in inches © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.