DPS310 pressure sensors with Multiplexer

Hello,

I am trying to connect three DPS310 pressure sensors using I2C. I read online that I could use a Multiplexer to get each sensor on its own channel so that they don’t conflict with each other. I have attached my code below.

So the problem I am running into is that only one of the sensors is reading correctly. I think that I have to add something like this to get them all working:

dps_a.parameter.communication = 0;
dps_a.parameter.I2CAddress = 0x77;

Though I can’t because the Adafruit_DPS310 has no library called “parameter.” (according to the error message I get)
Any suggestions would help!

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_DPS310.h>

#include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>

Adafruit_DPS310 dps_a;
Adafruit_DPS310 dps_b;
Adafruit_DPS310 dps_c;

#include “Wire.h”
extern “C” {
#include “utility/twi.h” // from Wire library, so we can do bus scanning
}

#define TCAADDR 0x70

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

Wire.beginTransmission(TCAADDR);
Wire.write(1 << i);
Wire.endTransmission();
}
double P_a = 0.; // pressure from sensor a
double P_b = 0.; // pressure from sensor b
double P_c = 0.; // pressure from sensor c

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

Serial.begin(115200);

tcaselect(2);
if(!dps_a.begin_I2C()){
Serial.println(“Failed to find DPS A”);
while (1) yield();
}
Serial.println(“DPS A OK!”);

tcaselect(3);
if(!dps_b.begin_I2C()){
Serial.println(“Failed to find DPS B”);
while (1) yield();
}
Serial.println(“DPS B OK!”);

tcaselect(4);
if(!dps_c.begin_I2C()){
Serial.println(“Failed to find DPS C”);
while (1) yield();
}
Serial.println(“DPS C OK!”);

//dps_a.configurePressure(DPS310_4HZ, DPS310_32SAMPLES);
// dps_b.configurePressure(DPS310_4HZ, DPS310_32SAMPLES);
// dps_c.configurePressure(DPS310_4HZ, DPS310_32SAMPLES);
}
void loop()
{sensors_event_t temp_event, pressure_event;

dps_a.getEvents(&temp_event, &pressure_event);
P_a = pressure_event.pressure;
dps_b.getEvents(&temp_event, &pressure_event);
P_b = pressure_event.pressure;
dps_c.getEvents(&temp_event, &pressure_event);
P_c = pressure_event.pressure;

Serial.print(F(", “));
Serial.print((P_a-1006.2)*10.,7);
Serial.print(F(”, “));
Serial.print((P_b-1006.2)*10.,7);
Serial.print(F(”, "));
Serial.print((P_c-1006.2)*10.,7);
Serial.println();

delay(1000);
}

Hello
did you serach for Adafruit_DPS310.h file inside the wordwide net ?

Thank you for the reply @paulpaulson but I was missing some code is all.

Please disregard this post.

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