Gravity_BMP280_Barometric_Pressure_Sensors_SKU_SEN0251-DFRobot

SEN0251

Introduction

The newly introduced BMP388 barometric pressure sensor by DFRobot is equipped with the functionality of temperature and pressure measurement. It supports Arduino code control. Compared with the earlier version of BMP180 and BMP280, this sensor exhibits lower power consumption, higher resolution and higher sampling rate. The barometric pressure is usually used to measure barometric pressure and temperature. But besides that, we can also use the sensor to measure the altitude and the relative floor height due to the fact that there is a certain relationship between altitude and barometric pressure. What’s more, BMP388 enables accurate GPS tracking. So with an IMU sensor and BMP388, you can experience 3D indoor positioning and navigation. BMP388 is based on Bosch’s mature Piezo resistive pressure sensor technology featuring high accuracy as well as low power consumption and high EMC robustness. The sensor features an accuracy of about ±8Pa, which is equivalent to about ±0.5m difference in altitude, and an absolute accuracy temperature of ±0.5℃ for a temperature range between 0℃ and 65℃.


warning_yellow.png Note: do not touch the sensor with your fingers since it is extremely sensitive to the outside environment.


Applications

Specification

Pinout

Silk-screen Description
SDA IIC Data
SCL IIC Clock
INT Interrupt Output Pin
SCK SPI-CLK
SDI SPI-MOSI
CSB SPI-CS
SDO SPI-MISO/IIC Address Select
GND Negative Pole
VCC Positive Pole

Tutorial

To detect the barometric pressure and temperature of the current environment and calculate the altitude of the environment in which the module is located.

Preparation

Hardware

Connection Diagram

Connect the module with UNO main board through I2C interface, as the way shown below.

connection diagram

Sample Code

Download BMP3XX library file. How to install the library? Copy the following codes and burn them into the single-chip.

#include <DFRobot_BMP3XX.h>

/* If using Gravity products, choose these two interfaces and comment subsequent interfaces. */
// DFRobot_BMP388_I2C sensor;
// DFRobot_BMP390L_I2C sensor;

/**
 * Select the chip version BMP388/BMP390L
 * Select communication interface I2C, please comment out SPI interface.
 * I2C communication address settings: eSDOGND: connect SDO pin to GND, I2C address is 0×76 now.
 *                   eSDOVDD: Connect SDO pin to VDDIO (3v3), I2C address is 0×77 now
 */
// DFRobot_BMP388_I2C sensor(&Wire, sensor.eSDOVDD);
DFRobot_BMP390L_I2C sensor(&Wire, sensor.eSDOVDD);

/**
 * Select chip version BMP388/BMP390L
 * Select communication port SPI, please comment out I2C port
 * Set up digital pin according to the on-board pin connected with SPI chip-select pin.
 * Notice: csPin used here is D3 digital pin on ESP32, other non-conflicting pins can also be selected as external interrupt pins.
 */
// uint8_t csPin = D3;
// DFRobot_BMP388_SPI sensor(&SPI, csPin);
// DFRobot_BMP390L_SPI sensor(&SPI, csPin);


/* If you do not need to eliminate the absolute difference of measurement, please comment the following line */
#define CALIBRATE_ABSOLUTE_DIFFERENCE

void setup(void)
{
  Serial.begin(115200);

  int rslt;
  while( ERR_OK != (rslt = sensor.begin()) ){
    if(ERR_DATA_BUS == rslt){
      Serial.println("Data bus error!!!");
    }else if(ERR_IC_VERSION == rslt){
      Serial.println("Chip versions do not match!!!");
    }
    delay(3000);
  }
  Serial.println("Begin ok!");

  /**
   * 6 commonly used sampling modes that allows users to configure easily, mode:
   *      eUltraLowPrecision, Ultra-low precision, suitable for monitoring weather (lowest power consumption), the power is mandatory mode.
   *      eLowPrecision, Low precision, suitable for random detection, power is normal mode
   *      eNormalPrecision1, Normal precision 1, suitable for dynamic detection on handheld devices (e.g on mobile phones), power is normal mode.
   *      eNormalPrecision2, Normal precision 2, suitable for drones, power is normal mode.
   *      eHighPrecision, High precision, suitable for low-power handled devices (e.g mobile phones), power is in normal mode.
   *      eUltraPrecision, Ultra-high precision, suitable for indoor navigation, its acquisition rate will be extremely low, and the acquisition cycle is 1000 ms.
   */
  while( !sensor.setSamplingMode(sensor.eUltraPrecision) ){
    Serial.println("Set samping mode fail, retrying....");
    delay(3000);
  }

  delay(100);
  #ifdef CALIBRATE_ABSOLUTE_DIFFERENCE
  /**
   * Calibrate the sensor according to the current altitude
   * In this example, we use an altitude of 540 meters in Wenjiang District of Chengdu (China). 
   * Please change to the local altitude when using it.
   * If this interface is not called, the measurement data will not eliminate the absolute difference.
   * Notice: This interface is only valid for the first call.
   */
  if( sensor.calibratedAbsoluteDifference(540.0) ){
    Serial.println("Absolute difference base value set successfully!");
  }
  #endif

  float sampingPeriodus = sensor.getSamplingPeriodUS();
  Serial.print("samping period : ");
  Serial.print(sampingPeriodus);
  Serial.println(" us");

  float sampingFrequencyHz = 1000000 / sampingPeriodus;
  Serial.print("samping frequency : ");
  Serial.print(sampingFrequencyHz);
  Serial.println(" Hz");

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

void loop()
{
  float temperature = sensor.readTempC();
  Serial.print("temperature : ");
  Serial.print(temperature);
  Serial.println(" C");

  float Pressure = sensor.readPressPa();
  Serial.print("Pressure : ");
  Serial.print(Pressure);
  Serial.println(" Pa");

  float altitude = sensor.readAltitudeM();
  Serial.print("Altitude : ");
  Serial.print(altitude);
  Serial.println(" m");

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

Result

Check the value the program read via serial port.

COM15

More Documents

Schematic Diagram

BMP388 Datasheet

For any other questions, advice or cool ideas to share, please visit the DFRobot Forum.