June 06, 2020

Barometer (BMP 280) Interface with Arduino

The BMP280 is an absolute barometric pressure sensor by BOSCH. Its small dimensions and its low power consumption allow for the implementation in battery-powered devices as mobile phones, GPS modules, or watches. We can interface this sensor with Arduino using SPI or I2C communication.

Items required:
  • Arduino Nano
  • BMP280
  • Jumper Wire
Circuit Diagram:
Video Example:
                Coming Soon

Software:
/*
# This sample codes is for testing the BMP280.
# Editor : ProjectHub
# Date : 2020.06.06
# Ver : 1.0
# Product: pH meter
*/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
void setup() {
Serial.begin(9600);
Serial.println(F("BMP280 test"));
if (!bmp.begin()) {
Serial.println(F("Could not find a valid BMP280 sensor, check the wiring!"));
while (1);
}
/* Default settings from datasheet. */
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
Adafruit_BMP280::FILTER_X16, /* Filtering. */
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
}
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)); /* Adjusted to local forecast! */
Serial.println(" m");
Serial.println();
delay(2000);
}

Updated Library:

No comments:

Post a Comment