Photon + BME280 breakout board + SparkfunBME280 library -> connected using I2C. This combination all working fine until code modified and the BME280::reset() function added to the beginning of Setup code. Then it all went pear shaped with rubbish output on reboot, unable to reconfigure as the BME280 is now not visible to an I2C scan which reports ‘no I2C device found’ - Any suggestions ?
@Terrex, the Sparkfun library code already call the reset function as part of
begin(). The comments for
reset() also state clearly that you need to call
begin() after. I would suggest removing your call to reset(), remove power from the sensor, flash the updated code and try again.
Hi peekay123, already tried this but unfortunately once reset() has been called the device looses its I2C address so a call to begin() does nothing. We suspect the device is returning to a default SPI mode when it resets its parameters to the power up reset status, no clues on the Bosch website.
@Terrex, since the
begin() function calls
reset(), I doubt that this is the case. If you look at the schematics (assuming this is the correct board), I2C/SPI mode is set by pcb trace jumpers on the board, not by software. Make sure your hardware configuration is not “fighting” the board pullup on CS* and that all jumpers are intact, especially J3.
We will check the source code, if what you stated about reset() being called within begin() this sounds like it would set up a circular path and lock the device. As stated previously we have reblown the same equipment with no hardware changes but the output is now rubbish and the I2C scan reports no device so it looks like the reset() has trashed some internal settings in some way. We agree that any SPI settings appear to only be hardware selectable hence only the four pins of the I2C are connected on the breakout board.
@Terrex, if you have an arduino board handy, try running the I2C scanner with the BME280 to see if it can be found.
No Arduino board but we have another Photon with I2Cscan code on board, we also have second BME280 breakout. The suspect board that reset() was run on reports no I2C device whereas the second board is correctly detected as 0x77. Both boards are in their default condition with no links changed. The single line of code that is the BME280::reset() function checks out with the Bosch documentation, however, they do not provide any detail of what the function does other than resetting to ‘power up reset’ values.
@Terrex, make sure the CS pin on the board is truly being pulled HIGH and is neither floating or connected to GND or pulled LOW. The reset() call follow the same initialization as a power-on reset:
The “reset” register contains the soft reset word reset[7:0]. If the value 0xB6 is written to the register, the device is reset using the complete power-on-reset procedure.
Rereading the Sparkfun library, I now realize that reset() is NOT called in begin(). It is Adafruit that does the call in their begin() function. The Sparkfun examples call reset() instead.
I cannot find any reason that the BME280 would not correctly reset to I2C mode when power is removed unless CS is being held low or the device was damaged coincidentally (over voltage, short, etc).
The CS is held high by the 4k resistor on the breakout board, there is no wire connection to anything external. Looks like we will have to connect up with SPI and investigate as without it responding to 0x77 then I2C is useless.