Wiring #

Arduino pin: | BMP280 pin: |
---|---|
+5V | +5V (VCC) |
GND | GND |
A5 | SCL Serial Clock (line) |
A4 | SCA Serial Clock (data) |
Script adafruit BMP280 bibliotheek #
Download Github: https://github.com/adafruit/Adafruit_BMP280_Library
Het adres van deze module kan gewijzigd worden tussen 0x76 en 0x77 door de SD0 lijn op GND of +3.3v te zetten, te controleren met een I2C scanner:
Arduino I2C scanner output
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --
Het adres kan je aanpassen in het bestand : Adafruit_BMP280.h
Pas deze regel aan, van:
#define BMP280_ADDRESS (0x77)
naar:
#define BMP280_ADDRESS (0x76)
Sluit de BMP module aan zoals hierboven aangegeven.
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
Adafruit_BMP280 bme; // I2C
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
void setup() {
Serial.begin(9600);
Serial.println(F("BMP280 test"));
if (!bme.begin()) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while (1);
}
}
void loop() {
Serial.print(F("Temperature = "));
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(bme.readPressure());
Serial.println(" Pa");
Serial.print(F("Approx altitude = "));
Serial.print(bme.readAltitude(1013.25)); // this should be adjusted to your local forcase
Serial.println(" m");
Serial.println();
delay(2000);
}
Output:
