Skip to main content
ESPBoards

ESP32 SHT35 Temperature and Humidity Sensor

The SHT35 sensor is a high-precision digital temperature and humidity sensor that utilizes Sensirion's CMOSens® technology. It provides fully calibrated, linearized, and temperature-compensated digital output, making it ideal for applications requiring precise and reliable environmental measurements.

Jump to Code Examples

Arduino Core Image
ESP-IDF Image
ESPHome Image
PlatformIO Image
MicroPython Image

Quick Links

SHT35 Temperature and Humidity Sensor Datasheet ButtonSHT35 Temperature and Humidity Sensor Specs ButtonSHT35 Temperature and Humidity Sensor Specs ButtonSHT35 Temperature and Humidity Sensor Specs Button

SHT35 Price

SHT35 Temperature and Humidity Sensor
Normally, the SHT35 Temperature and Humidity Sensor costs around Approximately $10 per unit.
The prices are subject to change. Check current price:

Amazon com

Amazon de logo

Aliexpress logo

About SHT35 Temperature and Humidity Sensor

The SHT35, developed by Sensirion, is the high-end model in the SHT3x series of digital temperature and humidity sensors. It offers superior accuracy and reliability, making it ideal for demanding applications such as industrial monitoring, HVAC systems, and environmental data logging. For more cost-effective solutions, consider the [SHT30](/blog/sht30/) or [SHT31](/sensors/sht31/) sensors, which provide good performance at lower price points.

SHT35 Sensor Technical Specifications

Below you can see the SHT35 Temperature and Humidity Sensor Technical Specifications. The sensor is compatible with the ESP32, operating within a voltage range suitable for microcontrollers. For precise details about its features, specifications, and usage, refer to the sensor’s datasheet.

  • Protocol: I2C
  • Operating Voltage: 2.4V to 5.5V
  • Temperature Range: -40°C to 125°C
  • Humidity Range: 0% to 100% RH
  • Temperature Accuracy: ±0.1°C
  • Humidity Accuracy: ±1.5% RH
  • Interface: I2C
  • Dimensions: 2.5mm x 2.5mm x 0.9mm

SHT35 Sensor Pinout

Below you can see the pinout for the SHT35 Temperature and Humidity Sensor. The VCC pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND pin is the ground connection and must be connected to the ground of your ESP32!

The SHT35 pinout is as follows:

  • VDD: Power supply voltage (2.4V to 5.5V).
  • GND: Ground.
  • SDA: Serial Data Line for I2C communication.
  • SCL: Serial Clock Line for I2C communication.

SHT35 Wiring with ESP32

Below you can see the wiring for the SHT35 Temperature and Humidity Sensor with the ESP32. Connect the VCC pin of the sensor to the 3.3V pin on the ESP32 or external power supply for power and the GND pin of the sensor to the GND pin of the ESP32. Depending on the communication protocol of the sensor (e.g., I2C, SPI, UART, or analog), connect the appropriate data and clock or signal pins to compatible GPIO pins on the ESP32, as shown below in the wiring diagram.

To interface the SHT35 with an ESP32:
  • Connect VDD to the 3.3V pin on the ESP32.
  • Connect GND to the ground (GND) of the ESP32.
  • Connect SDA to the ESP32's GPIO21 (default I2C data pin).
  • Connect SCL to the ESP32's GPIO22 (default I2C clock pin).
  • Place pull-up resistors (10kΩ) between SDA and VDD, and SCL and VDD, to ensure reliable communication.

Code Examples

Below you can find code examples of SHT35 Temperature and Humidity Sensor with ESP32 in several frameworks:

If you encounter issues while using the SHT35 Temperature and Humidity Sensor, check the Common Issues Troubleshooting Guide.

Arduino Core Image

ESP32 SHT35 Arduino IDE Code Example

Example in Arduino IDE

Fill in your main Arduino IDE sketch file with the following code to use the SHT35 Temperature and Humidity Sensor:

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

Adafruit_SHT31 sht31 = Adafruit_SHT31();

void setup() {
Serial.begin(115200);
while (!Serial) delay(10);

if (!sht31.begin(0x44)) { // Set to 0x45 for alternate I2C address
Serial.println("Couldn't find SHT35");
while (1) delay(1);
}
}

void loop() {
float t = sht31.readTemperature();
float h = sht31.readHumidity();

if (!isnan(t) && !isnan(h)) { // check if 'is not a number'
Serial.print("Temp *C = "); Serial.print(t); Serial.print(" ");
Serial.print("Hum. % = "); Serial.println(h);
} else {
Serial.println("Failed to read from SHT35 sensor");
}

delay(1000);
}

This Arduino sketch demonstrates how to interface with the SHT35 sensor using the Adafruit SHT31 library. It initializes the sensor and reads temperature and humidity data every second, printing the results to the Serial Monitor. The sensor's I2C address is set to 0x44 by default; if your sensor uses the alternate address (0x45), adjust the initialization accordingly.

