<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[I2C Multiplexer Driver]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">In connection with another post (<a href="https://forum.modalai.com/topic/3246/maximum-i2c-clock-frequency/19?_=1712302870042">link</a>) we're trying to put together some custom drivers for sensors we'd like to use with the voxl2 mini. Previously we got a driver working for a hall-effect sensor we were interested in using, but in reality we want to use 4 of them.</p>
<p dir="auto">All 4 have the same I2C address (which could be changed given more IO) so we're interfacing these using an I2C multiplexer. I wanted to try and reuse the previously mentioned single sensor driver, but it seems not so straightforward. For example, calling the <code>module_start</code> for the multiplexer driver will be a bit complicated if it in reality needs to also start the underlying hall-effect drivers. Also probing (function used by I2C class) the sensor drivers at the start is not so possible, given they will be "hidden" behind mux.</p>
<p dir="auto">I was curious if you knew of any examples of something similar? Or any advice how to structure this. Hope it makes sense</p>
]]></description><link>https://forum.modalai.com/topic/3294/i2c-multiplexer-driver</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 04:37:09 GMT</lastBuildDate><atom:link href="https://forum.modalai.com/topic/3294.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Apr 2024 07:47:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to I2C Multiplexer Driver on Tue, 09 Apr 2024 14:51:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.modalai.com/uid/2128">@Morten-Nissov</a> I would advise trying to get some support from the PX4 community. I'm not aware of any use of i2c multiplexers in any current PX4 drivers but I think it's a useful feature. But that is the best place to get advice on PX4 development.</p>
]]></description><link>https://forum.modalai.com/post/16078</link><guid isPermaLink="true">https://forum.modalai.com/post/16078</guid><dc:creator><![CDATA[Eric Katzfey]]></dc:creator><pubDate>Tue, 09 Apr 2024 14:51:28 GMT</pubDate></item><item><title><![CDATA[Reply to I2C Multiplexer Driver on Tue, 09 Apr 2024 14:58:35 GMT]]></title><description><![CDATA[<p dir="auto">Edit 2: Tried creating a class for handling only the multiplexer:</p>
<pre><code>#define NUMBER_OF_TMAG5273 1

class PCA9546 : public device::I2C
{
public:
  PCA9546(const I2CSPIDriverConfig&amp; config)
    : I2C(DRV_MAG_DEVTYPE_PCA9546, "pca9546", config.bus, ADA_PCA9546::I2C_ADDRESS_DEFAULT, I2C_SPEED)
  {
  }

  bool select(uint8_t i)
  {
    if (i &gt;= NUMBER_OF_TMAG5273)
    {
      PX4_ERR("select for index &gt; NUMBER_OF_TMAG5273: %i", NUMBER_OF_TMAG5273);
      return false;
    }

    this-&gt;transfer(&amp;i, 1, nullptr, 0);
    return true;
  }
private:
  int probe() override
  {
    return PX4_OK; // mux doesn't return anything
  }
};
</code></pre>
<p dir="auto">I include this as a member variable in my main driver class which is meant to read from the hall-effect sensors through the mux. This is proving to be a bit difficult as the <code>probe</code> doesn't seem to succeed ever (same probe which worked with single sensor but now with a call to <code>select(0)</code> first to test.</p>
<p dir="auto">Edit3: The mux driver can read a single sensor (sending the byte to mux address first followed by the standard read exchange) so it would seem that the difficult comes with the part interfacing the mux.</p>
]]></description><link>https://forum.modalai.com/post/16076</link><guid isPermaLink="true">https://forum.modalai.com/post/16076</guid><dc:creator><![CDATA[Morten Nissov]]></dc:creator><pubDate>Tue, 09 Apr 2024 14:58:35 GMT</pubDate></item><item><title><![CDATA[Reply to I2C Multiplexer Driver on Tue, 09 Apr 2024 09:23:09 GMT]]></title><description><![CDATA[<p dir="auto">Thanks to both.</p>
<p dir="auto">We actually have a mutliplexer (PCA9546) and 4 magnetometers working on a teensy. So all should be good, it's just about converting this to px4.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.modalai.com/uid/157">@Vinny</a> This sounds interesting because it is essentially what we would like to do, the challenge for us is that we haven't found a way to send I2C messages to the multiplex address (0x70) as well as the sensor address (0x35) from a single px4 driver class. Did you manage to do something similar?</p>
<p dir="auto">I've been trying to create a class for the multiplexer and have the magnetometer as a member variable but it doesn't seem like this will work particularly well given the standard boilerplate for px4 drivers. At least to me it looks that way. I assume it's the same for you, that the multiplex just needs a single byte sent to select which sensor is enabled, if you've found an easy way to send this byte from an I2C driver with a different address then I would be interested in hearing how to do that.</p>
<p dir="auto">Edit: I mean this in particular for bus 1 on header J19. I believe this bus is on the DSP. I think this is relevant for how I do I2C at a low level right? E.g., on linux using ioctl and such to write a byte. I mention this because I tried to implement this with ioctl and the docker container returns</p>
<pre><code>fatal error: 'linux/i2c.h' file not found
#include &lt;linux/i2c.h&gt;
</code></pre>
<p dir="auto">so I figured this was maybe not 100% correct.</p>
]]></description><link>https://forum.modalai.com/post/16062</link><guid isPermaLink="true">https://forum.modalai.com/post/16062</guid><dc:creator><![CDATA[Morten Nissov]]></dc:creator><pubDate>Tue, 09 Apr 2024 09:23:09 GMT</pubDate></item><item><title><![CDATA[Reply to I2C Multiplexer Driver on Fri, 05 Apr 2024 17:03:28 GMT]]></title><description><![CDATA[<p dir="auto">HI <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.modalai.com/uid/2128">@Morten-Nissov</a><br />
We've done some internal projects using the TCA9548A 8-port I2C mux.<br />
<img src="/assets/uploads/files/1712336449582-0bb6fdfe-53cf-46bd-bc6f-e3666b29817c-image.png" alt="0bb6fdfe-53cf-46bd-bc6f-e3666b29817c-image.png" class=" img-fluid img-markdown" /><br />
It's a very simple device that has only one config register, and the ability to configure it's device address to eight different values.<br />
The mux also provides inherent voltage translation too, which is why I love it!<br />
Check it out... <a href="https://www.ti.com/product/TCA9548A" rel="nofollow ugc">https://www.ti.com/product/TCA9548A</a>?</p>
<p dir="auto">As far as supported SW for it, since it is just a 1-register device, it should not be hard to include a command to configure it how you need to support a polling structure, but we have no official support as Eric mentioned.</p>
<p dir="auto">Hope this helps!</p>
]]></description><link>https://forum.modalai.com/post/16016</link><guid isPermaLink="true">https://forum.modalai.com/post/16016</guid><dc:creator><![CDATA[Vinny]]></dc:creator><pubDate>Fri, 05 Apr 2024 17:03:28 GMT</pubDate></item><item><title><![CDATA[Reply to I2C Multiplexer Driver on Fri, 05 Apr 2024 14:56:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.modalai.com/uid/2128">@Morten-Nissov</a> I think you are charting some new ground here. You might have better luck posting on the PX4 forum. And also, you don't have to follow the same structure as other i2c drivers. You can just do something completely custom.</p>
]]></description><link>https://forum.modalai.com/post/16012</link><guid isPermaLink="true">https://forum.modalai.com/post/16012</guid><dc:creator><![CDATA[Eric Katzfey]]></dc:creator><pubDate>Fri, 05 Apr 2024 14:56:29 GMT</pubDate></item></channel></rss>