HTE501 Temperature and Humidity Sensor

View on Amazon
Overview
About HTE501 Temperature and Humidity Sensor
The HTE501 is a high-precision digital humidity and temperature sensor, designed for accurate environmental monitoring. With fast response time and long-term stability, it is ideal for industrial, HVAC, and IoT applications.
⚡ Key Features
- High Accuracy – Provides precise humidity and temperature measurements.
- Digital Output – Communicates via I²C for seamless integration.
- Fast Response & Stability – Reliable performance in dynamic environments.
- Compact & Energy-Efficient – Suitable for battery-powered applications.
The HTE501 is a great choice for climate control, smart home devices, and weather monitoring systems. 🚀
Get Your HTE501
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
HTE501 Specifications
Complete technical specification details for HTE501 Temperature and Humidity Sensor
📊 Technical Parameters
HTE501 Pinout
The HTE501 is an 8-pin DFN package sensor with I²C interface for temperature and humidity measurement.
Visual Pinout Diagram

Pin Types
Quick Tips
Object],[object Object],[object Object]
Object],[object Object]
DFN package (2.5mm x 2.5mm),Includes internal heater for condensation removal
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 Pin 1 (SDA) | I2C | I²C Serial Data Line. Bidirectional data communication. | Connect to ESP32 GPIO 21 (default SDA). Requires pull-up resistor. |
2 Pin 2 (GND) | Power | Ground connection. Connect to system ground. | |
3 Pin 3 (VDD) | Power | Power supply input (2.35V-3.60V). Typically use 3.3V. | Low voltage sensor - use 3.3V power supply. |
4 Pin 4 (SCL) | I2C | I²C Serial Clock Line. Clock signal for I²C communication. | Connect to ESP32 GPIO 22 (default SCL). Requires pull-up resistor. |
5 Pins 5-8 | NC/Ground | Not connected or ground pads for thermal and mechanical stability. | Connect to ground plane on PCB for best performance. |
Wiring HTE501 to ESP32
To interface the HTE501 with an ESP32 via I²C, connect VDD to 3.3V, GND to ground, SDA to GPIO 21, and SCL to GPIO 22. Add 4.7kΩ pull-up resistors on SDA and SCL lines.
Visual Wiring Diagram

