# Multiple Celsius Fast-Response Temperature Sensors with Multiplexor

**URL:** <https://discuss.bluerobotics.com/t/multiple-celsius-fast-response-temperature-sensors-with-multiplexor/7092>\
**Category:** Sensors\
**Created:** [March 24, 2020, 10:09pm UTC](https://discuss.bluerobotics.com/t/multiple-celsius-fast-response-temperature-sensors-with-multiplexor/7092 "2020-03-24T22:09:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaptainPivo](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CaptainPivo](https://discuss.bluerobotics.com/u/CaptainPivo)\
**Post date:** [March 24, 2020, 10:09pm UTC](https://discuss.bluerobotics.com/t/multiple-celsius-fast-response-temperature-sensors-with-multiplexor/7092/1 "2020-03-24T22:09:30Z")

</div>

Hi, I’m trying to implement two seperate celsius fast-response temperature sensors with my raspberry pi 3 by using the tca9548a i2c multiplexor.

I’m using python and was able to get one temperature sensor working (while hooked up directly to the raspberry pi).

However, I haven’t been able to get it to work through the mux, here is the code I’m using:

> <https://github.com/PeterBrichta/Data-Acquisition-Buoy/blob/master/TempSensor.py>

And here is the example code I tried to base my code off of:

> <https://github.com/adafruit/Adafruit_CircuitPython_TCA9548A/blob/main/examples/tca9548a_simpletest.py>

And here is a picture of the errors I’m getting:

 ![bluerobotics error](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/a/a97b521d28ae4674e13d95f2f39cb41fedd33a88.jpeg)

I should add that I’ve been able to detect the mux over i2c and have gotten the mux to work with another adafruit IMU. So I’m wondering if I’ve messed up something in the code or if the mux just isn’t compatible with the BlueRobotics temperature sensor?

Hopefully I provided enough information on my situation and any help is greatly appreciated, thank you.

---

<div class="post-metadata">

**Author:** ![CaptainPivo](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CaptainPivo](https://discuss.bluerobotics.com/u/CaptainPivo)\
**Post date:** [March 25, 2020, 9:19pm UTC](https://discuss.bluerobotics.com/t/multiple-celsius-fast-response-temperature-sensors-with-multiplexor/7092/3 "2020-03-25T21:19:30Z")

</div>

Update: So I’ve been able to detect two Celsius Fast-Response Temperature Sensors through the tca9548a multiplexer. Additionally I’ve been able to get a reading from both and verified that it’s coming from each individual sensor. My only problem now is that I can only grab one reading from each one before I receive an error. (Cannot construct a working loop to get continuous readings)

The new code I have:

> <https://github.com/PeterBrichta/Data-Acquisition-Buoy/blob/master/TempSensor.py>

The new error:

 ![bluerobotics error2](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/6/67e3e71cf7e1e17df1913b24d4d48ab1d3d40cc6.jpeg)

---

<div class="post-metadata">

**Author:** ![ryanb](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@ryanb](https://discuss.bluerobotics.com/u/ryanb)\
**Post date:** [March 26, 2020, 5:49pm UTC](https://discuss.bluerobotics.com/t/multiple-celsius-fast-response-temperature-sensors-with-multiplexor/7092/4 "2020-03-26T17:49:15Z")

</div>

Hi Peter,

It looks like you were on track with your commit on March 24, there is just a small typo.

The following line:  
`tca = adafruit_tca9548a.TCA9548A(I2C)`

should read:  
`tca = adafruit_tca9548a.TCA9458A(i2c)`

The first line is referencing the I2C class within busio and the second is the i2c object that you just created.

Let me know if that sorts it out!

Ryan

---

<div class="post-metadata">

**Author:** ![CaptainPivo](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CaptainPivo](https://discuss.bluerobotics.com/u/CaptainPivo)\
**Post date:** [March 27, 2020, 4:45pm UTC](https://discuss.bluerobotics.com/t/multiple-celsius-fast-response-temperature-sensors-with-multiplexor/7092/5 "2020-03-27T16:45:53Z")

</div>

Hi, thanks for the reply!

Unfortunately I’m still receiving the same error as the one I posted first. I tried to just get a single sensor to work but still no success.

\*It flagged my post and says I’m unable to post a link to github, is that not allowed?

---

<div class="post-metadata">

**Author:** ![CaptainPivo](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CaptainPivo](https://discuss.bluerobotics.com/u/CaptainPivo)\
**Post date:** [March 27, 2020, 5:26pm UTC](https://discuss.bluerobotics.com/t/multiple-celsius-fast-response-temperature-sensors-with-multiplexor/7092/6 "2020-03-27T17:26:59Z")

</div>

I reached out to adafruit and they said the problem has to do with tsys01.py

When I linked them the file the response was:

“That code is expecting an I2C bus number, not an actual I2C bus. So it probably won’t be usable with our TCA library as is.”

Is there a way to fix this?

---

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [March 30, 2020, 6:19pm UTC](https://discuss.bluerobotics.com/t/multiple-celsius-fast-response-temperature-sensors-with-multiplexor/7092/7 "2020-03-30T18:19:38Z")

</div>

@CaptainPivo did you get it working?

I’m guessing a lot here (I haven’t looked closely at adafruits library), but maybe you could change [this line](https://github.com/bluerobotics/tsys01-python/blob/master/tsys01/tsys01.py#L31) to `self._bus = bus` so the constructor can receive the bus itself instead of its number.

---

<div class="post-metadata">

**Author:** ![CaptainPivo](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CaptainPivo](https://discuss.bluerobotics.com/u/CaptainPivo)\
**Post date:** [April 2, 2020, 7:05pm UTC](https://discuss.bluerobotics.com/t/multiple-celsius-fast-response-temperature-sensors-with-multiplexor/7092/8 "2020-04-02T19:05:34Z")

</div>

Hi, thanks for the reply.

I was able to get the sensors working but through a different method. I followed this guide and setup additional I2C buses:

> **[Raspberry PI Multiple I2C Devices](https://www.instructables.com/Raspberry-PI-Multiple-I2c-Devices/)**
>
> Raspberry PI Multiple I2C Devices: Frustrated because you can not use multiples of the same I2C devices in your project. No need to use slow multiplexers. The latest raspbian kernel support the creation of multiple I2C busses using GPIO pins. This...

I’ve since run into a new issue, however it has to do with the Adafruit LSM6DS33 IMU. I have the IMU connected to default bus 1 and the sensors connected to the created buses 3 and 4 (on the GPIO pins). I can detect the IMU but it will no longer initialize.

If you have any idea to a solution for this that would be great! Otherwise I understand if you don’t and will reach out to adafruit as well.
