Mux TCA9548A and NAU7802 connection problem

Hi,

I have a MUX TCA9548A (8 channels) and trying to use multiple NAU7802. I already connected and configured a NAU7802 successfully without the MUX, but I can not see connection with NAU when connected to MUX.

To check MUX, some others sensor were connected to it, such as BME280. I took BME280 to all ports, selecting the MUX port and running i2cdetect, it can be seen and it delivers its values in each port. But with NAU is not working, not even when I already tested by code to connec to 0x2A directly with good results.

Does it have something to do with pull up resistors ? Power ?

Any hint you could provide ?

One more thing I forgot to say, as soon as NAU is connected to MUX, its power LED turns ON. Everything looks ready, but no response from NAU.

Are you able to probe the Data and Clock lines with an oscilloscope?

Did you end up solving this problem? I am having a similar issue with the same hardware, though intermittently.

I can successfully get a serial output from all of the NAU7802’s on some occasions, and on other occasions not all of the sensors output or no sensors output at all. Pressing the reset button on the Arduino after connecting the USB sometimes fixes the problem.

I have limited knowledge of Arduino etc. but it seems to me the sensors aren’t always ACK ing when: ```
myScale.available()


Does the NAU7802 require some sort of reset when switching between channels on the TCA9548A?

Each NAU7802 is connected to the 5V & GND on the Arduino and to a SDA and SCL port pair on the TCA9548A. The SDA and SCL ports on the TCA9548A are connected to the A4 and A5 pins on the Arduino Uno. The load cells are [https://au.rs-online.com/web/p/strain-gauges/8937398](https://au.rs-online.com/web/p/strain-gauges/8937398).

Code is based on the Library provided by SparkFun and is below:

#include <Wire.h>
#include <EEPROM.h> //Needed to record user settings

#include “SparkFun_Qwiic_Scale_NAU7802_Arduino_Library.h” // Click here to get the library: http://librarymanager/All#SparkFun_NAU8702

NAU7802 myScale; //Create instance of the NAU7802 class

//EEPROM locations to store 4-byte variables
#define LOCATION_CALIBRATION_FACTOR 0 //Float, requires 4 bytes of EEPROM
#define LOCATION_ZERO_OFFSET 10 //Must be more than 4 away from previous spot. Long, requires 4 bytes of EEPROM

bool settingsDetected = false; //Used to prompt user to calibrate their scale

//Create an array to take average of weights. This helps smooth out jitter.
#define AVG_SIZE 4
float avgWeights[AVG_SIZE];
byte avgWeightSpot = 0;

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

Wire.beginTransmission(0x70); //TCA9548A address is 0x70
Wire.write(1 << bus); // send byte to select bus
Wire.endTransmission();
}

void setup()
{

Serial.begin(9600);
Wire.begin();
Wire.setClock(400000); //Qwiic Scale is capable of running at 400kHz if desired

for(int i=0; i<8; i++){
tcaselect(i);
if (myScale.begin() == false)
{
Serial.print(“Scale “);
Serial.print(i);
Serial.print(” not detected. Please check wiring.”);
Serial.println();
}
}

myScale.setGain(NAU7802_GAIN_4);
myScale.setSampleRate(NAU7802_SPS_10); //Increase to max sample rate
myScale.calibrateAFE(); //Re-cal analog front end when we change gain, sample rate, or channel
}

void loop()
{
float settingCalibrationFactor[8];
long settingZeroOffset[8];

//Calibration settings for load cell #0
settingCalibrationFactor[0] = 1071270.00; //Value used to convert the load cell reading to lbs or kg
settingZeroOffset[0] = 1000;

//Calibration settings for load cell #1
settingCalibrationFactor[1] = 47020.00; //Value used to convert the load cell reading to lbs or kg
settingZeroOffset[1] = -105445;

//Calibration settings for load cell #2
settingCalibrationFactor[2] = 1213750.00; //Value used to convert the load cell reading to lbs or kg
settingZeroOffset[2] = 108850;

//Calibration settings for load cell #3 [GOOD]
settingCalibrationFactor[3] = 32770.00; //Value used to convert the load cell reading to lbs or kg
settingZeroOffset[3] = 7122;

//Calibration settings for load cell #4
settingCalibrationFactor[4] = 1135370.00; //Value used to convert the load cell reading to lbs or kg
settingZeroOffset[4] = -326103;

//Calibration settings for load cell #5 [GOOD]
settingCalibrationFactor[5] = 34400.00; //Value used to convert the load cell reading to lbs or kg
settingZeroOffset[5] = 9587;

//Calibration settings for load cell #6
settingCalibrationFactor[6] = 1135370.00; //Value used to convert the load cell reading to lbs or kg
settingZeroOffset[6] = -326103;

//Calibration settings for load cell #7
settingCalibrationFactor[7] = 1135370.00; //Value used to convert the load cell reading to lbs or kg
settingZeroOffset[7] = -326103;

for (int i = 0; i<8; i++)
{
  delay(10);
  tcaselect(i); //select load cell
  if (myScale.getReading() != 0)
  {
    //Pass these values to the library
    myScale.setCalibrationFactor(settingCalibrationFactor[i]);
    myScale.setZeroOffset(settingZeroOffset[i]);
    
    long currentReading = myScale.getReading();
    float currentWeight = myScale.getWeight();

    Serial.print("Cell");
    Serial.print(i);
    Serial.print(": ");
    Serial.print(currentReading);
    Serial.print("  Wt: ");
    Serial.print(currentWeight, 2); //Print 2 decimal places
    Serial.print("    ");
  }

}
Serial.println();

if (Serial.available())
{
byte incoming = Serial.read();

if (incoming == 't') //Tare the scale
  myScale.calculateZeroOffset();
else if (incoming == 'c') //Calibrate
{
  calibrateScale();
}

}
}

You need a separate instance of an NAU7802 object for each one.

NAU7802 myScale[8];



  for(int i=0; i<8; i++){
    tcaselect(i);
    if (myScale[i].begin() == false)
    {
        Serial.print("Scale ");
        Serial.print(i);
        Serial.print(" not detected. Please check wiring.");
        Serial.println();
    }
  }
  myScale[i].setGain(NAU7802_GAIN_4);
  myScale[i].setSampleRate(NAU7802_SPS_10); //Increase to max sample rate
  myScale[i].calibrateAFE(); //Re-cal analog front end when we change gain, sample rate, or channel 
}

and likewise in loop()