SHT11 Temperature and Humidity Sensor

View on Amazon
Overview
About SHT11 Temperature and Humidity Sensor
The SHT11, developed by Sensirion, is a high-precision digital temperature and humidity sensor known for its reliability and stability. It integrates sensor elements and signal processing in a compact design, providing fully calibrated digital output.
⚡ Key Features
- High Accuracy & Stability – Ensures precise humidity and temperature measurements.
- CMOSens® Technology – Provides long-term reliability and fast response times.
- Capacitive Humidity Sensing & Band-Gap Temperature Sensor – Delivers consistent and accurate data.
- Ideal for Professional Applications – Used in HVAC systems, data loggers, and weather stations.
With its precision and durability, the SHT11 is a trusted choice for environmental monitoring in industrial and scientific applications. 🚀
SHT11 Specifications
Complete technical specification details for SHT11 Temperature and Humidity Sensor
📊 Technical Parameters
SHT11 Pinout
The SHT11 uses a proprietary 2-wire Sensibus protocol (similar to I²C but not identical) with 4 pins.
Visual Pinout Diagram

Pin Types
Quick Tips
Uses Sensibus protocol - NOT standard I²C,💡 Similar to I²C but with different timing requirements
Requires specialized library for communication,⚡ Pull-up resistor on DATA line may be required
High accuracy: ±0.4°C temperature, ±3% humidity
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 GND | Power | Ground connection | Connect to ESP32 ground |
2 DATA | Communication | Serial data line (Sensibus protocol) | Bidirectional data communication |
3 SCK | Communication | Serial clock line | Clock signal for data synchronization |
4 VDD | Power | Power supply input (2.4V to 5.5V) | Wide voltage range for flexible power options |
Wiring SHT11 to ESP32
Connect the SHT11 using the Sensibus protocol with two GPIO pins for DATA and SCK.
Visual Wiring Diagram

Connection Status
Protocol
Pin Connections
| SHT11 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 VDD Required | 3.3V | Power supply (2.4V to 5.5V supported) | |
2 GND Required | GND | Ground connection | |
3 DATA Required | GPIO21 | Serial data line (bidirectional) | |
4 SCK Required | GPIO22 | Serial clock line |
Sensibus is NOT I²C - use dedicated SHT1x library
Any GPIO pins work - GPIO21/22 commonly used
DATA line may need 10kΩ pull-up resistor
Timing requirements differ from I²C protocol
SHT11 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 DATA and SCK lines are correctly connected to the specified GPIO pins on the microcontroller. Verify that the power supply voltage is within the specified range (2.4V to 5.5V). Check for proper pull-up resistors on the DATA line if required by your specific setup.
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 communication protocol (Sensibus) is implemented in your code. Ensure that the timing requirements for the SCK signal are met. Check the integrity of the DATA and SCK 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
SHT11 Programming Examples
Ready-to-use code examples for different platforms and frameworks
#include <SHT1x.h>
#define dataPin 10
#define clockPin 11
SHT1x sht1x(dataPin, clockPin);
void setup() {
Serial.begin(115200);
}
void loop() {
float tempC = sht1x.readTemperatureC();
float humidity = sht1x.readHumidity();
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
delay(2000);
}This Arduino code initializes the SHT11 sensor using the SHT1x library. In the setup() function, it sets up serial communication. In the loop() function, it reads the temperature in Celsius and humidity from the sensor and prints the values to the Serial Monitor every two seconds. The SHT1x library facilitates communication with the sensor over its proprietary 2-wire interface.
#include "sht1x.h"
#include "esp_log.h"
#define DATA_PIN GPIO_NUM_21
#define SCK_PIN GPIO_NUM_22
static const char *TAG = "SHT11";
void app_main() {
ESP_LOGI(TAG, "Initializing SHT11...");
sht1x_dev_t dev;
sht1x_init(&dev, DATA_PIN, SCK_PIN);
while (1) {
float temperature, humidity;
if (sht1x_read_temperature(&dev, &temperature) == ESP_OK &&
sht1x_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 SHT11 sensor");
}
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}This ESP-IDF code configures the ESP32 to communicate with the SHT11 sensor using its proprietary Sensibus interface. The sht1x_init function initializes the sensor, while the sht1x_read_temperature and sht1x_read_humidity functions 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: sht1x
data_pin: GPIO21
clock_pin: GPIO22
temperature:
name: "SHT11 Temperature"
humidity:
name: "SHT11 Humidity"
update_interval: 2sThis ESPHome configuration sets up the SHT11 sensor to measure temperature and humidity. The sensor communicates over GPIO pins 21 and 22 using its Sensibus protocol. The readings update every two seconds.
platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
panStamp/SHT1x Library
wire
monitor_speed = 115200main.cpp
#include <SHT1x.h>
#define dataPin 21
#define clockPin 22
SHT1x sht1x(dataPin, clockPin);
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.print("Temperature: ");
Serial.print(sht1x.readTemperatureC(), 1);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(sht1x.readHumidity(), 1);
Serial.println(" %");
delay(2000);
}This PlatformIO code initializes the SHT11 sensor using the SHT1x library. The sensor communicates over GPIO pins 21 and 22 using its proprietary Sensibus interface. The program continuously reads and prints temperature and humidity values to the Serial Monitor every two seconds.
Wrapping Up SHT11
The ESP32 SHT11 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 SHT11 into your ESP32 project and bring your ideas to life!






