Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: BMP280 pressure sensor

  1. #1

    BMP280 pressure sensor

    I am using the BMP280 not BME280 and the drivers from adafruit.

    this is the monitor output:
    Temperature = 0.00 *C
    Pressure = 0.00 Pa
    Approx altitude = 44330.00 m

    here is the code, I went and used the "Sketch / include lib/ manage lib and it seemed to find the BMP280 and Adafruit_sensor lib.

    this is the area in question:
    #include <Wire.h> //***********Wire is RED text[/B]
    #include <SPI.h> //***********SPI is RED text
    #include <Adafruit_Sensor.h> //***********Adafruit_Sensor is normal text
    #include <Adafruit_BMP280.h> //***********Adafruit_BMP280 is normal text

    does this lib work for the Teency 3.2?
    /************************************************** *************************
    This is a library for the BMP280 humidity, temperature & pressure sensor

    Designed specifically to work with the Adafruit BMEP280 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 andopen-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> //***********Wire is RED text[/B]
    #include <SPI.h> //***********SPI is RED text
    #include <Adafruit_Sensor.h> //***********Adafruit_Sensor is normal text
    #include <Adafruit_BMP280.h> //***********Adafruit_BMP280 is normal text

    #define BMP_SCK 13
    #define BMP_MISO 12
    #define BMP_MOSI 11
    #define BMP_CS 15

    //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);
    // }
    }

    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)); // this should be adjusted to your local forcase
    Serial.println(" m");

    Serial.println();
    delay(2000);
    }

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,080
    sorry but you absolutely need to run begin(), why you comment it out?

  3. #3
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,121
    I use the BME280 sensor and the drivers are very similar. tonton81 is absolutely correct you need the bmp.begin() statement in the loop. Its better to uncomment that whole block - the begin function will test to see if the BMP280 is connected correctly and working correctly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •