The SHT30 is a high-precision digital temperature and humidity sensor that communicates via the I2C protocol. It provides accurate environmental measurements, making it suitable for weather monitoring, indoor climate control, and industrial applications. In this blog, we will interface the SHT30 sensor module with an Arduino and display the temperature and humidity readings on an OLED screen.

 

Components Required


About SHT30 Digital Temperature and Humidity Sensor Module

The SHT30 is a highly accurate and reliable digital temperature and humidity sensor developed by Sensirion. It is designed for applications that require precise environmental monitoring, such as weather stations, HVAC systems, smart home devices, and industrial automation.


Features & Specifications of SHT30 Sensor Module

  • Operating Voltage: 2.4V to 5.5V
  • Temperature Range: -40°C to 125°C
  • Temperature Accuracy: ±0.2°C (typical)
  • Humidity Range: 0% to 100% RH
  • Humidity Accuracy: ±2% RH (typical)
  • Interface: I2C (Two-Wire Communication)
  • I2C Address: 0x44 (default), can be changed to 0x45
  • Low Power Consumption: Ideal for battery-operated devices
  • Integrated Heaters: Helps reduce condensation for stable readings

 

Working Principle

The SHT30 uses a capacitive humidity sensor and a band-gap temperature sensor. It measures environmental conditions by detecting changes in capacitance (for humidity) and resistance (for temperature). The sensor provides digital output over an I²C interface, ensuring accurate and stable readings with minimal external components.

 

Arduino SHT30 Sensor Module Circuit Diagram and Connections

The SHT30 module and 0.96 inch OLED display both communicate via the I2C protocol, requiring only two data lines (SDA and SCL) along with power connections.

Arduino SHT30 Temperature Sensor Module Circuit Connections

 

Arduino SHT30 Sensor Circuit

SHT30 to Arduino Connections:

  • VCC → 3.3V / 5V 

  • GND → GND

  • SDA → A4 (Arduino Uno)

  • SCL → A5 (Arduino Uno)

OLED Display to Arduino Connections:

  • VCC → 5V

  • GND → GND

  • SDA → A4 (Arduino Nano)

  • SCL → A5 (Arduino Nano)


Working Principle

  • Power Supply & Connections:

    • The Arduino Nano is powered via USB or an external power source.
    • The SHT30 temperature and humidity sensor and the OLED display are connected to the Arduino using I²C protocol.
    • Power lines (VCC and GND) of both modules are connected to the Arduino’s 3.3V or 5V and GND pins, respectively.
  • Data Acquisition from SHT30:

    • The SHT30 sensor continuously measures temperature and humidity.
    • The sensor communicates with the Arduino Nano over I2C (SDA & SCL lines).
    • The Arduino reads digital data from the SHT30 sensor.
  • Processing Data in Arduino:

    • The Arduino receives raw sensor data from the SHT30 module.
    • It converts this data into readable temperature (°C) and humidity (%) values.
  • Displaying Data on OLED:

    • The Arduino sends the processed temperature and humidity values to the 0.96-inch OLED display using I2C.
    • The OLED updates in real time, showing the latest environmental conditions.

 

Arduino SHT30 Sensor Code Explanation 

#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_SHT31.h"

  • #include <Wire.h> → This library allows communication over the I2C (Inter-Integrated Circuit) protocol, which is used to communicate with both the SHT30 sensor and the OLED display.
  • #include <Adafruit_SSD1306.h> → This library is used to control the SSD1306 OLED display.
  • #include <Adafruit_Sensor.h> → This is a generic sensor library that provides common functions for different sensors.
  • #include "Adafruit_SHT31.h" → This library provides functions to interact with the SHT30 temperature and humidity sensor.

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

  • #define SCREEN_WIDTH 128 → Defines the width of the OLED display as 128 pixels.
  • #define SCREEN_HEIGHT 64 → Defines the height of the OLED display as 64 pixels.
  • #define OLED_RESET -1 → Since the SSD1306 OLED does not require a reset pin, we set it to -1.
  • Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); → Creates an OLED display object with the specified parameters.

Adafruit_SHT31 sht30 = Adafruit_SHT31();

  • This creates an instance of the SHT30 sensor to interact with it.

