I have a Redboard Qwiic, Qwiic mux, and one SEN-16476 (Qwiic) pressure sensor connected to P0 on the mux. I have disabled the I2C pull-ups on the sensor. I have the Qwiic connector from the redboard connected to Main on the mux. The output that I get on the serial monitor is nan PSI. Any ideas?
Thanks Eric
#include <SparkFun_I2C_Mux_Arduino_Library.h>
#include <Wire.h>
#include <SparkFun_MicroPressure.h>
SparkFun_MicroPressure mpr;
/*
Basic control and commands for the PCA9548A/TCA9548A I2C multiplexer
*/
#define MUX_ADDR 0x70 //7-bit unshifted default I2C Address
//Enables a specific port number
void enableMuxPort(byte portNumber)
{
if (portNumber > 7) portNumber = 7;
//Read the current mux settings
Wire.requestFrom(MUX_ADDR, 1);
if (!Wire.available()) return; //Error
byte settings = Wire.read();
//Set the wanted bit to enable the port
settings |= (1 << portNumber);
//Write the updated settings
Wire.beginTransmission(MUX_ADDR);
Wire.write(settings);
Wire.endTransmission();
}
//Disables a specific port number
void disableMuxPort(byte portNumber)
{
if (portNumber > 7) portNumber = 7;
//Read the current mux settings
Wire.requestFrom(MUX_ADDR, 1);
if (!Wire.available()) return; //Error
byte settings = Wire.read();
//Clear the wanted bit to disable the port
settings &= ~(1 << portNumber);
//Write the updated settings
Wire.beginTransmission(MUX_ADDR);
Wire.write(settings);
Wire.endTransmission();
}
void setup() {
Serial.begin(115200);
if(!mpr.begin()) {
Serial.println(“Cant Connect”);
}
for (byte x = 0 ; x <= 7; x++){
disableMuxPort(x);
}
}
void loop() {
enableMuxPort(byte (0));
Serial.print(mpr.readPressure(),4);
Serial.println(" PSI");
disableMuxPort(byte (0));
delay(500);
}