TCA9548A with PM2.5 sensor SEN0460 DFRobot

I am working on the project of a filtration efficiency tester, and want to compare the particle in the chamber before the filter and the particle after the filter. so, I decided to use 2 particle sensor SEN0460 DFRobot (Gravity: PM2.5 Air Quality Sensor PM2.5/PM10 Particle Sensor Wiki - DFRobot) which having the same i2c address 0x19. I decided to use TCA9548A, I have never used an i2c multiplexer before, so I have no idea how to code it. I tried to combine the code from the example given on many websites but still didn't work. It would be a pleasure if anyone can give me some hints or advice. Thank you.

Below is the PM2.5 sensor code

#include "DFRobot_AirQualitySensor.h"

#define I2C_ADDRESS    0x19
  DFRobot_AirQualitySensor particle(&Wire ,I2C_ADDRESS);

void setup() {
  Serial.begin(115200);
/**
  Sensor initialization is used to initialize IIC, which is determined by the communication mode used at this time.
*/
  while(!particle.begin())
  {
    Serial.println("NO Deivces !");
    delay(1000);
  }
  Serial.println("sensor begin success!");
  delay(1000);
/**
  Get sensor version number
*/
  uint8_t version = particle.gainVersion();
  Serial.print("version is : ");
  Serial.println(version);
  delay(1000);
}

void loop() {
/**
 *@brief : Get concentration of PM1.0 PM2.5 PM10
 *@param :PARTICLE_PM1_0_STANDARD  Standard particle  
          PARTICLE_PM2_5_STANDARD  Standard particle  
          PARTICLE_PM10_STANDARD   Standard particle 
          PARTICLE_PM1_0_ATMOSPHERE  In atmospheric environment
          PARTICLE_PM2_5_ATMOSPHERE  In atmospheric environment
          PARTICLE_PM10_ATMOSPHERE   In atmospheric environment
*/  
  uint16_t PM2_5 = particle.gainParticleConcentration_ugm3(PARTICLE_PM2_5_STANDARD);
  uint16_t PM1_0 = particle.gainParticleConcentration_ugm3(PARTICLE_PM1_0_STANDARD);
  uint16_t PM10 = particle.gainParticleConcentration_ugm3(PARTICLE_PM10_STANDARD);
  Serial.print("PM1.0 concentration:");
  Serial.print(PM1_0);
  Serial.println(" ug/m3");
  Serial.print("PM2.5 concentration:");
  Serial.print(PM2_5);
  Serial.println(" ug/m3");
  Serial.print("PM10 concentration:");
  Serial.print(PM10);
  Serial.println(" ug/m3");
  Serial.println();
  delay(1000);
}
#include "DFRobot_AirQualitySensor.h"

#define I2C_ADDRESS    0x19
DFRobot_AirQualitySensor particle[2] = {
    DFRobot_AirQualitySensor(&Wire ,I2C_ADDRESS),
    DFRobot_AirQualitySensor(&Wire ,I2C_ADDRESS)
}

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

void setup() {
  Serial.begin(115200);
/**
  Sensor initialization is used to initialize IIC, which is determined by the communication mode used at this time.
*/
  for (byte s=0; s<2; s++) {
    Serial.print("Starting sensor ");
    Serial.println(s);
    TCA9548A(s);
    while(!particle[s].begin())
      {
      Serial.println("NO Deivces !");
      delay(1000);
      }
    Serial.println("sensor begin success!");
    delay(1000);
/**
  Get sensor version number
*/
    uint8_t version = particle[s].gainVersion();
    Serial.print("version is : ");
    Serial.println(version);
    delay(1000);
  }
}

void loop() {
/**
 *@brief : Get concentration of PM1.0 PM2.5 PM10
 *@param :PARTICLE_PM1_0_STANDARD  Standard particle  
          PARTICLE_PM2_5_STANDARD  Standard particle  
          PARTICLE_PM10_STANDARD   Standard particle 
          PARTICLE_PM1_0_ATMOSPHERE  In atmospheric environment
          PARTICLE_PM2_5_ATMOSPHERE  In atmospheric environment
          PARTICLE_PM10_ATMOSPHERE   In atmospheric environment
*/  
  for (byte s=0; s<2; s++) {
    Serial.print("Reading sensor ");
    Serial.println(s);
    TCA9548A(s);
    uint16_t PM2_5 = particle[s].gainParticleConcentration_ugm3(PARTICLE_PM2_5_STANDARD);
    uint16_t PM1_0 = particle[s].gainParticleConcentration_ugm3(PARTICLE_PM1_0_STANDARD);
    uint16_t PM10 = particle[s].gainParticleConcentration_ugm3(PARTICLE_PM10_STANDARD);
    Serial.print("PM1.0 concentration:");
    Serial.print(PM1_0);
    Serial.println(" ug/m3");
    Serial.print("PM2.5 concentration:");
    Serial.print(PM2_5);
    Serial.println(" ug/m3");
    Serial.print("PM10 concentration:");
    Serial.print(PM10);
    Serial.println(" ug/m3");
    Serial.println();
    delay(1000);
  }
}

it appeared to be 'No device', I don't know whether there is something wrong with my pin connection.

but this is my pin
SCL of TCA9548A - A5 of Arduino
SDA of TCA9548A - A4 of Arduino

SCL Sensor 1 - SCL2 TCA9548A
SDA Sensor 1 - SDA2 TCA9548A

SCL Sensor 2 - SCL3 TCA9548A
SDA Sensor 2 - SDA3 TCA9548A

A0 - GND
A1 - GND
A2 - GND

Thank you so much for answering my topic.

Try this:
SCL Sensor 1 - SC0 TCA9548A
SDA Sensor 1 - SD0 TCA9548A

SCL Sensor 2 - SC1 TCA9548A
SDA Sensor 2 - SD1 TCA9548A

I got it, thank you so much, you save my day.

1 Like

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