KY-052 Pressure and Temperature Sensor Module

The KY-052 module features the BMP280 sensor, offering accurate measurements of barometric pressure and temperature. It utilizes the <strong>I2C interface</strong> for communication, making it ideal for environmental monitoring projects.

I2C KY-0xx module Pressure_temperature
KY-052 Pressure and Temperature Sensor Module image
KY-052 · I2C
I2C
Interface
6pins
Connections
$3
Typical price
On this page

KY-052 pinout

6 pins · I2C

The KY-052 is a 6-pin barometric pressure and temperature sensor module:

View:
KY-052 Pressure and Temperature Sensor Module pinout
PinTypeDescriptionNotes
GNDPowerGround connection
VCCPowerPower supply3.3V or 5V
SDACommunicationI2C data lineBidirectional data
SCLCommunicationI2C clock lineClock signal
CSBCommunicationChip select for SPIConnect to VCC for I2C mode
SDOCommunicationSPI data outputNot used in I2C mode
  • 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

Wiring the KY-052 to ESP32

6 connections · 1 optional

To interface the KY-052 with an ESP32 for pressure/temperature sensing (I2C mode):

Wiring diagram coming soon
The pin-to-pin table covers every connection.
KY-052 pinESP32 pinPurpose
GNDGNDGround
VCC3.3V or 5VPower supply
SDAGPIO21I2C data (default ESP32 I2C SDA)
SCLGPIO22I2C clock (default ESP32 I2C SCL)
CSBVCCConnect to VCC for I2C mode
SDONC or GND/VCCLeave NC, or connect to GND (0x76) or VCC (0x77) for address · optional
  • 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 code examples

5 platforms
Platform:

KY-052 Arduino example

Copy
#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.

KY-052 ESP-IDF example

Copy
// Requires the esp-idf-lib BMP280 driver from the ESP Component Registry:
//   idf.py add-dependency "esp-idf-lib/bmp280^1.0.7"

#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "bmp280.h"

#define SDA_GPIO GPIO_NUM_21
#define SCL_GPIO GPIO_NUM_22

void app_main(void)
{
    ESP_ERROR_CHECK(i2cdev_init());

    bmp280_params_t params;
    bmp280_init_default_params(&params);
    bmp280_t dev;
    memset(&dev, 0, sizeof(bmp280_t));

    ESP_ERROR_CHECK(bmp280_init_desc(&dev, BMP280_I2C_ADDRESS_0, 0, SDA_GPIO, SCL_GPIO));
    ESP_ERROR_CHECK(bmp280_init(&dev, &params));

    float pressure, temperature;
    while (1) {
        if (bmp280_read_float(&dev, &temperature, &pressure, NULL) == ESP_OK)
            printf("Temp %.2f C, Press %.2f Pa\n", temperature, pressure);
        else
            printf("Could not read data from sensor\n");
        vTaskDelay(pdMS_TO_TICKS(2000));
    }
}

ESP-IDF ships no BMP280 driver of its own, so this example uses the maintained esp-idf-lib BMP280 driver from the ESP Component Registry. Install it into your project first with idf.py add-dependency "esp-idf-lib/bmp280^1.0.7", then build as usual.

i2cdev_init() sets up the shared I2C layer used by all esp-idf-lib drivers, and bmp280_read_float() returns temperature in Celsius and pressure in Pascal every 2 seconds. The humidity argument is NULL because the KY-052's BMP280 has no humidity sensor (the same driver also supports the BME280, which does). Wire SDA to GPIO 21 and SCL to GPIO 22, or change the defines.

KY-052 ESPHome example

Copy
i2c:
  sda: GPIO21
  scl: GPIO22

sensor:
  - platform: bmp280_i2c
    temperature:
      name: "KY-052 Temperature"
    pressure:
      name: "KY-052 Pressure"
    address: 0x76
    update_interval: 2s

Since ESPHome 2023.12 the BMP280 platform is split by bus - bmp280_i2c here, with the KY-052 at address 0x76 on the default I2C pins. Temperature and pressure each become their own entity.

KY-052 PlatformIO example

Copy
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
    adafruit/Adafruit BMP280 Library
    adafruit/Adafruit Unified Sensor
src/main.cppCopy
#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.

KY-052 MicroPython example

Copy
# Requires driver: bmp280.py from https://github.com/dafvid/micropython-bmp280
# Copy it to the board: mpremote cp bmp280.py :
from time import sleep
from machine import I2C, Pin
from bmp280 import BMP280

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

# Initialize KY-052 (BMP280, address 0x76)
bmp = BMP280(i2c)

while True:
    print("KY-052 Temperature: {:.2f} C".format(bmp.temperature))
    print("Pressure: {:.2f} hPa".format(bmp.pressure / 100))
    sleep(2)

The example uses dafvid/micropython-bmp280 (copy bmp280.py to the board with mpremote) for the KY-052's BMP280. The driver exposes temperature (Celsius) and pressure (Pascal - divided by 100 to print hPa); it has no altitude property, but you can derive altitude from pressure with the barometric formula if needed.

KY-052 specifications

From the datasheet
Pressure Measuring Range
300 to 1100 hPa (equivalent to +9000 to -500 m above/below sea level)
Relative Accuracy
±0.12 hPa (±1 m) within 950 to 1050 hPa at 25°C
Absolute Accuracy
±1 hPa within 950 to 1050 hPa, 0 to +40°C
Temperature Coefficient Offset
1.5 Pa/K (12.6 cm/K) from 25 to 40°C at 900 hPa
Digital Interfaces
I²C (up to 3.4 MHz), SPI (3- and 4-wire, up to 10 MHz)
Power Consumption
2.7 µA at 1 Hz sampling rate
Temperature Measuring Range
-40 to +85°C
Dimensions
22 x 34 x 6 mm

About the KY-052

The KY-052 is a breakout for Bosch’s BMP280 - the exact same chip, so any library or example written for a bare BMP280 board works here unchanged. The CSB pin is what picks the interface at power-up: tied to VCC it puts the chip in I2C mode at address 0x76 (or 0x77 with SDO pulled to VCC instead of GND), left floating or pulled low it switches the same chip into SPI, using SCL as the clock and SDA/SDO as the data lines - one sensor, two wiring options depending on what the rest of the project already uses.

What the BMP280 does not have is a humidity element, so this module reads pressure and temperature only, with pressure the more interesting of the two given its 300 to 1100 hPa range and roughly 1 hPa absolute accuracy translating to about 8 meters of altitude resolution. Projects that also want humidity from the same Bosch sensor family, weather stations especially, are better served by the BME280, which is pin- and protocol-compatible but adds a humidity element the BMP280 simply does not have.

KY-052 troubleshooting

2 common issues

Sensor Not Responding

›

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).

Incorrect Temperature or Pressure Readings

›

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).

Resources