Can a SPI display and I2C sensor be used together or is it best to use SPI for everything? I am using a SPI LCD Display and want to incorporate a BME280 sensor into my code. The BME280 can be used SPI or I2C.
Thanks,
Kevin
Can a SPI display and I2C sensor be used together or is it best to use SPI for everything? I am using a SPI LCD Display and want to incorporate a BME280 sensor into my code. The BME280 can be used SPI or I2C.
Thanks,
Kevin
There is no reason why 12C and SPI can't be used together. In fact I have used SPI SRAM and an I2C display together with no trouble.
Thanks for the reply. Just wanted to make sure I wouldn't run into problems.
Kevin
What are the voltages ? Is everything 3.3V or everything 5V ? (the Arduino board, the display, the sensors, and so on). If there is a mismatch then you can run into problems.
SPI = SCK-MISO-MOSI-Gnd,
I2C is SCL-SDA-Gnd.
The BME280 appears to be a 3.3V interface part.
Turn off the internal pullup resistors (after Begin Wire.h in your code add digitalWrite (SCL, LOW), and digitalWrite (SDA, LOW); where SCL/SDA are pins 18/19 on an Uno, and 20/21 I think on the Mega)
and use external pullups to 3.3V or 5V as needed for SCL & SDA. On the Mega you'll also need to remove of the resistor networks that pulls up SCL & SDA to 5V.
Then you can have 5V SPI and 3.3V I2C.