BMP280 Init Failed

Hello, i am pretty new to Arduino, and i wanted to try making an Altimeter using a BMP280 and an Oled screen, following this tutorial: https://www.instructables.com/Standalone-Arduino-Altimeter/
Instead of a Nano i used an Uno, and that part seems to work.
The problem is that when the program gets loaded and starts, the bmp initialization fails.
I've tried different BMP280 and they all give the same error.

Here is the code that i am currently using:

#include <BMP280.h>
#include <Wire.h>
#include <U8glib.h>

#define P0 1021.97  //1013.25 
BMP280 bmp;

// OLED Type
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);

char sT[20];
char sP[9];
char sA[9];
char sA_MIN[9];
char sA_MAX[9];
double A_MIN = 0;
double A_MAX = 0;

void draw(double T, double P, double A) {
  u8g.setFont(u8g_font_unifont);

  dtostrf(T, 4, 2, sT);
  dtostrf(P, 4, 2, sP);
  dtostrf(A, 4, 2, sA);

  u8g.drawStr( 5, 10, "Temp: ");
  u8g.drawStr( 5, 30, "Bar : ");
  u8g.drawStr( 5, 50, "Alt : ");
  u8g.drawStr( 50, 10, sT);
  u8g.drawStr( 50, 30, sP);
  u8g.drawStr( 50, 50, sA);
}

void draw2(double A_MIN, double A_MAX) {
  u8g.setFont(u8g_font_unifont);

  dtostrf(A_MIN, 4, 2, sA_MIN);
  dtostrf(A_MAX, 4, 2, sA_MAX);
  u8g.drawStr( 5, 20, "A Min: ");
  u8g.drawStr( 60, 20, sA_MIN);
  u8g.drawStr( 5, 45, "A Max: ");
  u8g.drawStr( 60, 45, sA_MAX);
}

void setup() {
  Serial.begin(9600);
  if (!bmp.begin()) {
    Serial.println("BMP init failed!");
    while (1);
  }
  else Serial.println("BMP init success!");

  bmp.setOversampling(4);

  u8g.setColorIndex(1);
  u8g.setFont(u8g_font_unifont);
}

void loop(void) {
  double T, P;
  char result = bmp.startMeasurment();

  if (result != 0) {
    delay(result);
    result = bmp.getTemperatureAndPressure(T, P);

    if (result != 0) {
      double A = bmp.altitude(P, P0);

      if ( A > A_MAX) {
        A_MAX = A;
      }

      if ( A < A_MIN || A_MIN == 0) {
        A_MIN = A;
      }

      //      Serial.print("T = \t"); Serial.print(T, 2); Serial.print(" degC\t");
      //      Serial.print("P = \t"); Serial.print(P, 2); Serial.print(" mBar\t");
      //      Serial.print("A = \t"); Serial.print(A, 2); Serial.println(" m");

      u8g.firstPage();
      do {
        draw(T, P, A);
      } while ( u8g.nextPage() );
      u8g.firstPage();
      delay(1000);

      do {
        draw2(A_MIN, A_MAX);
      } while ( u8g.nextPage() );
      u8g.firstPage();
      delay(1000);
      
    }
    else {
      Serial.println("Error.");
    }
  }
  else {
    Serial.println("Error.");
  }

  delay(100);

}

I amp pretty sure that i included all the needed libraries.

Thanks in advance!
Riccardo

First connect the sensor as described in the various tutorials and run just the I2C Address Scanner program to verify communications.

Then, start with an example from one of the BMP280 libraries, and verify that the sensor works as expected with the serial monitor before adding other displays and any other options.

1 Like

Ok, i tried connecting the sensor in the same way that the tutorials show and run the i2c address scanner, but it just doesn't find the sensor.
Why could that be?

Could be the wiring. Please post a wiring diagram (hand drawn is fine) and a photo of your setup. Did you cleanly solder header pins to the module?

Also post a link to product page for the exact BMP280 module that you have.

Forum members very rarely recommend Instructables, as many of them are posted by people who have little to no idea what they are doing.



I'm very sorry for the quality of both, but i am a complete amateur and don't know how to draw a wire diagram.

I also have another question, which could be very stupid, does the BMP280 need to be soldered in order for it to function correctly?

The drawing is fine and the connections appear to be correct.

Definitely. That is why I asked about soldering.

Adafruit has a good soldering guide.

For soldering male header pins to the BMP280, this guide is helpful.

If you you solder the wires or not, use shorter wires for the I2C. I2C was made for not-long traces.

The HW-611 board is 3.3V only. it has no 3.3V regulator, nor level shifting. Hooking it up to 5V has quite likely cooked its goose.

The header pins do need to be soldered to the board.
The instructable shows 6 wires to the nano, you are only showing 4 connections.

I had the same issue, - "Could not find a valid BME280 sensor, check wiring, address, sensor ID!"
and my page here decribes in some detail how I resolved it.

Thanks for everything guys, i figured it out and understood that the problem was the soldering.
I now have one last question, what voltage do i need to apply?
Because I've seen different people using 5V and others using 3.3V, considering i also need to connect an Oled screen, what's the best option?

As pointed out above, it appears to be a 3.3V only module, and is probably dead. That is why people are asked to post links to the product page.

You need to power it with 3.3V, and use logic level shifters with a 5V Arduino.

For the Arduino Uno, it is best to use sensors that are designed to work on 5V, with 5V logic, and buy them from reputable distributors, like Adafruit, Sparkfun, Conrad, etc. as Amazon/eBay sellers often make misleading claims.

Capture

Capture

This is where i bought them: https://www.amazon.it/dp/B0BN1NXG4D?ref=ppx_pop_mob_ap_share

I was very tight with time so i chose the quickest solution, another time I'll try to be more prudent with the supplier.
Another problem was the fact that i live in Italy, so the options for buying parts are very limited.

From the product page:

Tips:
The I2C address was 0x76 and not the 0x77 default used by most other sensors.
You have to manually change the address inside the Adafruit_BMP280.h to: #define BMP280_ADDRESS (0x76),Then it starts to work.
Package Included:
5 * GY-BMP280 BMP280 Atmospheric Pressure Sensor Modules 3.3V

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.