Instructions

Arduino Nano Sensor Set
Veröffentlicht: 17.10.2018 Copyright by Maker Factory 15
7. DER DRUCK UND TEMPERATURSENSOR
Bitte kopieren sie den folgenden Code vollständig und fügen Sie ihn in Ihr Skript ein.
/***************************************************************************
This is a library for the BMP280 humidity, temperature & pressure sensor
Designed specically to work with the Adafruit BMEP280 Breakout
----> hp://www.adafruit.com/products/2651
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface.
Adafruit invests me and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!
Wrien by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribuon
***************************************************************************/
#include
#include
#include
#include
#dene BMP_SCK 13
#dene BMP_MISO 12
#dene BMP_MOSI 11
#dene 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 nd a valid BMP280 sensor, check wiring!"));
while (1);
}
}
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 altude = "));
Serial.print(bmp.readAltude(1013.25)); // this should be adjusted to your local forcase
Serial.println(" m");
Serial.println();
delay(2000);
}