BME280 library compiler error


I got today my new Photon and tried to connect it to a Bosch BME280. For that I wired SCL to D1 and SDA to D0. Then I wrote a small test app:

    // This #include statement was automatically added by the Particle IDE.
    #include "Adafruit_Sensor/Adafruit_Sensor.h"
    // This #include statement was automatically added by the Particle IDE.
    #include "Adafruit_BME280/Adafruit_BME280.h"
    #define SEALEVELPRESSURE_HPA (1013.25)
    Adafruit_BME280 bme; 
    void setup() {
    void loop() {
        Particle.publish("Temperature", bme.readTemperature());
        Particle.publish("Pressure", bme.readPressure() / 100.0F);
        Particle.publish("Altitude", bme.readAltitude(SEALEVELPRESSURE_HPA));
        Particle.publish("Humidity", bme.readHumidity());

The compiling went fine and the app started on my Photon. In the dashboard I could see that there were no sensor data incoming. So I wanted to change the I2C address from 0x77 to 0x76. For that I had to clone the Adafruit library and change the address in Adafruit_BME280.h. But when I try to compile the app with the custom library I’m getting the following error message:

Adafruit_BME280/Adafruit_BME280.cpp: In member function 'uint32_t Adafruit_BME280::read24(byte)':

Adafruit_BME280/Adafruit_BME280.cpp:247:11: error: 'class SPIClass' has no member named 'beginTransaction'
       SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));

Adafruit_BME280/Adafruit_BME280.cpp:247:67: error: 'SPISettings' was not declared in this scope
       SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));

Adafruit_BME280/Adafruit_BME280.cpp:259:11: error: 'class SPIClass' has no member named 'endTransaction'
       SPI.endTransaction();              // release the SPI bus

make[1]: *** [../build/target/user/platform-6Adafruit_BME280/Adafruit_BME280.o] Error 1
make: *** [user] Error 2

Besides the I2C address I didn’t change anything in my fork. Hopefully somebody can give me a hint what I have done wrong. Thanks in advance!

Are you sure that your BME280 has the address 0x76?
Which breakout board do you use?

I got them from a distributor from China. I checked the I2C ID with a Raspberry and it is indeed 0x76.

Try the CE_BME280 library, it uses the address 0x76

Did you clone this library?

In the Particle world there is no beginTransaction() (yet), so you’d need to use a library that is already ported for your own fork.

In that library beginTransaction() gets replaced with

      // SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));

but not in read24(), so you’d need to do that there too.

Currently Build only features 1.0.3 which doesn’t seem to implement read24() at all, but on GitHub it’s 1.0.4 which introduced that error.


With CE_BME280 it is working now! Thanks!


I cloned that repository which Particle Build offered me as I pushed the button FORK THIS LIBRARY. So yes, I probably not cloned the right. I will this try also. Thanks for the quick response!

1 Like

You are welcome! :wink: