DFRobot / DFRobot_SCD4X

MIT License
1 stars 0 forks source link

Can we change the default I2C address of SCD41 sensor by constructors? #1

Closed lemorage closed 4 months ago

lemorage commented 4 months ago

The information on my SCD41 sensor tells me the default I2C address is 0x62, however, I want to change it to another address. I wonder if we can use the constructor provided by the library to change the SCD4X_I2C_ADDR and how to do it (since I didn't see there is an example doing this)?

DFRobot_SCD4X(TwoWire *pWire=&Wire, uint8_t i2cAddr=SCD4X_I2C_ADDR);
qsjhyy commented 4 months ago

image The following is the same as the figure above:

/**
 * @brief Constructor
 * @param pWire - Wire object is defined in Wire.h, so just use &Wire and the methods in Wire can be pointed to and used
 * @param i2cAddr - SCD4X I2C address.
 */
DFRobot_SCD4X SCD4X(&Wire, /*i2cAddr = */0x62);
lemorage commented 4 months ago

So actually we can pass in another i2c address to override the default one, like this SCD4x scd4x(&Wire, 0x70);. Is it right?

qsjhyy commented 4 months ago

Sorry, I misunderstood your meaning earlier. This interface can be considered a reserved feature, supporting potential other SCD4x series sensors with different I2C addresses. However, according to the information provided in the chip manual, the SCD4x should only support the unique I2C address 0x62. Therefore, I'm just using a macro to represent its address. image

lemorage commented 4 months ago

alright, that makes sense to me. actually, I am thinking of the same problem that it seems we can only change the address physically, anyways, thanks for the reply.

qsjhyy commented 4 months ago

If you need to use two i2c sensors at the same time because the address is the same, and can not be changed, you can try using this type of module: https://www.dfrobot.com/product-1780.html

lemorage commented 4 months ago

Yeah, it looks like this is the standard way to resolve this. I'm not up for adding complexity, but anyway, I'll give it a try. Thanks for the info.