-
-
Save gleguizamon/177f2d58383fd3a35a8bdb8be9b8222d to your computer and use it in GitHub Desktop.
Configuration of BMP280 Arduino Sensor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////////////////////////////////////////////////// | |
// BMP280_DEV - I2C Communications (Alternative Address), Default Configuration, Normal Conversion | |
///////////////////////////////////////////////////////////////////////////////////////////////////// | |
#include <BMP280_DEV.h> // Include the BMP280_DEV.h library | |
float temperature, pressure, altitude; // Create the temperature, pressure and altitude variables | |
BMP280_DEV bmp280; // Instantiate (create) a BMP280_DEV object and set-up for I2C operation | |
void setup() | |
{ | |
Serial.begin(115200); // Initialise the serial port | |
bmp280.begin(BMP280_I2C_ALT_ADDR); // Default initialisation with alternative I2C address (0x76), place the BMP280 into SLEEP_MODE | |
//bmp280.setPresOversampling(OVERSAMPLING_X4); // Set the pressure oversampling to X4 | |
//bmp280.setTempOversampling(OVERSAMPLING_X1); // Set the temperature oversampling to X1 | |
//bmp280.setIIRFilter(IIR_FILTER_4); // Set the IIR filter to setting 4 | |
bmp280.setTimeStandby(TIME_STANDBY_2000MS); // Set the standby time to 2 seconds | |
bmp280.startNormalConversion(); // Start BMP280 continuous conversion in NORMAL_MODE | |
bmp280.setSeaLevelPressure(1019.00f); | |
} | |
void loop() | |
{ | |
if (bmp280.getMeasurements(temperature, pressure, altitude)) // Check if the measurement is complete | |
{ | |
Serial.print(temperature); // Display the results | |
Serial.print(F("*C ")); | |
Serial.print(pressure); | |
Serial.print(F("hPa ")); | |
Serial.print(altitude); | |
Serial.println(F("m")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment