BMP280 Humidity, Temperature, and Pressure Sensor for Arduino
This video explains how to use the BMP280 humidity, temperature, and pressure sensor with Arduino.
201-BMP280 temperature and pressure sensor for Arduino
Langue: C++
/*
*
***************************************************************************
This is a library for the BMP280 humidity, temperature & pressure sensor.
Get library from: https://github.com/adafruit/Adafruit_BMP280_Library
This code has been downloaded from Robojax.com.
Watch video instruction of this code: https://youtu.be/InNHrtnZgUQ
Video recorded January 22, 2019 in Ajax, Ontario, Canada
by Ahmad Shamshiri
Designed specifically to work with the Adafruit BMP280 Breakout
----> http://www.adafruit.com/products/2651
These sensors use I2C or SPI to communicate; 2 or 4 pins are required
to interface.
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing products
from Adafruit!
Written by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribution
**************************************************************************
*/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#define BMP_SCK (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS (10)
Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
void setup() {
Serial.begin(9600);
Serial.println(F("BMP280 test"));
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");
Serial.print(F("Pressure = "));
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.print(F("Approx altitude = "));
Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */
Serial.println(" m");
Serial.println();
delay(2000);
}
Ce dont vous pourriez avoir besoin
-
Amazon
-
AmazonAchetez le BMP280 sur Amazon.amzn.to
-
eBayAchetez le BMP280 sur eBayebay.us
-
AliExpressAchetez AHT20+BMP280 sur une carte unique sur AliExpresss.click.aliexpress.com
Ressources et références
-
ExterneBibliothèque BMP280 (de GitHub)github.com
-
ExterneSite web de Bosch pour le BMP280bosch-sensortec.com
Fichiers📁
Fiche technique (pdf)
-
BMP280-datasheet_DS001-11
BMP280-datasheet_DS001-11.pdf1.42 MB -
Fiche technique en anglais du capteur de pression numérique BMP280
BST-BMP280-DS001-11[1].pdf1.42 MB -
Fiche technique BMP280Fiche technique pour le capteur de pression numérique Bosch BMP280. Mesure la pression barométrique et la température avec une haute précision, interfaces I2C et SPI, et une tension d'alimentation de 1,71 à 3,6V.
BMP280-datasheet_DS001-11.pdf1.42 MB