SHT31+Arduino+oled display
(Last Updated On: December 11, 2020)


In this tutorial, we will design and develop a Digital Thermometer and Hygrometer Meter With Oled Display. For this, we will be Interfacing SHT3X Temperature and Humidity sensor with Arduino.

Various Sensors are available to sense humidity and temperature but when we need small size and low power consuming sensor only a few stand out, here we have taken the sensor SHT31 from sensirion for sensing humidity and temperature, It can be fully calibrated and I2C Interface available with communication speeds up to 1 MHz and two user-selectable addresses (0x44 or 0x45). It provides a very fast start-up and measurement time. Sensor SH31 Arduino interface can be done through the breakout board.

Digital Humidity Sensor SHT3x (RH/T)

The digital SHT3x humidity sensor series takes sensor technology to a new level. As the successor of the SHT2x series, it sets the industry standard in humidity sensing. The SHT3x humidity sensor series consists of a low-cost version with the SHT30 humidity sensor, a standard version with the SHT31 humidity sensor, and a high-end version with the SHT35 humidity sensor. Automotive-grade versions are also available. The SHT3x humidity sensor series combines multiple functions and various interfaces (I2C, analog voltage output) with an applications-friendly, very wide operating voltage range (2.15 to 5.5 V). The SHT3x humidity sensor is available in both large and small volumes.




Size 2.5 x 2.5 x 0.9 mm
Output I²C, Voltage Out
Supply voltage range 2.15 to 5.5 V
Energy consumption 4.8µW (at 2.4 V, low repeatability, 1 measurement / s)
RH operating range 0 – 100% RH
T operating range -40 to +125°C (-40 to +257°F)
RH response time 8 sec (tau63%)


0.96″ I2C OLED Display:

This is a 0.96 inch blue OLED display module. The display module can be interfaced with any microcontroller using SPI/IIC protocols. It is having a resolution of 128×64. The package includes display board, display,4 pin male header pre-soldered to board.

OLED (Organic Light-Emitting Diode) is a self light-emitting technology composed of a thin, multi-layered organic film placed between an anode and cathode. In contrast to LCD technology, OLED does not require a backlight. OLED possesses high application potential for virtually all types of displays and is regarded as the ultimate technology for the next generation of flat-panel displays.



  • OLED Driver IC: SSD1306
  • Resolution: 128 x 64
  • Visual Angle: >160°
  • Input Voltage: 3.3V ~ 6V
  • Compatible I/O Level: 3.3V, 5V
  • Mini Size: 2.7 x 2.8cm
  • Only Need 2 I/O Port to Control
  • Fully Compatible with Arduino
  • Working temperature: -30°C ~ 70°C
  • Module volume ( generous ): 27.0 x 27.0 x 4.1mm
  • Factory configured for SPI protocol (can be easily changed to IIC)

For more information about the SSD1306 OLED Display, check out this datasheet.

Required Components:

  1. Arduino –Buy from amazon
  2. SHT31 –Buy from amazon
  3. OLED Display –Buy from amazon
  4. Breadboard –Buy from amazon
  5. Connecting Wires –Buy from amazon

Circuit Diagram: Interfacing SHT3X Temperature and Humidity sensor with Arduino


SHT31+Arduino+OLED Display


Source Code: Interfacing SHT3X Temperature and Humidity sensor with Arduino

Here is a source code for interfacing SHT3x with Arduino for reading humidity and Temperature. Copy the code and paste it in on the ArduinoIDE. Before going to upload the code Install all the libraries. You download the libraries from the links provided beside the library in the code.

#include "Adafruit_SHT31.h" //
Adafruit_SHT31 sht31 = Adafruit_SHT31();

#include <Wire.h>
#include <Adafruit_GFX.h> //
#include <Adafruit_SSD1306.h> //

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
      Serial.println("SHT31 test");
      if (! sht31.begin(0x44)) {   // Set to 0x45 for alternate i2c addr
      Serial.println("Couldn't find SHT31");
      while (1) delay(1);

        if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));


void loop() {
    float t = sht31.readTemperature();
    float h = sht31.readHumidity();
    if (! isnan(t)) {  // check if 'is not a number'
    Serial.print("Temp *C = "); Serial.println(t);
    else {    
    Serial.println("Failed to read temperature");
    if (! isnan(h)) {  // check if 'is not a number'
    Serial.print("Hum. % = "); Serial.println(h);
    else { 
    Serial.println("Failed to read humidity");    

    // display temperature
    display.print("Temperature: ");
    display.print(" ");
    // display humidity
    display.setCursor(0, 45);
    display.setCursor(74, 50);
    display.print(" ");
    display.print("Rel H");  


On Serial Monitor:


On OLED Display:

SHT31+Arduino+oled display

2 thoughts on “Interfacing SHT3X Temperature and Humidity sensor with Arduino”

Leave a Reply