SHT40 Temperature and Humidity Sensor

View on Amazon
Overview
About SHT40 Temperature and Humidity Sensor
The SHT40, part of Sensirion’s 4th-generation sensor platform, delivers high-accuracy temperature and humidity measurements with exceptional stability. Its compact design and low operating voltage make it ideal for HVAC systems, data loggers, and environmental monitoring.
⚡ Key Features
- Superior Accuracy – ±1.8% RH (humidity) and ±0.2°C (temperature).
- Low Power & Wide Voltage Range – Operates from 1.08V to 3.6V, ideal for battery-powered devices.
- I²C Communication – Simple integration with ESP32, Arduino, and embedded systems.
- Compact & Reliable – Designed for long-term environmental sensing applications.
With its high precision and energy efficiency, the SHT40 is an excellent choice for next-generation climate monitoring solutions. 🚀
SHT40 Specifications
Complete technical specification details for SHT40 Temperature and Humidity Sensor
📊 Technical Parameters
SHT40 Pinout
The SHT40 uses standard I²C communication with 4 pins, optimized for ultra-low power applications.
Visual Pinout Diagram

Pin Types
Quick Tips
Standard I²C interface for easy integration,📡 Default I²C address is 0x44
Excellent accuracy: ±0.2°C temp, ±1.8% humidity,🔋 Ultra-low voltage (1.08V-3.6V) for battery applications
Low power consumption ideal for IoT devices
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 VDD | Power | Power supply input (1.08V to 3.6V) | Ultra-low voltage for battery-powered devices |
2 GND | Power | Ground connection | Connect to ESP32 ground |
3 SDA | Communication | I²C data line | Bidirectional data communication |
4 SCL | Communication | I²C clock line | Clock signal from master device |
Wiring SHT40 to ESP32
Connect the SHT40 using standard I²C interface for low-power environmental monitoring.
Visual Wiring Diagram

Connection Status
Protocol
Pin Connections
| SHT40 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 VDD Required | 3.3V | Power supply (1.08V to 3.6V supported) | |
2 GND Required | GND | Ground connection | |
3 SDA Required | GPIO21 | I²C data line (default SDA) | |
4 SCL Required | GPIO22 | I²C clock line (default SCL) |
GPIO21/22 are default I²C pins on ESP32
I²C address is 0x44 (fixed)
Add 10kΩ pull-up resistors on SDA/SCL if needed
Optimized for ultra-low power consumption
SHT40 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: The sensor fails to initialize, and no data is received.
Solution: Ensure that the SDA and SCL lines are correctly connected to the corresponding GPIO pins on the microcontroller. Verify that the power supply voltage is within the specified range (1.08V to 3.6V). Check for proper pull-up resistors on the SDA and SCL lines if required by your specific setup. Confirm that the I²C address used in your code matches the sensor's default address (0x44).
Issue: The sensor provides inaccurate temperature or humidity readings.
Solution: Avoid placing the sensor near heat sources or in direct sunlight. Ensure that the sensor is not exposed to condensation or water droplets. Allow the sensor to stabilize after power-up, as recommended by the manufacturer. Calibration may be necessary for precise measurements.
Issue: Communication with the sensor is intermittent or fails.
Solution: Verify that the correct I²C address (0x44) is used in your code. Ensure that the timing requirements for the I²C signals are met. Check the integrity of the SDA and SCL connections and ensure that appropriate pull-up resistors are in place if not already included on the sensor module.
Debugging Tips
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
SHT40 Programming Examples
Ready-to-use code examples for different platforms and frameworks
#include <Wire.h>
#include "Adafruit_SHT4x.h"
Adafruit_SHT4x sht4 = Adafruit_SHT4x();
void setup() {
Serial.begin(115200);
if (!sht4.begin()) {
Serial.println("Couldn't find SHT4x");
while (1) delay(10);
}
Serial.println("Found SHT4x sensor");
}
void loop() {
sensors_event_t humidity, temp;
sht4.getEvent(&humidity, &temp);
Serial.print("Temperature: ");
Serial.print(temp.temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity.relative_humidity);
Serial.println(" %");
delay(2000);
}This Arduino code initializes the SHT40 sensor using the Adafruit SHT4x library. In the setup() function, it sets up serial communication and attempts to initialize the sensor. If the sensor is not found, it prints an error message and halts execution. In the loop() function, it reads temperature and humidity data from the sensor and prints the values to the Serial Monitor every two seconds.
#include "sht4x.h"
#include "esp_log.h"
#define I2C_MASTER_SCL_IO 22
#define I2C_MASTER_SDA_IO 21
#define I2C_MASTER_FREQ_HZ 100000
#define SHT40_ADDR 0x44
static const char *TAG = "SHT40";
void app_main() {
ESP_LOGI(TAG, "Initializing SHT40...");
sht4x_dev_t dev;
sht4x_init(&dev, I2C_MASTER_SCL_IO, I2C_MASTER_SDA_IO, I2C_MASTER_FREQ_HZ, SHT40_ADDR);
while (1) {
float temperature, humidity;
if (sht4x_read_temperature(&dev, &temperature) == ESP_OK &&
sht4x_read_humidity(&dev, &humidity) == ESP_OK) {
ESP_LOGI(TAG, "Temperature: %.2f°C", temperature);
ESP_LOGI(TAG, "Humidity: %.2f%%", humidity);
} else {
ESP_LOGE(TAG, "Failed to read data from SHT40 sensor");
}
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}This ESP-IDF code configures the ESP32 to communicate with the SHT40 sensor over I²C. The sht4x_init function initializes the sensor, while sht4x_read_temperature and sht4x_read_humidity fetch temperature and humidity data. The values are logged to the console every two seconds, and errors are reported if data retrieval fails.
sensor:
- platform: sht4x
temperature:
name: "SHT40 Temperature"
humidity:
name: "SHT40 Humidity"
address: 0x44
update_interval: 2sThis ESPHome configuration sets up the SHT40 sensor to measure temperature and humidity over I²C. The sensor readings update every two seconds, and the default I²C address is 0x44.
platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
adafruit/Adafruit SHT4x Library
wire
monitor_speed = 115200main.cpp
#include <Wire.h>
#include "Adafruit_SHT4x.h"
Adafruit_SHT4x sht4 = Adafruit_SHT4x();
void setup() {
Serial.begin(115200);
if (!sht4.begin()) {
Serial.println("Couldn't find SHT4x");
while (1) delay(10);
}
Serial.println("Found SHT4x sensor");
}
void loop() {
sensors_event_t humidity, temp;
sht4.getEvent(&humidity, &temp);
Serial.print("Temperature: ");
Serial.print(temp.temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity.relative_humidity);
Serial.println(" %");
delay(2000);
}This PlatformIO code initializes the SHT40 sensor using the Adafruit SHT4x library. The sensor communicates over I²C, and the program continuously reads and prints temperature and humidity values to the Serial Monitor every two seconds.
Wrapping Up SHT40
The ESP32 SHT40 Temperature and Humidity Sensor is a powerful environment sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
Best Practices
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Safety First
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.
Ready to Start Building?
Now that you have all the information you need, it's time to integrate the SHT40 into your ESP32 project and bring your ideas to life!






