Introduction to BMP388 Sensor
The BMP388 is a 2-in-1 digital sensor that can measure temperature, absolute atmospheric pressure. Since air pressure varies with altitude, altitude can be estimated very accurately, making it very handy for drone and navigation applications.
parameter | Measuring range | accuracy |
---|---|---|
temperature | -40 to 85 ºC | +/- 0.5 ºC(0 to 65 ºC) |
air pressure | 300 to 1250 hPa | Absolute accuracy +/- 0.5hPa, relative accuracy +/- 0.08hPa |
Sampling Rate | / | 200Hz |
Interface Description
VIN- Power supply positive 3.3-5V
GND Power supply negative
3Vo Voltage regulator 3.3V output
SCK SPI/IIC mode clock signal input
SDI SPI mode MOSI data signal input, IIC mode data signal input and output
SDO SPI mode MISO data Signal output, IIC device address setting pin when in IIC mode, 1110110 (0x76) when connected to GND, 1110111 (0x77) when connected to VCC
Chip select pin in CS SPI mode, active low input
INT Interrupt output high level
BMP388 and Arduino UNO wiring and program
BMP388 | SPI wiring method | IIC wiring method |
---|---|---|
SCK | D13 | A5 |
SDI | D11 | A4 |
SDO | D12 | / |
CS | D10 | / |
IIC wiring
methodArduino IDE library manager install Adafruit_BME680 library
Arduino IDE library manager install Adafruit Unified SensorOpen
the sample code
/***************************************************************************
This is a library for the BMP3XX temperature & pressure sensor
Designed specifically to work with the Adafruit BMP388 Breakout
----> http://www.adafruit.com/products/3966
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface.
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing products
from Adafruit!
Written by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribution
***************************************************************************/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BMP3XX.h"
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BMP3XX bmp;
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("Adafruit BMP388 / BMP390 test");
if (!bmp.begin_I2C()) {
// hardware I2C mode, can pass in address & alt Wire
//if (! bmp.begin_SPI(BMP_CS)) { // hardware SPI mode
//if (! bmp.begin_SPI(BMP_CS, BMP_SCK, BMP_MISO, BMP_MOSI)) { // software SPI mode
Serial.println("Could not find a valid BMP3 sensor, check wiring!");
while (1);
}
// Set up oversampling and filter initialization
bmp.setTemperatureOversampling(BMP3_OVERSAMPLING_8X);
bmp.setPressureOversampling(BMP3_OVERSAMPLING_4X);
bmp.setIIRFilterCoeff(BMP3_IIR_FILTER_COEFF_3);
bmp.setOutputDataRate(BMP3_ODR_50_HZ);
}
void loop() {
if (! bmp.performReading()) {
Serial.println("Failed to perform reading :(");
return;
}
Serial.print("Temperature = ");
Serial.print(bmp.temperature);
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bmp.pressure / 100.0);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bmp.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.println();
delay(2000);
}
Open the serial monitor to display the data measured by the sensor
Summarize
Through this experiment, I learned the basic use of the BMP388 sensor, and measured the basic data of temperature, air pressure, and altitude.