Sunday, March 8, 2020

BMP280 I2C Code


Objective: 

  • Demo a temperature and pressure reading from BMP280 with Arduino.


Connection:
        Arduino -- BMP280
5V (or 3.3V) -- Vcc
            GND -- GND
                A5 -- SCL
                A4 -- SDA

Note: 
    BMP280 work with 5V and 3.3V.  This BMP come with Vcc, GND, SCL, SDA, CSB and SDD.  Only the first four been connected in this project.


Arduino Code:
#include <Adafruit_BMP280.h>   // include Adafruit library for BMP280 sensor
Adafruit_BMP280 bmp; // I2C

void setup() {
  Serial.begin(115200); delay(100);
  bmp.begin(0x76); delay(100);
}

void loop() {
  Serial.println(bmp.readTemperature());delay(100);
  Serial.println(bmp.readPressure());delay(100);
  Serial.println(bmp.readAltitude(1013.25));delay(100);  //SEALEVELPRESSURE_HPA = 1013.25
}

No comments:

Post a Comment