Connect your ESP32 to your computer via a USB cable, Ensure the correct Board and Port are selected under Tools, Click the "Upload" button in the Arduino IDE to compile and upload the code to your ESP32.

ESP-IDF Image

ESP32 SHT35 ESP-IDF Code Example
Example in Espressif IoT Framework (ESP-IDF)

If you're using ESP-IDF to work with the SHT35 Temperature and Humidity Sensor, here's how you can set it up and read data from the sensor. Fill in this code in the main ESP-IDF file:

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/i2c.h"

#define I2C_MASTER_SCL_IO 22 /*!< GPIO number used for I2C master clock */
#define I2C_MASTER_SDA_IO 21 /*!< GPIO number used for I2C master data */
#define I2C_MASTER_NUM I2C_NUM_0 /*!< I2C master I2C port number */
#define I2C_MASTER_FREQ_HZ 100000 /*!< I2C master clock frequency */
#define SHT35_SENSOR_ADDR 0x44 /*!< SHT35 I2C address */

static esp_err_t i2c_master_init(void) {
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.scl_io_num = I2C_MASTER_SCL_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
esp_err_t err = i2c_param_config(I2C_MASTER_NUM, &conf);
if (err != ESP_OK) {
return err;
}
return i2c_driver_install(I2C_MASTER_NUM, conf.mode, 0, 0, 0);
}

void read_sht35_sensor() {
uint8_t data[6];
i2c_master_write_read_device(I2C_MASTER_NUM, SHT35_SENSOR_ADDR, NULL, 0, data, sizeof(data), pdMS_TO_TICKS(1000));

uint16_t temp_raw = (data[0] << 8) | data[1];
uint16_t hum_raw = (data[3] << 8) | data[4];

float temperature = -45 + 175 * ((float)temp_raw / 65535.0);
float humidity = 100 * ((float)hum_raw / 65535.0);

printf("Temperature: %.2f °C, Humidity: %.2f %%\n", temperature, humidity);
}

void app_main() {
ESP_ERROR_CHECK(i2c_master_init());

while (1) {
read_sht35_sensor();
vTaskDelay(pdMS_TO_TICKS(2000));
}
}

This ESP-IDF code demonstrates how to interface with the SHT35 sensor using the I2C interface. The I2C master is initialized on GPIO21 (SDA) and GPIO22 (SCL). The `read_sht35_sensor()` function reads raw temperature and humidity data from the SHT35 sensor and converts it into human-readable values. These values are printed to the console every 2 seconds.

Update the I2C pins (I2C_MASTER_SDA_IO and I2C_MASTER_SCL_IO) to match your ESP32 hardware setup, Use idf.py build to compile the project, Use idf.py flash to upload the code to your ESP32.

ESPHome Image

ESP32 SHT35 ESPHome Code Example

Example in ESPHome (Home Assistant)

Fill in this configuration in your ESPHome YAML configuration file (example.yml) to integrate the SHT35 Temperature and Humidity Sensor

sensor:
- platform: sht3x
address: 0x44
temperature:
name: "Living Room Temperature"
humidity:
name: "Living Room Humidity"
update_interval: 60s

This ESPHome configuration defines the SHT35 sensor using the `sht3x` platform. The I2C address is set to 0x44 (default for the sensor). Two entities are configured: one for temperature and one for humidity, with descriptive names like 'Living Room Temperature' and 'Living Room Humidity.' The `update_interval` is set to 60 seconds, meaning the data will be updated every minute.

Upload this code to your ESP32 using the ESPHome dashboard or the esphome run command.

PlatformIO Image

ESP32 SHT35 PlatformIO Code Example

Example in PlatformIO Framework

For PlatformIO, make sure to configure the platformio.ini file with the appropriate environment and libraries, and then proceed with the code.

Configure platformio.ini

First, your platformio.ini should look like below. You might need to include some libraries as shown. Make sure to change the board to your ESP32:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
adafruit/Adafruit SHT31 Library @ ^1.2.0
monitor_speed = 115200

ESP32 SHT35 PlatformIO Example Code

Write this code in your PlatformIO project under the src/main.cpp file to use the SHT35 Temperature and Humidity Sensor:

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

Adafruit_SHT31 sht35 = Adafruit_SHT31();

void setup() {
Serial.begin(115200);
while (!Serial) delay(10);

if (!sht35.begin(0x44)) { // Default I2C address for SHT35
Serial.println("Couldn't find SHT35 sensor!");
while (1) delay(1);
}
}

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

if (!isnan(temperature) && !isnan(humidity)) { // Check if readings are valid
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
} else {
Serial.println("Failed to read from SHT35 sensor!");
}

delay(2000); // Wait 2 seconds between readings
}

