BMP280_SPI_Normal.ino 1.6 KB

1234567891011121314151617181920212223242526272829303132
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // BMP280_DEV - SPI Communications, Default Configuration, Normal 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. bmp280.setTimeStandby(TIME_STANDBY_2000MS); // Set the standby time to 2 seconds
  15. bmp280.startNormalConversion(); // Start BMP280 continuous conversion in NORMAL_MODE
  16. }
  17. void loop()
  18. {
  19. if (bmp280.getMeasurements(temperature, pressure, altitude)) // Check if the measurement is complete
  20. {
  21. Serial.print(temperature); // Display the results
  22. Serial.print(F("*C "));
  23. Serial.print(pressure);
  24. Serial.print(F("hPa "));
  25. Serial.print(altitude);
  26. Serial.println(F("m"));
  27. }
  28. }