ArduinoTroubleshooting

3x PM2.5 + 3x O2 Sensors I2C conflicts

userHead jonner13 2023-06-21 00:35:42 242 Views2 Replies

Im trying to do some air quality measurement on an Arduino mega 2560 R3. Im using 3x DFRobot PM2.5 and 3x DFRobot O2 Sensors which use I2C as their communication method. In the code Ive assigned each sensor their own address and I included the code below. Ive hooked up all their SCL and SDA lines to the same 2 pins on the arduino. With this setup I cant get past the .begin() function for the first sensors so Im thinking at this point I may need to just buy the DFRobot Multiplexer to solve this issue but I was under the impression that these sensors if individually addressed can all work on the same SCL and SDA data lines. 

Thoughts ? Thank you in advance!

 

```
#define Oxygen_IICAddress_0 ADDRESS_0
#define Oxygen_IICAddress_1 ADDRESS_1
#define Oxygen_IICAddress_2 ADDRESS_2

 

DFRobot_OxygenSensor Oxygen_0;
DFRobot_OxygenSensor Oxygen_1;
DFRobot_OxygenSensor Oxygen_2;


#define AirQuality_IICAddress_0 0x19
#define AirQuality_IICAddress_1 0x20
#define AirQuality_IICAddress_2 0x21


DFRobot_AirQualitySensor AirQualitySensor_0(&Wire ,AirQuality_IICAddress_0);
DFRobot_AirQualitySensor AirQualitySensor_1(&Wire ,AirQuality_IICAddress_1);
DFRobot_AirQualitySensor AirQualitySensor_2(&Wire ,AirQuality_IICAddress_2);

```

2023-06-21 12:00:49

Is it this PM2.5 sensor?

https://www.dfrobot.com/product-2439.html

 

This PM2.5 sensor cannot modify the I2C address. If you use three PM2.5 at the same time, you need a DFRobot Multiplexer module. Our oxygen sensor can modify the I2C address. You can try using multiple oxygen sensors first.

userHeadPic jenna
2023-06-21 11:31:14

If you are using these two sensor:

https://www.dfrobot.com/product-2439.html

https://www.dfrobot.com/product-2052.html

 

The O2 sensor could set the different IIC address by the on-board dial.

But I don't think the PM2.5 sensor could set different IIC address.

 

So this is might be the IIC address confilct problem. There could not be two same IIC address on one IIC bus wire. This would cause the IIC master don't which slave to communicate.(Unless you use the Multiplexer.)

 

To confirm this, you could upload the IIC scanner code, and connect each of your sensor to the board to print out the address.

If there are two same address in five of your sensor, then this is the address conflict.

 

IIC scanner code:

https://github.com/rifandani/i2c-scanner

userHeadPic Yeez_B