ENG-CANSAT-BMP280
Install the Library
Manual Installation
The Adafruit's BMP280 is provided with a library available on GitHub.
You can download and install the library manually by dowloading it from the BMP280 Repository.
Note that BMP280 library rely on the Adafruit_Sensor library which declare an unified data structure to store data across all the Adafruit's Sensors Libraries.
Easier Installation
You can also use the "Library Manager" to ease the installation of the BMP280 library.
From the "Sketch" menu, select the sub-menu "Include library" --> "Library Manager" like shown on the picture here under.
In the library manager, key-in the value "BMP280" in the search box. Then click on the install button in the front of the Adafruit BMP280 Library by Adafruit.
Great, the BMP280 library is now installed!
You must also install the unified sensor library! If not yet done, proceed the installation of the library as described here under. |
From "Library Manager", search for the "Adafruit Unified Sensor" like shown on the picture here under.
Then install it.
Wiring the sensor
xxx
Testing the sensor
The sensor can be easily tested with the Adafruit Example code (installed with the library).
The sample code is available through the File menu under the sub-menu Example --> Adafruit BMP280 Library --> BMP280test.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bme; // I2C
void setup() {
Serial.begin(9600);
Serial.println(F("BMP280 test"));
if (!bme.begin()) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
}
void loop() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure());
Serial.println(" Pa");
Serial.print("Approx altitude = ");
// 1013.25 is the pressure at sea level. It should be ajusted
// with your local forecast for a corect evaluation of altitude
Serial.print(bme.readAltitude(1013.25));
Serial.println(" m");
Serial.println();
delay(2000);
}
Written by Meurisse D. from MC Hobby - License: CC-SA-BY.