กลับหน้าหลัก
views
How to Use ESP8266 with BMP280 to Read Temperature and Pressure
Last updated on

How to Use ESP8266 with BMP280 to Read Temperature and Pressure


How to Use ESP8266 with BMP280 to Read Temperature and Pressure

In this guide, you’ll wire a NodeMCU ESP8266 to a BMP280 sensor and read temperature, atmospheric pressure, and altitude through the Arduino IDE Serial Monitor.

Components Needed

  • NodeMCU ESP8266 V2 (CP2102)
  • BMP280 3.3V sensor module
  • Micro USB cable for programming and power
  • Breadboard MB-102 (830 points)
  • Jumper wires (male-male, male-female, female-female)
Photo showing all components laid out on a desk for the ESP8266 BMP280 project

Wiring ESP8266 to BMP280

Connect the ESP8266 to the BMP280 as follows:

ESP8266BMP280
3V3VCC
GNDGND
D2SDA
D1SCL
Circuit diagram showing wire connections between ESP8266 and BMP280 on a breadboard, every pin labeled clearly

Note: The 3.3V BMP280 module draws power directly from the ESP8266’s 3V3 pin. No voltage divider or level shifter is required.

Installing the Library

  1. Open Arduino IDE
  2. Go to Sketch > Include Library > Manage Libraries
  3. Search for Adafruit BMP280
  4. Click Install on the Adafruit BMP280 Library by Adafruit
Screenshot of Arduino IDE Library Manager with 'Adafruit BMP280' search result and Install button visible

Code for Reading BMP280

#include <Wire.h>
#include <Adafruit_BMP280.h>

Adafruit_BMP280 bmp;

void setup() {
  Serial.begin(115200);
  Serial.println(F("BMP280 Test"));

  if (!bmp.begin(0x76)) {
    Serial.println(F("Could not find BMP280 sensor!"));
    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("Approx altitude = "));
  Serial.print(bmp.readAltitude(1013.25));
  Serial.println(" m");

  Serial.println();
  delay(1000);
}

Adjust this: The value 1013.25 in readAltitude() represents the local sea-level pressure in hPa. Adjust it to your actual atmospheric pressure for more accurate altitude readings.

Uploading and Testing

  1. Connect your ESP8266 via USB
  2. Select the correct Board and Port from the Tools menu
  3. Click Upload and wait for Done Uploading
  4. Open Serial Monitor, set baud rate to 115200
  5. You will see temperature, pressure, and altitude values printed every second

[image: Serial Monitor window displaying live BMP280 readings for temperature, pressure, and altitude]

Testing the Sensor Response

With Serial Monitor open, use a hair dryer to blow warm air toward the BMP280 sensor. You should see the temperature reading rise quickly. When you stop, the value will gradually return to room temperature, confirming the sensor works correctly.

Summary

Connecting ESP8266 to BMP280 requires just four wires. After installing the library and uploading the sketch, you get real-time temperature, pressure, and altitude data. From here, you can extend this to display on an LCD screen or send data to a web server.

อยากทำโปรเจคแบบนี้?

รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน

If you need Arduino project service or urgent IoT development, see full service details on the services page

จ้างทำโปรเจคเลย

Project estimate

Want something like this? Open the estimate page.

The long form is now on a separate estimate page, so this article stays clean.

ความคิดเห็น

รีวิวจากคนใช้งานจริง

รีวิวจากลูกค้าและคนที่เคยใช้งาน

ถ้าเคยสั่งงาน เคยอ่านหน้านี้แล้วได้ประโยชน์ หรือมีข้อเสนอแนะ ฝากรีวิวไว้ได้เลย

กำลังโหลดรีวิว...