BMP280_SPI_Forced.ino 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. /////////////////////////////////////////////////////////////////////////////////
  2. // BMP280_DEV - SPI Communications, Default Configuration, Forced Conversion
  3. /////////////////////////////////////////////////////////////////////////////////
  4. #include <BMP280_DEV.h> // Include the BMP280_DEV.h library
  5. float temperature, pressure, altitude; // Create the temperature, pressure and altitude variables
  6. BMP280_DEV bmp280(10); // Instantiate (create) a BMP280_DEV object and set-up for SPI operation on digital pin D10
  7. void setup()
  8. {
  9. Serial.begin(115200); // Initialise the serial port
  10. bmp280.begin(); // Default initialisation, place the BMP280 into SLEEP_MODE
  11. //bmp280.setPresOversampling(OVERSAMPLING_X4); // Set the pressure oversampling to X4
  12. //bmp280.setTempOversampling(OVERSAMPLING_X1); // Set the temperature oversampling to X1
  13. //bmp280.setIIRFilter(IIR_FILTER_4); // Set the IIR filter to setting 4
  14. }
  15. void loop()
  16. {
  17. bmp280.startForcedConversion(); // Start BMP280 forced conversion (if we're in SLEEP_MODE)
  18. if (bmp280.getMeasurements(temperature, pressure, altitude)) // Check if the measurement is complete
  19. {
  20. Serial.print(temperature); // Display the results
  21. Serial.print(F("*C "));
  22. Serial.print(pressure);
  23. Serial.print(F("hPa "));
  24. Serial.print(altitude);
  25. Serial.println(F("m"));
  26. }
  27. }