SparkFun BMP581 sensor is not working with an Adafruit with a TCA9548a multiplexer

I am trying to get a SparkFun BMP581 sensor to work with an Adafruit TCA9548a multiplexer. The BMP581 works when it is not connected to the TCA. The inverse happens when the they are connected.

Code w/o TCA9548:

#include "SparkFun_BMP581_Arduino_Library.h"
#include <Wire.h>

BMP581 pressureSensor; // Create a new sensor object

uint8_t i2cAddress = BMP581_I2C_ADDRESS_DEFAULT;

void setup() { Wire.begin(); // Start I2C bus delay(500); // wait Serial.begin(115200); // Start Serial connection

Serial.println("BMP581 Begin!");

/* Initialize the sensor */ while(pressureSensor.beginI2C(i2cAddress) != BMP5_OK) { // Not connected --> inform user Serial.println("Error: BMP581 not connected - check wiring and I2C address!");

// Wait
delay(1000);
} Serial.println("BMP581 Connected!"); }

void loop() { // Get measurements from the sensor bmp5_sensor_data data = {0}; int8_t err = pressureSensor.getSensorData(&data);

// Check whether data was acquired successfully if(err == BMP5_OK) { Serial.print("Temperature (C): "); Serial.print(data.temperature);

Serial.print("\nPressure (Pa): ");
Serial.println(data.pressure);
} else{ Serial.print("Error getting data from sensor! Error Code: "); Serial.println(err); } delay(1000); }

Code w/ TCA9548:

#include <Wire.h>
#include "SparkFun_BMP581_Arduino_Library.h"

BMP581 BMP;

#define TCA_Addr 0x70 uint8_t BMP_Addr = BMP581_I2C_ADDRESS_DEFAULT;

void tcaselect(uint8_t i) { if (i > 7) return;

Wire.beginTransmission(TCA_Addr); Wire.write(1 << i); Wire.endTransmission(); }

void setup() { while (!Serial); delay(1000); Wire.begin(); Serial.begin(115200);

tcaselect(5); init_bmp(); }

void loop() { bmp581(); }

void init_bmp() { tcaselect(5); while (BMP.beginI2C(TCA_Addr) != BMP5_OK) { Serial.println("Error: BMP581 not connected - check wiring and I2C address!"); delay(1000); } Serial.println("BMP581 Connected!"); }

void bmp581() { tcaselect(5); bmp5_sensor_data data = {0}; int8_t err = BMP.getSensorData(&data);

if (err == BMP5_OK) { Serial.print("Temperature (C): "); Serial.println(data.temperature);

Serial.print("\nPressure (Pa): ");
Serial.println(data.pressure);
} else { Serial.print("Error getting data from sensor! Error Code: "); Serial.println(err); } delay(1000); }

I don't have Fritzing so please bare with me and my circuit diagram I drew in paint.

Thank you

@oxygen02
Installation and Troubleshooting is for Problems with the Arduino IDE itself NOT your project. It says so in the description of the section.

Therefore I have moved your post here. Please be more careful where you post in future.

You may want to read this before you proceed:-
how to get the best out of this forum

Great, please keep it that way. Schematics like that are much better than Fritzing.
The details are missing though, you show three chips in your diagram, but do you mean the chips or do you mean a board containing those chips? If the latter pleas post a link to who's boards these are.

Apologies, I will remember that.

There are 4 chips. I linked the BMP and TCA. I will link the PCA here .

Thanks.

Why are you even using a multiplexer?
All you need is to get an I2C level shifter between the Uno and the pressure sensor.

I think you are miss understanding what an I2C multiplexer is for. It is for when you have two or more devices that you want to use on an I2C buss that have the same address.

This is not the case with the two chips you want to put on the bus. Check the data sheets and see what address they have. One device has an address that you can change with a resistor so even if the default addresses clashed, you could always move them.

What you have to be aware of is if the two devices need different power supplies then you need a bidirectional level shifter to connect one of the devices.

1 Like

Oh I didn't even think of that. I can just connect the BMP to SDA/SCL of the Arduino and not branch it from a multiplexer.

Thank you

I have one.

1 Like

Update: Not using the multiplexer with the BMP worked.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.