Good, specific libraries question

Adafruit BME280 is a weather sensor chip.
The library says the I2C address is 0x77.

The chip I’m using has as I2C address of 0x76.

In the Olde Country (Arduino), I just edit the library file.

In PIO, I’ve included the edited library in the local project folder. Serial monitor says I have a bad address.

What is the correct way to do this?

I want to use MY BME280 library, not the Adafruit distribution.

Here, you see it says the address is 0x58, which represents a BME280. That’s rright, but there are several I2C addresses. 0x76 is what comes up when you scan I2C devices, and it’s what the manufacturer says the address is.

I want it to look at 0x76, like it says in the library.

This is in the code:
#define BME280_ADDRESS_ALTERNATE (0x58) // Alternate Address

Do a


in your code (or whatever the name of the define you altering is) then to check and see if the address is being changed.

There is no need to edit the library anyway - the library provides the facility to specify the address if it is different - as shown in the bme280test example (which I was also looking to do just a few days, hence why I remember). Otherwise, you would have to include the library locally in the libs folder, and omit it from your platformio.ini lib_deps since you need to use a modified copy.

    // You can also pass in a Wire library object like &Wire2
    // status = bme.begin(0x76, &Wire2)
1 Like

Hi Monsterthews,

You’re right. This was a Good, specific libraries question.

However, the subject line not was not good or specific.

If I want to find information about Adafruit BME280 in the future, it would be great if the Subject line was better.

For example: “Using the Adafruit BME280 library”


1 Like

This question generalizes to “working with libraries”. Nothing special about this one, outside this particular example of a library detail needing to be changed.

If I put the ‘status’ line in, will that create a second sensor object, and maybe that sensor object will start working?
I’ll try it later.

If it is in the /lib folder, DO NOT add it to lib_deps?


That won’t work. Look at your own screenshot. You are already creating an status object, and you don’t want or need a second one. You want to change from the default, so use the syntax I gave you from the Adafruit example sketch provided with the library!


A better title would have actually been How to change library defaults or How to use modified versions of libraries. “Good, specific libraries question” is a pretty meaningless and unhelpful thread title. You’re likely to be posting a question in a forum - so what is the question about?

That’s too literate. I can’t do that today.

I am writing for posterity, for people like me who haven’t started focusing yet, because we’re not entirely sure what we’re looking at. “Libraries” is going to hit a lot of us exactly the way it’s hit me. This will be easy for that searcher to find, probably searching ‘libraries’ first, and there is a lot of helpful information in the thread…

or ‘How do I use modified versions of libraries?’ would also appear in that search, and be descriptive of the question being asked in the thread. Plus the content of the post is searched also, not just the title! After all, I sure it would be much better if we had threads titled ‘good, vague compiler question’ and ‘bad, unclear class question’ … instead of ‘Compiler complains about loop undefined’ or ‘declaring class results in x error’. Just a thought. :open_mouth:

“Modified” as a qualifier for “libraries” isn’t obvious. It could as well be ‘minty’ libraries.

That argument will be valid the day there are flavoured libraries in programming. :stuck_out_tongue:

They’re doing that now.