Using the standard BME280 library i ran into a strange issue when trying to use the BME280 from a Mega2560.
Using the stadard library on a Nano the hardware SPI works OK.
Because the BME280 library is using more memory than average i switched to a Mega2560. Just replaced pins 10, 11, 12, 13 to the corresponding 53, 51, 50, 52.
Tried 2 Mega2560 boards. Both just no response at all.
Then switched from hardware SPI to software SPI:
As you mention i started with the Hardware SPI specifiying only CS.
On Nano this worked.
On Mega it did not so i tried to specify the other pins too. After strugeling for a few days i thought lets give the Software SPI a try. Suppricinly this worked
And yes i do the Software SPI on the hardware pins. Just because these pins were allready connected.
Now you mention, i now tried the Software SPI on the Mega using 10, 11, 12, 13. Strangly this does NOT work
At least i have a working config now
Using software SPI at pins 10,11,12,13 should work, assuming you have a "R3" version of the Mega board.
Perhaps something is not reliable yet. Can you show how the level shifters are wired ?
The level shifters for the I2C bus make the TTL signals weaker.
Can you start thinking about buying a 3.3V Arduino board ?
Many thanks for the tip: I missed the SS pin (53) must be set as output part.
For level shifters i am using a cheap 4-Channel logic voltage level converter. Not sure if you see this as a I2C one. Now it is working i will try to use a resitor only level shifting.
Again many thanks,
Hope other can benefit from this. I spend a lot of time.
To compleet the interface from a 5v arduino to the 3.3v BME280.
I needed 3 level shifters to get it working:
The CLK signal did need an active one: 1 fet and 2 resistors.
For the CSB and MOSI a pasive of 2 resitors worked: 1k8 / 3k3 (18k / 33k did not work)
For the MISO no level shifters is needed.