Note

Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.

Why Join?

  • Expert Support: Solve post-sale issues and technical challenges with help from our community and team.

  • Learn & Share: Exchange tips and tutorials to enhance your skills.

  • Exclusive Previews: Get early access to new product announcements and sneak peeks.

  • Special Discounts: Enjoy exclusive discounts on our newest products.

  • Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.

👉 Ready to explore and create with us? Click [here] and join today!

Temperature, Humidity & Pressure Sensor (BMP280)

../_images/14_gy_bme280_3.3_module.png

Introduction

The BMP280, developed by Bosch Sensortec, is a high-precision, low-power digital sensor module for measuring barometric pressure and temperature. It is widely used in mobile devices, weather monitoring, altitude estimations, and various other applications that require accurate atmospheric pressure and temperature data due to its small size and superior performance.

Principle

A BMP280 high precision atmospheric pressure sensor module works by using a BMP280 sensor from Bosch that can measure both pressure and temperature. The BMP280 sensor has a piezoresistive pressure sensor and a thermistor inside a sealed metal chamber. The piezoresistive sensor changes its resistance according to the pressure applied to the chamber. The thermistor changes its resistance according to the temperature inside the chamber. The module has an integrated circuit that converts the resistance values into digital signals and sends them to the Arduino through either I2C or SPI interface.

Module Schematic Diagram

../_images/14_bmp280_module_schematic.png

Usage

Hardware components

  • Arduino Uno R4 or R3 board * 1

  • Temperature, Humidity & Pressure Sensor(GY-BMP280-3.3) * 1

  • Jumper Wires

Circuit Assembly

../_images/14_gy_bme280_3.3_module_circuit.png

Code

Note

To install the library, use the Arduino Library Manager and search for “Adafruit BMP280” and install it.



Code explanation

  1. Including Libraries and Initialization. Necessary libraries are included and the BMP280 sensor is initialized for communication using the I2C interface.

    Note

    To install the library, use the Arduino Library Manager and search for “Adafruit BMP280” and install it.

    • Adafruit BMP280 Library: This library provides an easy-to-use interface for the BMP280 sensor, allowing the user to read temperature, pressure, and altitude.

    • Wire.h: Used for I2C communication.


    #include <Wire.h>
    #include <Adafruit_BMP280.h>
    #define BMP280_ADDRESS 0x76
    Adafruit_BMP280 bmp;  // use I2C interface
    
  2. The setup() function initializes the Serial communication, checks for the BMP280 sensor, and sets up the sensor with default settings.

    void setup() {
      Serial.begin(9600);
      while (!Serial) delay(100);
      Serial.println(F("BMP280 test"));
      unsigned status;
      status = bmp.begin(BMP280_ADDRESS);
      // ... (rest of the setup code)
    
  3. The loop() function reads data from the BMP280 sensor for temperature, pressure, and altitude. This data is printed to the Serial Monitor.

    void loop() {
      // ... (read and print temperature, pressure, and altitude data)
      delay(2000);  // 2-second delay between readings.
    }
    

Additional Ideas

  • Integrate an LCD display module to show the readings instead of or in addition to the Serial Monitor.

  • Set threshold values for temperature and pressure. Use a buzzer or LED to alert when these thresholds are exceeded.

More Projects