void setup() {
    Serial.begin(115200);
    Wire.begin();

  • Serial.begin(115200); → Initializes serial communication at 115200 baud rate for debugging.
  • Wire.begin(); → Initializes I2C communication for connecting with the OLED display and SHT30 sensor.

if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);

  • display.begin(SSD1306_SWITCHCAPVCC, 0x3C); → Initializes the OLED display with I2C address 0x3C.
  • If initialization fails, it prints "SSD1306 allocation failed" and enters an infinite loop (for (;;);) to stop further execution.
  • display.clearDisplay(); → Clears the display before writing new data.
  • display.setTextSize(1); → Sets the font size to 1x scale (smallest).
  • display.setTextColor(WHITE); → Sets the text color to white.

if (!sht30.begin(0x44)) {  // SHT30 I2C address
    Serial.println("Couldn't find SHT30");
    while (1);
}

  • sht30.begin(0x44); → Initializes the SHT30 sensor with I2C address 0x44.
  • If the sensor is not found, it prints "Couldn't find SHT30" and enters an infinite loop (while (1);), stopping execution.

void loop() {
    float temperature = sht30.readTemperature();
    float humidity = sht30.readHumidity();

  • Reads temperature and humidity values from the SHT30 sensor.
  • sht30.readTemperature(); → Returns the temperature in Celsius.
  • sht30.readHumidity(); → Returns the humidity in percentage.

Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" °C");
Serial.print("Humidity: "); Serial.print(humidity); Serial.println(" %");

  • Prints the temperature and humidity values to the Serial Monitor for debugging.

display.clearDisplay();
display.setCursor(0, 10);
display.print("Temp: ");
display.print(temperature);
display.println(" C");

display.setCursor(0, 30);
display.print("Humidity: ");
display.print(humidity);
display.println(" %");

display.display();

  • display.clearDisplay(); → Clears the screen before displaying new values.
  • display.setCursor(0, 10); → Sets the cursor position at (x = 0, y = 10 pixels).
  • display.print("Temp: "); → Prints "Temp: " on the OLED.
  • display.print(temperature); → Prints the temperature value.
  • display.println(" C"); → Prints " C" (Celsius).
  • display.setCursor(0, 30); → Moves the cursor to (x = 0, y = 30 pixels) for the next line.
  • display.print("Humidity: "); → Prints "Humidity: " on OLED.
  • display.print(humidity); → Prints the humidity value.
  • display.println(" %"); → Prints " %" (percentage).
  • display.display(); → Updates the OLED screen with new values.

delay(2000);

  • Waits 2 seconds (2000 milliseconds) before taking the next reading.

 

It successfully demonstrates real-time monitoring of temperature and humidity using the SHT30 sensor and displaying the data on an SSD1306 OLED screen. The implementation leverages the I2C communication protocol, ensuring efficient data transfer between the sensor and the display. The use of the Adafruit libraries simplifies sensor interaction and display handling.

Arduino SHT30 Sensor Working

This project serves as a foundation for more advanced embedded systems applications, emphasizing the importance of sensor integration, real-time data processing, and user-friendly display interfaces.

 

Code for Interfacing SHT30 Sensor Module with Arduino

#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_SHT31.h"

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

Adafruit_SHT31 sht30 = Adafruit_SHT31();

void setup() {
    Serial.begin(115200);
    Wire.begin();

    // Initialize OLED display
    if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
        Serial.println(F("SSD1306 allocation failed"));
        for (;;);
    }
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(WHITE);
   
    // Initialize SHT30 Sensor
    if (!sht30.begin(0x44)) {  // SHT30 I2C address
        Serial.println("Couldn't find SHT30");
        while (1);
    }
}

void loop() {
    float temperature = sht30.readTemperature();
    float humidity = sht30.readHumidity();

    Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" °C");
    Serial.print("Humidity: "); Serial.print(humidity); Serial.println(" %");

    // Display data on OLED
    display.clearDisplay();
    display.setCursor(0, 10);
    display.print("Temp: ");
    display.print(temperature);
    display.println(" C");
   
    display.setCursor(0, 30);
    display.print("Humidity: ");
    display.print(humidity);
    display.println(" %");
   
    display.display();
   
    delay(2000);
}

Video

Leave a comment

Please note, comments must be approved before they are published

Your cart

×