This PlatformIO sketch demonstrates how to interface with the SHT35 sensor using the Adafruit SHT31 library. The sensor is initialized on its default I2C address (0x44). Temperature and humidity values are read every 2 seconds and printed to the Serial Monitor. If readings fail, an error message is displayed.

Upload the code to your ESP32 using the PlatformIO "Upload" button in your IDE or the pio run --target upload command.

MicroPython Image

ESP32 SHT35 MicroPython Code Example

Example in Micro Python Framework

Fill in this script in your MicroPython main.py file (main.py) to integrate the SHT35 Temperature and Humidity Sensor with your ESP32.

from machine import I2C, Pin
import time

# SHT35 default I2C address
SHT35_I2C_ADDRESS = 0x44

# Initialize I2C communication (SDA=21, SCL=22)
i2c = I2C(0, scl=Pin(22), sda=Pin(21))

def read_sht35():
# Send measurement command (high repeatability, no clock stretching)
i2c.writeto(SHT35_I2C_ADDRESS, b'\x24\x00')
time.sleep(0.015) # Wait for measurement to complete

# Read 6 bytes of data
data = i2c.readfrom(SHT35_I2C_ADDRESS, 6)

# Convert the data
temp_raw = (data[0] << 8) | data[1]
humidity_raw = (data[3] << 8) | data[4]

# Calculate temperature and humidity
temperature = -45 + (175 * temp_raw / 65535.0)
humidity = 100 * humidity_raw / 65535.0

return temperature, humidity

while True:
try:
temperature, humidity = read_sht35()
print("Temperature: {:.2f} °C".format(temperature))
print("Humidity: {:.2f} %".format(humidity))
except Exception as e:
print("Failed to read from SHT35 sensor:", e)

time.sleep(2)

This MicroPython script interfaces with the SHT35 sensor using the I2C protocol. The `read_sht35` function sends a command to the sensor to initiate a measurement, waits for the response, and then reads 6 bytes of data. The raw data is processed into human-readable temperature (°C) and humidity (%) values. The script continuously reads and prints these values every 2 seconds. Error handling is included to manage failed readings.

Upload this code to your ESP32 using a MicroPython-compatible IDE, such as Thonny, uPyCraft, or tools like ampy.

SHT35 Temperature and Humidity Sensor Troubleshooting

This guide outlines a systematic approach to troubleshoot and resolve common problems with the . Start by confirming that the hardware connections are correct, as wiring mistakes are the most frequent cause of issues. If you are sure the connections are correct, follow the below steps to debug common issues.

Compilation Error: 'yield' was not declared in this scope

Issue: When compiling code for the SHT35 sensor using the Seeed Studio library, the following error occurs: 'yield' was not declared in this scope.

Possible causes include outdated or incorrect library versions that are incompatible with the current Arduino IDE.

Solution: Update the Arduino IDE to the latest version and ensure that the Seeed Studio SHT35 library is also up to date. If the issue persists, manually edit the library files to include the appropriate declarations or consider using an alternative library compatible with the SHT35 sensor. (forum.arduino.cc)

Runtime Error: Errno 121 Remote I/O Error

Issue: When running a Python script on a Raspberry Pi to read data from the SHT35 sensor, the following error is encountered after a period of successful readings: Errno 121 Remote I/O Error.

Possible causes include intermittent I2C communication issues, loose connections, or power supply instability.

Solution: Check all physical connections between the Raspberry Pi and the SHT35 sensor to ensure they are secure. Verify that the I2C bus is properly configured and that pull-up resistors are correctly implemented. Additionally, monitor the power supply to ensure it remains stable during operation. (forum.seeedstudio.com)

Sensor Not Detected on I2C Bus

Issue: The SHT35 sensor is not detected on the I2C bus, resulting in failed communication attempts.

Possible causes include incorrect wiring, improper I2C address configuration, or sensor malfunction.

Solution: Verify that the SDA and SCL lines are correctly connected to the appropriate pins on the microcontroller. Ensure that the sensor's I2C address matches the address specified in the code (default is 0x44). If using multiple I2C devices, confirm that there are no address conflicts. Test the sensor with an I2C scanner to detect its presence on the bus. (arduinolearning.com)

Data Retrieval Issues with Multiple Clients

Issue: When accessing the SHT35 sensor data from multiple clients simultaneously, the sensor becomes unresponsive, requiring a system reboot to restore functionality.

Possible causes include concurrent access to the I2C bus leading to communication conflicts.

Solution: Implement a data caching mechanism where a single process reads data from the sensor at regular intervals and stores it. Clients can then access the cached data instead of querying the sensor directly. This approach prevents simultaneous I2C access and reduces the risk of communication issues. (forums.raspberrypi.com)

Conclusion

We went through technical specifications of SHT35 Temperature and Humidity Sensor, its pinout, connection with ESP32 and SHT35 Temperature and Humidity Sensor code examples with Arduino IDE, ESP-IDF, ESPHome and PlatformIO.