BMP280の使い方

BMP280の使い方

仕様

入力電圧:DC3.3V
測定気圧:300~1100hPa(±1hPa)
測定気温:-40~85℃(±1℃)
更新間隔:157[fps](max)

商品


https://amzn.to/41nKF1R

プログラム

Adafruit BMP280のライブラリをインクルードしてください

#include <Wire.h>
#include <Adafruit_BMP280.h>
#define BMP280_ADDRESS 0x76
Adafruit_BMP280 bmp;  // use I2C interface

void setup() {
  Serial.begin(9600);
  while (!Serial) delay(100);
  Serial.println(F("BMP280 test"));
  unsigned status;
  status = bmp.begin(BMP280_ADDRESS);

  if (!status) {
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "
                     "try a different address!"));
    while (1) delay(10);  // Stop code execution if the sensor is not found.
  }

  /* 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() {
  // Read and print temperature in degrees Celsius.
  Serial.print(F("Temperature = "));
  Serial.print(bmp.readTemperature());
  Serial.println(" °C");

  //Read and print atmospheric pressure in hectopascals (hPa).
  Serial.print(F("Pressure = "));
  Serial.print(bmp.readPressure());
  Serial.println(" hPa");

  //Read and print approximate altitude based on standard pressure (1013.25 hPa).
  Serial.print(F("Approx altitude = "));
  Serial.print(bmp.readAltitude(1013.25));
  Serial.println(" m");

  Serial.println();  // Print a blank line to separate readings.
  delay(2000);       // Wait for 2 seconds before taking the next set of readings.
}

参考

レッスン20: 温度、湿度、気圧センサー (BMP280) — SunFounder Universal Maker Sensor Kit ドキュメント

Seeed Studio XIAO ESP32C3でBLE ③ I2CでセンサBMP280をつなぐ | Arduinoクックブック
IoT spresense Arduino IDE LED Lチカ

気圧センサー[BMP180]を使う~①シリアルモニタ表示~
独BOSCH社から気圧センサーがシリーズでリリースされてますが、その中で比較的性能が良くて安価な[BMP180…

タイトルとURLをコピーしました