Connection Status
Protocol
Pin Connections
| HTE501 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 Pin 3 (VDD) Required | 3.3V | Power supply (3.3V). Do not exceed 3.6V. | |
2 Pin 2 (GND) Required | GND | Ground connection. | |
3 Pin 1 (SDA) Required | GPIO 21 | I²C data line. Add 4.7kΩ pull-up to 3.3V. | |
4 Pin 4 (SCL) Required | GPIO 22 | I²C clock line. Add 4.7kΩ pull-up to 3.3V. |
Object]
4.7kΩ pull-up resistors on both SDA and SCL lines
Object]
SHT3x-compatible libraries (similar I²C protocol)
Object]
0.1µF bypass capacitor between VDD and GND (close to sensor)
Object]
Object]
accuracy requires stable power and good thermal coupling
HTE501 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: The HTE501 sensor is not recognized on the I2C bus, leading to communication failures.
Possible causes include incorrect wiring, improper I2C address configuration, or sensor malfunction.
Solution: Verify that the sensor's VCC and GND are properly connected to the power supply, and that SDA and SCL lines are correctly connected to the corresponding I2C pins on the microcontroller. Ensure that the I2C address matches the sensor's default or configured address. Use an I2C scanner to detect the sensor's presence on the bus. If the sensor remains undetected, consider testing with a different microcontroller or replacing the sensor.
Issue: The HTE501 sensor provides temperature or humidity readings that are inaccurate or fluctuate unexpectedly.
Possible causes include environmental interference, improper sensor placement, or lack of calibration.
Solution: Place the sensor away from direct heat sources, sunlight, or areas with rapid temperature changes. Ensure that the sensor is properly initialized and calibrated in the code. If inaccuracies persist, consider implementing software-based calibration adjustments based on known reference values.
Issue: Communication with the HTE501 sensor over I2C results in timeout errors, especially during single-shot measurements.
Possible causes include the sensor's clock stretching behavior during measurements, which may not be properly handled by the microcontroller's I2C implementation.
Solution: Implement a delay (e.g., 20ms) after initiating a measurement to allow the sensor to process the data before attempting to read the results. Alternatively, monitor the sensor's status register to determine when the measurement is complete before reading the data. This approach ensures synchronization between the sensor and the microcontroller, preventing timeout errors.
Issue: Compilation errors occur when attempting to use the HTE501 sensor with a development platform.
Errors such as 'undefined reference' or 'no matching function' may appear.
Solution: Ensure that the correct library for the HTE501 sensor is installed and properly included in the project. Verify that the library version is compatible with your development environment. Check for any missing dependencies and ensure that all necessary files are present. If errors persist, consider consulting the library's documentation or seeking support from the developer community.
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
HTE501 Programming Examples
Ready-to-use code examples for different platforms and frameworks
#include <Wire.h>
#include <Adafruit_SHT31.h> // Adafruit library compatible with I2C humidity/temp sensors
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup() {
Serial.begin(115200); // Start the serial communication
Wire.begin(); // Initialize I2C
// Initialize the sensor
if (!sht31.begin(0x44)) { // The default I2C address for many SHT3x sensors is 0x44
Serial.println("Couldn't find HTE501 sensor!");
while (1) delay(1); // Stop if the sensor is not found
}
Serial.println("HTE501 Sensor initialized.");
}
void loop() {
float temperature = sht31.readTemperature(); // Read temperature in Celsius
float humidity = sht31.readHumidity(); // Read relative humidity in %
if (!isnan(temperature)) { // Check if reading is valid
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
} else {
Serial.println("Error reading temperature.");
}
if (!isnan(humidity)) { // Check if reading is valid
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
} else {
Serial.println("Error reading humidity.");
}
delay(2000); // Wait for 2 seconds before the next reading
}setup() function initializes serial communication, the I2C bus, and the sensor. If the sensor initialization fails, an error message is printed, and the program halts. In the loop() function, temperature and humidity values are read using the library's methods, checked for validity, and then printed to the Serial Monitor. A 2-second delay ensures manageable update intervals.#include <stdio.h>
#include "driver/i2c.h"
#include "esp_log.h"
#include "sdkconfig.h"
#define I2C_MASTER_SCL_IO 22 // GPIO number for I2C SCL
#define I2C_MASTER_SDA_IO 21 // GPIO number for I2C SDA
#define I2C_MASTER_NUM I2C_NUM_0 // I2C port number for master
#define I2C_MASTER_FREQ_HZ 100000 // I2C master clock frequency
#define I2C_MASTER_TX_BUF_DISABLE 0 // I2C master doesn't need buffer
#define I2C_MASTER_RX_BUF_DISABLE 0 // I2C master doesn't need buffer
#define HTE501_SENSOR_ADDR 0x44 // I2C address for the HTE501 sensor
#define HTE501_CMD_MEASURE 0x2C06 // Command for measurement
static const char *TAG = "HTE501";
void i2c_master_init() {
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_param_config(I2C_MASTER_NUM, &conf);
i2c_driver_install(I2C_MASTER_NUM, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
}
float read_humidity_temperature(float *temperature, float *humidity) {
uint8_t data[6];
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (HTE501_SENSOR_ADDR << 1) | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, HTE501_CMD_MEASURE >> 8, true);
i2c_master_write_byte(cmd, HTE501_CMD_MEASURE & 0xFF, true);
i2c_master_stop(cmd);
i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
vTaskDelay(50 / portTICK_RATE_MS); // Wait for measurement
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (HTE501_SENSOR_ADDR << 1) | I2C_MASTER_READ, true);
i2c_master_read(cmd, data, 6, I2C_MASTER_LAST_NACK);
i2c_master_stop(cmd);
i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
// Convert the data
uint16_t raw_temp = (data[0] << 8) | data[1];
uint16_t raw_hum = (data[3] << 8) | data[4];
*temperature = -45 + 175 * ((float)raw_temp / 65535.0);
*humidity = 100 * ((float)raw_hum / 65535.0);
return ESP_OK;
}
void app_main() {
i2c_master_init();
float temperature, humidity;
while (1) {
if (read_humidity_temperature(&temperature, &humidity) == ESP_OK) {
ESP_LOGI(TAG, "Temperature: %.2f °C", temperature);
ESP_LOGI(TAG, "Humidity: %.2f %%", humidity);
} else {
ESP_LOGE(TAG, "Could not read from sensor");
}
vTaskDelay(2000 / portTICK_RATE_MS); // Delay for 2 seconds
}
}i2c_master_init() function configures and initializes the I2C interface. The read_humidity_temperature() function sends measurement commands to the sensor, retrieves the raw data, and converts it to temperature and humidity values using the sensor's scaling formulas. In the app_main() function, the temperature and humidity are read in an infinite loop and logged via ESP_LOG. A 2-second delay is added between readings.sensor:
- platform: hte501
temperature:
name: "Office Temperature"
humidity:
name: "Office Humidity"
address: 0x40
update_interval: 60splatform key specifies the sensor type, and the I2C address is provided under the address key (e.g., 0x40). The temperature and humidity keys define the outputs with user-friendly names like 'Office Temperature' and 'Office Humidity.' The update_interval key ensures sensor readings are updated every 60 seconds.platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = espidf
monitor_speed = 115200
lib_deps =
esp-idf-esp32
Wiremain.cpp
#include <stdio.h>
#include "driver/i2c.h"
#include "esp_log.h"
#define I2C_MASTER_SCL_IO 22 // GPIO number for I2C SCL
#define I2C_MASTER_SDA_IO 21 // GPIO number for I2C SDA
#define I2C_MASTER_NUM I2C_NUM_0 // I2C port number for master
#define I2C_MASTER_FREQ_HZ 100000 // I2C master clock frequency
#define I2C_MASTER_TX_BUF_DISABLE 0 // I2C master doesn't need buffer
#define I2C_MASTER_RX_BUF_DISABLE 0 // I2C master doesn't need buffer
#define HTE501_SENSOR_ADDR 0x44 // I2C address for the HTE501 sensor
#define HTE501_CMD_MEASURE 0x2C06 // Command for measurement
static const char *TAG = "HTE501";
void i2c_master_init() {
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_param_config(I2C_MASTER_NUM, &conf);
i2c_driver_install(I2C_MASTER_NUM, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
}
float read_humidity_temperature(float *temperature, float *humidity) {
uint8_t data[6];
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (HTE501_SENSOR_ADDR << 1) | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, HTE501_CMD_MEASURE >> 8, true);
i2c_master_write_byte(cmd, HTE501_CMD_MEASURE & 0xFF, true);
i2c_master_stop(cmd);
i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
vTaskDelay(50 / portTICK_RATE_MS); // Wait for measurement
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (HTE501_SENSOR_ADDR << 1) | I2C_MASTER_READ, true);
i2c_master_read(cmd, data, 6, I2C_MASTER_LAST_NACK);
i2c_master_stop(cmd);
i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
// Convert the data
uint16_t raw_temp = (data[0] << 8) | data[1];
uint16_t raw_hum = (data[3] << 8) | data[4];
*temperature = -45 + 175 * ((float)raw_temp / 65535.0);
*humidity = 100 * ((float)raw_hum / 65535.0);
return ESP_OK;
}
void app_main() {
i2c_master_init();
float temperature, humidity;
while (1) {
if (read_humidity_temperature(&temperature, &humidity) == ESP_OK) {
ESP_LOGI(TAG, "Temperature: %.2f °C", temperature);
ESP_LOGI(TAG, "Humidity: %.2f %%", humidity);
} else {
ESP_LOGE(TAG, "Could not read from sensor");
}
vTaskDelay(2000 / portTICK_RATE_MS); // Delay for 2 seconds
}
}i2c_master_init() function configures the I2C master interface with GPIO pins 21 (SDA) and 22 (SCL). The read_humidity_temperature() function sends measurement commands to the HTE501, retrieves the raw sensor data, and calculates temperature and humidity using the sensor's conversion formulas. The app_main() function continuously reads and logs temperature and humidity values every 2 seconds.Wrapping Up HTE501
The ESP32 HTE501 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 HTE501 into your ESP32 project and bring your ideas to life!






