#include <Wire.h>
#include <Adafruit_BMP280.h>

Adafruit_BMP280 bmp;

void setup() {
  Serial1.begin(9600);
  unsigned status;
  status = bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID);
  if (!status) {
    Serial1.println(F("Could not find a valid BMP280 sensor, check wiring or "
                      "try a different address!"));
    Serial1.print("SensorID was: 0x"); Serial1.println(bmp.sensorID(),16);
    Serial1.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
    Serial1.print("   ID of 0x56-0x58 represents a BMP 280,\n");
    Serial1.print("        ID of 0x60 represents a BME 280.\n");
    Serial1.print("        ID of 0x61 represents a BME 680.\n");
    while (1) delay(10);
  }
  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() {
    Serial1.print(F("Temperature = "));
    Serial1.print(bmp.readTemperature());
    Serial1.println(" *C");

    Serial1.print(F("Pressure = "));
    Serial1.print(bmp.readPressure());
    Serial1.println(" Pa");

    Serial1.print(F("Approx altitude = "));
    Serial1.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */
    Serial1.println(" m");

    Serial1.println();
    delay(2000);
}
Loading
pi-pico-w