Help with BMP280

I'm trying to use the library "BMP280_DEV" and trying out the user defined pins for i2c pin. My board is an esp32. But this error shows when trying to upload it on my board:

call of overloaded 'BMP280_DEV(int, int)' is ambiguous

What does the error mean? Am I using the code incorrectly? Any help is appreciated. The code Im trying is one of the built in example of the library:

#include <BMP280_DEV.h>                           // Include the BMP280_DEV.h library

float temperature, pressure, altitude;            // Create the temperature, pressure and altitude variables

BMP280_DEV bmp280(25, 26);                          // Instantiate (create) a BMP280 object and set-up for I2C operation on pins SDA: 25, SCL: 26

void setup() 
{
  Serial.begin(115200);                           // Initialise the serial port
  bmp280.begin();                                 // Default initialisation, place the BMP280 into SLEEP_MODE 
  bmp280.setTimeStandby(TIME_STANDBY_2000MS);     // Set the standby time to 2 seconds
  bmp280.startNormalConversion();                 // Start BMP280 continuous conversion in NORMAL_MODE
}

void loop() 
{
  if (bmp280.getMeasurements(temperature, pressure, altitude))    // Check if the measurement is complete
  {
    Serial.print(temperature);                    // Display the results    
    Serial.print(F("*C   "));
    Serial.print(pressure);    
    Serial.print(F("hPa   "));
    Serial.print(altitude);
    Serial.println(F("m"));  
  }
}

Hi @LuXian

My apologies that you're getting an error with my library. I'll look into it and get back to you later on today.

Hi @LuXian

A quick fix is to go into the library's BMP280_DEV.h file an on line 134 replace this line:

BMP280_DEV(uint8_t cs, uint8_t spiPort, SPIClass& spiClass = SPI1);	// BMP280_DEV object for SPI1 with supplied SPIClass object

with this:

BMP280_DEV(uint8_t cs, uint8_t spiPort, SPIClass& spiClass);	// BMP280_DEV object for SPI1 with supplied SPIClass object

I'll update the BMP280_DEV library with the correction later on today.

Thank you for flagging this up.

Thank you, its working now

Hi @LuXian

Glad to hear that you got it working :smiley:.

By the way, I've updated the BMP280_DEV library on Github. The new version V1.0.20 should soon become available as an update on the Arduino IDE in a few hours time.

1 Like

I'm sorry to bother but it worked for me because I just verified the code on my arduino, but when uploading it on my esp32 and monitoring the results on my serial monitor, the serial monitor shows this error:

12:11:04.152 -> Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
12:11:04.293 -> 
12:11:04.293 -> Core  1 register dump:
12:11:04.293 -> PC      : 0x400d1a60  PS      : 0x00060830  A0      : 0x800d184c  A1      : 0x3ffb2750  
12:11:04.434 -> A2      : 0x00000000  A3      : 0x00000019  A4      : 0x0000001a  A5      : 0xffffffff  
12:11:04.481 -> A6      : 0x00000000  A7      : 0x003fffff  A8      : 0x8008a5d3  A9      : 0x3ffb2710  
12:11:04.576 -> A10     : 0x3ffc19d4  A11     : 0x3ffc19d4  A12     : 0x00000004  A13     : 0x00060a23  
12:11:04.670 -> A14     : 0x00060a23  A15     : 0x00000001  SAR     : 0x00000003  EXCCAUSE: 0x0000001c  
12:11:04.764 -> EXCVADDR: 0x00000130  LBEG    : 0x400861a0  LEND    : 0x400861ab  LCOUNT  : 0xffffffff  
12:11:04.905 -> 
12:11:04.905 -> 
12:11:04.905 -> Backtrace:0x400d1a5d:0x3ffb27500x400d1849:0x3ffb2790 0x400d14bd:0x3ffb27b0 0x400d1515:0x3ffb27d0 0x400d134d:0x3ffb27f0 0x400d46b2:0x3ffb2820 
12:11:04.999 -> 
12:11:04.999 -> 
12:11:04.999 -> 
12:11:04.999 -> 
12:11:04.999 -> ELF file SHA256: 0000000000000000
12:11:05.045 -> 
12:11:05.045 -> Rebooting...

@LuXian Ok, I'll look into it.

Hi @LuXian Just a quick update. I've tracked down the problem. I'll test and update the library tomorrow.

I'll let you know when it's ready.

Hi @LuXian

Ok, I've updated and released BMP280_DEV library version 1.0.21 that solves the issue. It should become available on the Arduino IDE through the library manager shortly.

Sorry about that. I recently updated the library to allow it to access multiple/alternative I2C ports, which all functioned OK, but rather embarrasingly didn't consider the ESP8266/ESP32 with user defined I2C pins.

Im sorry to bother again, i've tested the latest update, the good thing is I can now use the library with the default i2c pins on my esp32 and show the results on serial monitor, but with user defined pins, there's no reading that shows on serial monitor, is there a new way of initializing the user defined pins?

