#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <LiquidCrystal.h>
Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
LiquidCrystal lcd(9, 8, 5, 4, 3, 2);
void setup() { lcd.begin(16,2); Serial.begin(9600); Serial.println(F("BMP280 test")); lcd.print("Welcome to "); lcd.setCursor(0,1); lcd.print("CIRCUIT DIGEST"); delay(1000); lcd.clear(); if (!bmp.begin()) { Serial.println(F("Could not find a valid BMP280 sensor, check 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"); lcd.setCursor(0,0); lcd.print("Temp= "); lcd.print(bmp.readTemperature());
Serial.print(F("Pressure = ")); Serial.print(bmp.readPressure()); Serial.println(" Pa"); lcd.setCursor(0,1); lcd.print("Press= "); lcd.print(bmp.readPressure()); Serial.print(F("Approx altitude = ")); Serial.print(bmp.readAltitude(1018)); /* Adjusted to local forecast! */ Serial.println(" m"); Serial.println(); delay(2000);
}