Go Down

Topic: Request help with BMP-280 (Read 1 time) previous topic - next topic


Help with BMP-280 Sensor

I am unable to get past the "Could not find a valid BMP280 sensor, check wiring!" condition in the Adafruit BMP-280 library.

I recently ordered a BMP-280 sensor from "Funny DIY Expert" via Amazon.  The sensor is labeled GY-B11 280 and has 6 pins:
SCL (clock?)

This is not the Adafruit version of the chip with a built in logic level converter, so I am using a logic level converter to communicate with my controler.  I am using clones of the Arduino Nano and Arduino Mega (I have attempted with each board).  I have attempted the example sketch on each board with both the I2C and SPI wiring configurations. My desired end state is to use the BMP-280 with the Nano and SPI protocol.  Also, the datasheet I can finde at https://www.adafruit.com/datasheets/BST-BMP280-DS001-11.pdf sudgests that there should be 7 pins, witht he 7th being VDDIO (as near as I can tell, the Adafruit version also has 7 pins, but the 7th pin is a 3.3V in for the on-board logic level shifter).

After receiving the "check wiring" message, I verified the communication path from the Nano to the BMP-280 with a fluke.  The 5V signal passes correctly through the logic level converter resulting in a 3.3V signal at the correct pin of the BMP-280.

I suspected I may have a problem with my Arduino libraries because I also attempted to use this code from http://www.instructables.com/id/How-to-Use-the-Adafruit-BMP280-Sensor-Arduino-Tuto/step3/The-code/

Code: [Select]

#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(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

float pressure;
float temperature;
int altimeter;

void setup() {
 Serial.println("Adafruit BMP280 test:");
void loop() {
pressure = bmp.readPressure();
temperature = bmp.readTemperature();
 altimeter = bmp.readAltitude (1050.35);
 Serial.print(F("Pressure: "));
    Serial.print(" Pa");
    Serial.print(("Temp: "));
    Serial.print(" oC");
    Serial.print("Altimeter: ");
    Serial.print(altimeter); // this should be adjusted to your local forcase
    Serial.println(" m");
    delay(5000); //Update every 5 sec

When I attempt to upload the code, I get an error message reading, "exit status 1
'bmp' was not declared in this scope." in reference to the line:
pressure = bmp.readPressure();

If I change all "bmp." entries to "bme." entries (as indicated by the line:
Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);) I can upload the code.  The same is true if I change:
Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);
but the resulting output of T=0 P=0 and a nonsensical altitude indicate that I am not receiving data from the BMP-280.

These indications along with the fact that the lines:
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
pressure = bmp.readPressure();
altimeter = bmp.readAltitude (1050.35);
do not follow the standard font color code in the IDE (all are only black text vice the expected red), lead me to think I am having a problem with the libraries and not the BMP-280 itself.  I have completely removed all Arduino related files and programs from my computer and re-installed from the source to ensure that they are properly located and not corrupted, but I still have the same problems.
I do not yet know enough about these projects to attempt to re-create specific commands from the associated libraries, so this is about all the troubleshooting I can think to do.  Any recommendations on resolving this issue would be greatly appreciated.  If you suspect that my BMP-280 is not functioning properly, please let me know how you diagnosed this problem so I can use the technique in the future and justify a return of the chip.

Thank you for your help,



Its an I2C device, Not SPI.
http://www.uk-pcb.co.uk - UK Based PCB Fab & Assembly Company
Design & Assembly work undertaken - Arduino repairs & testing - PM for details. Arduino & C# PC programming.


If this device is only I2C, why do the examples and technical documentation use the SPI protocol?


Because Adafruit have configured it to SPI!

I spent 30 seconds on google to find the information.
http://www.uk-pcb.co.uk - UK Based PCB Fab & Assembly Company
Design & Assembly work undertaken - Arduino repairs & testing - PM for details. Arduino & C# PC programming.


.. and: the device is a BMP-280 which measures temperature and humidity.
The BME280 is a different device which never works with the BMP280 library (in addition the BME280 measures pressure).

Wire your BMP280 as I2C device and run the I2C-address guesser first to identify the I2C address, which might be either 0x76 (or 0x77).

Have a look at this example, if your device denies to work with the Adafruit example:
Before you ask:
Did you really read and understand How to use this forum ?
Do you have already some solution or is a part of the problem sitting in front of the screen?  :)


The sensor itself has both interfaces I2C and SPI:


so it depends which kind of breakout board you have. If you see only SCL and SDA pins, you can use only I2C.


Consider using I2C and ignore the SPI pins (CSB and SD0).

#include <Adafruit_BMP280.h>        
Adafruit_BMP280 bme;

In setup:
if (!bme.begin())
     {(..... "BMP280 failed!");}
else {..... "BME280 success!");}

In your function:
void ...()                          
   double T, P;
   T = bme.readTemperature();
   P = bme.readPressure() / 100.0;          //  P/100 for hPa (mb)

Works for me!           

Go Up