This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HDC2022: Reading data from multiple sensors through I2C multiplexer

Part Number: HDC2022
Other Parts Discussed in Thread: HDC2080,

Hi,

I have connected 2 sensors# HDC2022 (ADDR = 0x40 and 0x41) to each output of  1 X 8 I2C multiplexer (PCA9548 through Arduino - total = 16 sensors) , and trying to read the data from all sensors one after one. can anyone share the example code for reading the data from multiple sensors ? I am using HDC2080 library and can able to read the data from one sensor.

Regards,

Veera

  • Dear Veera - 

    Thanks for the post! 

    Here you would need to (on each loop through each channel) replicate your code for address 0x40, and add address 0x41 subsequent to polling for 0x40. Then you would want to command your PCA9548 to switch channels and repeat that loop. (as the default state of the PCA device channel is all disabled, so I am assuming you commanded it to a specific channel, as you stated you were able to communicate with the device at 0x40 already.) Then switch and loop six more times to capture data from all 16 devices. 

    Specifically, for the mux, to address next channel (if you started with Channel 0 of the PCA9548 using command byte 0x01), you would send 0x02, to turn on Channel 1 and turn off Channel 0.  See pages 16 & 17 here: https://www.ti.com/lit/ds/symlink/pca9548a.pdf 

  • Thank you Josh. I have modified the code and tried to compile the code, but I am getting error when I initialize/call the following function "HDC2080 sensor(0x41)" more than one time. sent you the code over email. please have a look and let me know the issue.

  • Veera - 

    Please find attached and image below for assisting you into organizing your code to accomplish setting up and using the parts via the mux. 

    4745.HDC2_PCA9548_Mux_logic.pdf

  • Veera -

    I was able to dig up a MEGA 2560 and put this sketch together for you, which is a one second loop read of two HDC2 sensors, one on address 0x40, the other on 0x41. I tested this on my side with hardware I had. You will still need to add the PCA specific code & loop, and of course test. Please do let me know if you get it working / or get stuck by replying or reposting.  

    0x40_0x41_HDC20xx_Example_12_2022.ino

    This is the output, on UART, so you can log it as a csv, with a timestamp added by the terminal up front, and still comma separated correctly