edit: I got it working with the wire.begin function, thanks for fixing the library

Hi @LuXian

Might I ask what user defined pins you're using?

I just updated and retested the BMP280_DEV library (version 1.0.21) with user defined pins on my ESP32 and it's working fine for me.

I'm using pin numbers 14 (A6) on SDA and 32 (A7) on SCL.

Im using pins 25 - sda and 26 - scl. Im using it like this:

#include <Wire.h>
#include <BMP280_DEV.h>                           // Include the BMP280_DEV.h library

float temperature, pressure, altitude;            // Create the temperature, pressure and altitude variables
BMP280_DEV bmp280;                                // Instantiate (create) a BMP280_DEV object and set-up for I2C operation
//BMP280_DEV bmp280(25,26);

void setup() 
{
  Serial.begin(115200);                           // Initialise the serial port
  Wire.begin(25,26);
  bmp280.begin(BMP280_I2C_ALT_ADDR);              // Default initialisation with alternative I2C address (0x76), place the BMP280 into SLEEP_MODE 
  bmp280.setTimeStandby(TIME_STANDBY_2000MS);     // Set the standby time to 2 seconds
  bmp280.startNormalConversion();                 // Start BMP280 continuous conversion in NORMAL_MODE
}

void loop() 
{
  if (bmp280.getMeasurements(temperature, pressure, altitude))    // Check if the measurement is complete
  {
    Serial.print(temperature);                    // Display the results    
    Serial.print(F("*C   "));
    Serial.print(pressure);    
    Serial.print(F("hPa   "));
    Serial.print(altitude);
    Serial.println(F("m"));  
  }
}

Hi @LuXian

It shouldn't be necessary to call on the Wire library, since the BMP280_DEV library calls it itself.

Please could you try this code:

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// BMP280_DEV - ESP32, I2C Communications, Default Configuration, Normal Conversion, User-Defined Pins
//////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <BMP280_DEV.h>                           // Include the BMP280_DEV.h library

float temperature, pressure, altitude;            // Create the temperature, pressure and altitude variables
BMP280_DEV bmp280(25, 26);                        // Instantiate (create) a BMP280 object and set-up for I2C operation on pins SDA: 25, SCL: 26

void setup() 
{
  Serial.begin(115200);                           // Initialise the serial port
  bmp280.begin(BMP280_I2C_ALT_ADDR);              // Default initialisation with alternative I2C address (0x76), place the BMP280 into SLEEP_MODE 
  bmp280.setTimeStandby(TIME_STANDBY_2000MS);     // Set the standby time to 2 seconds
  bmp280.startNormalConversion();                 // Start BMP280 continuous conversion in NORMAL_MODE
}

void loop() 
{
  if (bmp280.getMeasurements(temperature, pressure, altitude))    // Check if the measurement is complete
  {
    Serial.print(temperature);                    // Display the results    
    Serial.print(F("*C   "));
    Serial.print(pressure);    
    Serial.print(F("hPa   "));
    Serial.print(altitude);
    Serial.println(F("m"));  
  }
}

I tried that code but nothing shows up at the serial monitor

Hi @LuXian

I just tested the above code on ESP32 pins 25 (SDA) and 26 (SCL) together with the BMP280 configured for the alternate I2C address (0x76) and it works just fine.

Have you selected the correct I2C address for the barometer: 0x77 standard, 0x76 alternate?

Are you powering the barometer breakout board with 3.3V? The board should be powered with 3.3V.

Hi @MartinL, the bmp280 is powered through 3.3v of the esp32, but like I've said above the

Wire.begin(25,26); - worked with me.

But with this

BMP280_DEV bmp280(25, 26); - it doesn't.

It uploads but nothing shows up at my serial monitor. I might borrow other esp32 to test if there's something wrong with my esp32. Btw the board I'm using is Lilygo TTGO T8 1.7.1

Hi @LuXian

If you don't mind, please could you just check if your using version 1.0.21 of the BMP280_DEV library.

On my Windows PC the library's directory is located here:

C:\Users\Computer\Documents\Arduino\libraries\BMP280_DEV

In the BMP280_DEV directory, just open the library.properties file with Notepad or similar. It should state the version: version=1.0.21.

Hi @MartinL I'm using the latest version 1.0.21

Hi @LuXian

Please could you perhaps post an image of your current set-up and specify which make/model of ESP32 you're currently using?

I ask, because I'm currently unable to reproduce the problem on my set-up: Adafruit Huzzah 32 ESP32 and Adafruit BMP280 breakout. I'm getting barometer back readings using the user-defined I2C pins, but maybe it's something to do with the connections or type of ESP32?

Hi @MartinL Please excuse the garbage quality but this is my current set-up:

I'm currently using Lilygo TTGO T8 1.7.1. The BMP280 I'm using are the chinese clones, I've tested it and it works normally