BME280 Sensor not working

Why do u need the address when connecting it to SPI?

OT: Is there a (easy) way to use existing SPI-pins as I2C?

See page 11, 30, 38
https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280_DS001-11.pdf
In SPI mode, there is a discrete slave select line to select the part that will respond, vs an address in I2C mode that the part must watch for and respond to.

If multiple parts are to be used, then pin 5, SDO, can be used as a chip select in I2C mode. Drive each devices SDO high with a unique signal. Drive SDO Low to one device and access it at address 76 - the other will be looking for address 77 and will not respond.
The SDOs can be from a shift register if you are short on pins.
Tho, if you had that many devices and chip select pins, I don't know why you wouldn't use the much faster SPI (up to 8 MHz) vs the slower I2C (400 KHz).

Usually these sensors take time for a measurement so faster SPI is useless.
If we talk about displays or ADCs you're absolutely right, SPI is much better.

s-h-a-w-n:
Changing #define BME280_ADDRESS (0x77) for #define BME280_ADDRESS (0x76) in the library's Adafruit_BME280.h solved the problem.

Thank you. Solved my problem :wink:

Reading the documentation (I did it very late!!!!) it seems that you can use bme.begin(0x77) instead of changing the library as I did before.
I should have read the F.... manual!!!

CrossRoads:
Tho, if you had that many devices and chip select pins, I don't know why you wouldn't use the much faster SPI (up to 8 MHz) vs the slower I2C (400 KHz).

I2C: two pins for up to 128 devices. More than fast enough for the few bytes that you read from a sensor.
SPI: three pins for the bus plus one SS pin for each device. Makes you run out of pins fast.

For me, it's SPI for the MicroSD and I2C for just about everything else.

If you want to use more sensors, if all share the same address, may be difficult.

On the ESP8266 I'd just open a second I2C bus for such a situation, if it ever happens. Don't know how well the ATmega handles that. It just takes two extra pins, still a easy win over SPI in pin count: four BME280 sensors take seven pins for SPI, or four pins with two I2C buses. Well, I'm sure you can come up with a situation where it happens.

zoomx:
Check the address with an I2C scanner. My bme280 is on 76 and not 77 as in the Adafruit library.

after spending many hours changing esp, trying different ports I found that this was the problem, thanks!

When you have problems using an I2C chip the first action is to discover if it works using an I2C scanner taking care that some few chips have an address that is not recognized by the scanner because is longer that expected, 10 bits instead of 8, if I remember.

I2C standard address length is 7 bits.

10 bits gets tricky as it's more than a byte.

It is a new addressing
https://www.i2c-bus.org/addressing/10-bit-addressing/

Guys,

Hope you don't mind asking the same question again.

I use this BME280, but when I try to run the same bme280test sketch as mentioned above the serial monitor doesn't give any readings.

Only message on serial monitor: BME280 test

On the I2C_scanner: I2C Scanner
Scanning ......

I use a stock Arduino Uno and the BME280 is connected I2C through pins A4 and A5 for SDA and SCL.

Best regards,
Mischa

If you don't see it show up on the I2C scanner, check wiring, make sure it's all connected properly.
If still nothing, take another - preferably known good - sensor, see if that one works. That confirms whether your wiring and so is correct, and that the other sensor is probably defective.
If you also don't see the known good one, start working on your wiring.

Well, the wiring is not that hard. 5V and GND from the Arduino board, Pin A5 to SCL, Pin A4 to SDA and 2 pullups from +5V to SDA and SCL.

I already tried another BPE280, but it "performs" the same (does nothing).

Yes, 5V is correct as the breakout board has an internal voltage regulator.

Regards,
Mischa

As it has on module voltage regulator has it also got on module pullup resistors on the SCL/SDA lines?
Try without your pullups.

The BME280 is a 3.3V device and pulling the SCL/SDA lines up to 5V is not good unless the module also does voltage level shifting of these line as well. If it does not then you may have damaged the modules.

Hi Guys,

I got the same sensor as Mischa72, however I see I2C adress 0x76 in the I2C scanner. I changed my Adafruit_BMP280.h the I2C adress from 0x77 to 0x76..... But it still doesn't want to find the sensor....
Do I have to reload the library or????

I changed it with a text editor, I am working on OSX 10.13.2 and I use Arduino 1.8.5 editor.

Thanx in advance!

Koen.

Does it show up in the I2C scanner? That will tell you the actual address.

Koen_P_Belgium:
I changed my Adafruit_BMP280.h the I2C adress from 0x77 to 0x76..... But it still doesn't want to find the sensor....

You don't need to do so, just use bme.begin(0x76).

Unfortunately when I use an I2C scanner sketch I find the sensors ever. I have the same board and the address is 0x77.

I've tried again with adding bme.begin(0x76); in void setup, but still the same result, it displays "could not find a valid bmp280 sensor, check wiring!" in the serial monitor

This is the result from I2C Scanner, the 0x20 is the LCD, and there is the 0x76 from bmp280...
Do I have a faulty breakout board?