KY-052 Pressure and Temperature Sensor Module

View on Amazon
Overview
About KY-052 Pressure and Temperature Sensor Module
The KY-052 module integrates the BMP280 sensor, capable of measuring both barometric pressure and temperature. It communicates via the I2C bus, providing precise environmental data suitable for applications like weather stations, altimeters, and mobile devices.
KY-052 Specifications
Complete technical specification details for KY-052 Pressure and Temperature Sensor Module
📊 Technical Parameters
KY-052 Pinout
The **KY-052** is a 6-pin barometric pressure and temperature sensor module:
Visual Pinout Diagram

Pin Types
Quick Tips
**Interface**: I2C (default) or SPI,🌡️ **Sensor**: BMP280 barometric pressure and temperature sensor,📊 **I2C Address**: 0x76 (SDO to GND) or 0x77 (SDO to VCC)
**Power**: 3.3V or 5V operation (onboard voltage regulator),🌍 **Pressure Range**: 300-1100 hPa (±9000m to -500m altitude),🌡️ **Temperature Range**: -40°C to +85°C
**Pressure Accuracy**: ±1 hPa (±8m altitude),🎯 **Applications**: Weather stations, altimeters, GPS enhancement, indoor navigation
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 GND | Power | Ground connection | |
2 VCC | Power | Power supply | 3.3V or 5V |
3 SDA | Communication | I2C data line | Bidirectional data |
4 SCL | Communication | I2C clock line | Clock signal |
5 CSB | Communication | Chip select for SPI | Connect to VCC for I2C mode |
6 SDO | Communication | SPI data output | Not used in I2C mode |
Wiring KY-052 to ESP32
To interface the **KY-052** with an **ESP32** for pressure/temperature sensing (I2C mode):
Pin Connections
| KY-052 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 GND Required | GND | Ground | |
2 VCC Required | 3.3V or 5V | Power supply | |
3 SDA Required | GPIO21 | I2C data (default ESP32 I2C SDA) | |
4 SCL Required | GPIO22 | I2C clock (default ESP32 I2C SCL) | |
5 CSB Required | VCC | Connect to VCC for I2C mode | |
6 SDO Optional | NC or GND/VCC | Leave NC, or connect to GND (0x76) or VCC (0x77) for address |
**I2C Mode**: Connect CSB to VCC to enable I2C communication
**I2C Address**: 0x76 (default) or 0x77 (connect SDO to VCC)
**Voltage**: 3.3V recommended for ESP32, but 5V compatible
**Pull-ups**: Internal I2C pull-ups on module (2.2kΩ typical)
**Altitude**: Calculate altitude from pressure using barometric formula
**Temperature**: Built-in temperature compensation for accurate pressure readings
**SPI Mode**: If using SPI, connect CSB to GPIO (CS), SCL to SCK, SDA to MOSI, SDO to MISO
**Power**: ~2.7μA sleep, 720μA active (very low power)
KY-052 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: The sensor does not provide any data.
Solutions:
- Ensure proper wiring connections, especially the I2C lines (SDA and SCL).
- Verify that the CSB pin is connected to VCC to enable I2C mode.
- Check that the correct I2C address is used in the code (default is 0x76 or 0x77).
Issue: The sensor outputs inaccurate environmental data.
Solutions:
- Ensure the sensor is not exposed to rapid temperature changes or drafts.
- Calibrate the sensor if necessary, especially for altitude measurements.
- Verify that the sensor is operating within its specified temperature range (-40°C to +85°C).
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
KY-052 Programming Examples
Ready-to-use code examples for different platforms and frameworks
#include <Wire.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
void setup() {
Serial.begin(9600);
if (!bmp.begin()) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while (1);
}
}
void loop() {
Serial.print(F("Temperature = "));
Serial.print(bmp.readTemperature());
Serial.println(" °C");
Serial.print(F("Pressure = "));
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.print(F("Altitude = "));
Serial.print(bmp.readAltitude(1013.25)); // Adjust to local sea level pressure
Serial.println(" m");
delay(2000);
}This Arduino code initializes the BMP280 sensor and reads temperature, pressure, and altitude data. The altitude calculation requires adjusting the sea level pressure value (1013.25 hPa) to your local value for accurate readings. The sensor data is printed to the serial monitor every 2 seconds.
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/i2c.h"
#include "bmp280.h"
#define I2C_MASTER_SCL_IO 22
#define I2C_MASTER_SDA_IO 21
#define I2C_MASTER_NUM I2C_NUM_0
#define I2C_MASTER_FREQ_HZ 100000
void app_main() {
printf("Initializing BMP280 sensor...\n");
bmp280_t bmp;
bmp280_params_t params;
bmp280_init_default_params(¶ms);
i2cdev_init();
if (bmp280_init_desc(&bmp, BMP280_I2C_ADDRESS_0, I2C_MASTER_NUM, I2C_MASTER_SDA_IO, I2C_MASTER_SCL_IO) != ESP_OK ||
bmp280_init(&bmp, ¶ms) != ESP_OK) {
printf("BMP280 sensor initialization failed!\n");
return;
}
while (1) {
float temperature, pressure, altitude;
if (bmp280_read_float(&bmp, &temperature, &pressure, &altitude) == ESP_OK) {
printf("Temperature: %.2f°C, Pressure: %.2f hPa, Altitude: %.2f m\n", temperature, pressure / 100.0, altitude);
} else {
printf("Failed to read data from BMP280\n");
}
vTaskDelay(pdMS_TO_TICKS(2000));
}
}This ESP-IDF code initializes the BMP280 sensor using the I2C interface on GPIO21 (SDA) and GPIO22 (SCL). It reads temperature, pressure, and altitude values and prints them to the console every 2 seconds.
sensor:
- platform: bmp280
temperature:
name: "KY-052 Temperature"
pressure:
name: "KY-052 Pressure"
address: 0x76
update_interval: 2sThis ESPHome configuration sets up the KY-052 sensor (BMP280) to read temperature and pressure data via I2C with an update interval of 2 seconds.
platformio.ini
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
adafruit/Adafruit BMP280 Library
adafruit/Adafruit Unified Sensormain.cpp
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
void setup() {
Serial.begin(115200);
if (!bmp.begin(0x76)) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
}
void loop() {
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" °C");
Serial.print("Pressure = ");
Serial.print(bmp.readPressure() / 100.0);
Serial.println(" hPa");
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude(1013.25)); // Adjust sea level pressure
Serial.println(" m");
delay(2000);
}This PlatformIO code configures the KY-052 sensor (BMP280) for temperature, pressure, and altitude measurement using I2C communication. It reads data every 2 seconds and prints it to the serial monitor.
from machine import Pin, I2C
import time
import bmp280
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
sensor = bmp280.BMP280(i2c)
while True:
temperature = sensor.temperature
pressure = sensor.pressure
altitude = sensor.altitude
print("Temperature:", temperature, "°C", "Pressure:", pressure, "hPa", "Altitude:", altitude, "m")
time.sleep(2)This MicroPython script configures the KY-052 sensor (BMP280) using I2C on GPIO21 (SDA) and GPIO22 (SCL). It continuously reads temperature, pressure, and altitude and prints the values every 2 seconds.
Wrapping Up KY-052
The ESP32 KY-052 Pressure and Temperature Sensor Module is a powerful KY-0xx module 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 KY-052 into your ESP32 project and bring your ideas to life!
Explore Alternative Sensors
Looking for alternatives to the KY-052? Check out these similar sensors that might fit your project needs.

KY-001 Temperature Sensor Module
The KY-001 is a temperature sensor module that operates within a wide temperature range. It supports 1-Wire communication and is based on...

KY-013 Analog Temperature Sensor Module
The KY-013 is an analog temperature sensor module utilizing an NTC thermistor. It provides temperature measurements in the range of -55°C to...

KY-022 Infrared Receiver Module
The KY-022 is an infrared receiver module capable of detecting 38kHz IR signals. It's commonly used in projects requiring remote control...




