<?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[M5Dial external i2C (port A) with Arduino Wire]]></title><description><![CDATA[<p dir="auto">I want to use a I2C CAN Bus Module <a href="https://docs.longan-labs.cc/1030017/" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.longan-labs.cc/1030017/</a> connected to the port A on the M5Dial.<br />
The Longan_I2C_CAN_Arduino lib uses the Arduino Wire lib.<br />
I get the following error probably because It uses the internal I2C.</p>
<pre><code>Guru Meditation Error: Core  1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4200f55c: e2e502ad 000000ff fd004136
...
</code></pre>
<p dir="auto">in the main.ino file I declare a second Wire instance and initialize it with the pins used on the M5Dial.</p>
<pre><code>TwoWire i2Ctwo(2);
I2C_CAN CAN(0x25, &amp;i2Ctwo); // Set I2C address and Wire instance 

void setup() {
  int8_t SDA_2 = M5.Ex_I2C.getSDA(); // 2 (G13)
  int8_t SCL_2 = M5.Ex_I2C.getSCL(); // 3 (G15)
  i2Ctwo.begin(SDA_2, SCL_2);
...
</code></pre>
<p dir="auto">But the M5Dial class uses already the I2C_Class instead of the TwoWire class.</p>
<pre><code>// for external I2C device (Port.A)
   I2C_Class &amp;Ex_I2C = m5::Ex_I2C;
</code></pre>
<p dir="auto">I modified the I2C_CAN lib to be able to pass a TwoWire * pointer.</p>
<pre><code>I2C_CAN::I2C_CAN(unsigned char __addr, TwoWire *__i2c = &amp;Wire)
{
    IIC_ADDR = __addr;
    i2C = __i2c;
}

void I2C_CAN::begin()
{
    i2C-&gt;begin();
}

void I2C_CAN::IIC_CAN_SetReg(unsigned char __reg, unsigned char __len, unsigned char *__dta)
{
    i2C-&gt;beginTransmission(IIC_ADDR);
    i2C-&gt;write(__reg);
    for(int i=0; i&lt;__len; i++)
    {
        i2C-&gt;write(__dta[i]);
    }
    i2C-&gt;endTransmission();
}
...
</code></pre>
<p dir="auto">Has anyone tried to use a I2C extension on port A with a standard Arduino lib? Any help would be appreciated.</p>
]]></description><link>https://community.m5stack.com/topic/6920/m5dial-external-i2c-port-a-with-arduino-wire</link><generator>RSS for Node</generator><lastBuildDate>Wed, 13 May 2026 04:15:26 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6920.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 Oct 2024 21:42:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5Dial external i2C (port A) with Arduino Wire on Wed, 23 Oct 2024 18:09:45 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/minieigi" aria-label="Profile: minieigi">@<bdi>minieigi</bdi></a></p>
<p dir="auto">you are correct, the standard Wire pins are configured correctly for port A, but in your case you don't want the I2C_Class wrapper from M5Unified. So the idea is to release/end <code>Wire</code> as it has been initialized in <code>M5.begin()</code> and then restart <code>Wire</code> by calling <code>Wire.begin(13, 15)</code>.</p>
<p dir="auto">And yes, I think the <code>release()</code> is done automatically when <code>Wire</code> is re-initialize.</p>
<p dir="auto">Note: I don't have this particular sensor so I cannot fully test this myself.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/26825</link><guid isPermaLink="true">https://community.m5stack.com/post/26825</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 23 Oct 2024 18:09:45 GMT</pubDate></item><item><title><![CDATA[Reply to M5Dial external i2C (port A) with Arduino Wire on Wed, 23 Oct 2024 17:57:01 GMT]]></title><description><![CDATA[<p dir="auto">If I leave the <strong>Longan_I2C_CAN_Arduino</strong> lib unchanged I get one CAN message before the device reboots and I see the error I posted above.<br />
It seems the standard Wire pins are configured properly.<br />
If I add <strong>Wire.begin(2, 3)</strong> the device is not even starting Serial debug.<br />
M5.Ex_I2C.release(); is not making any difference.</p>
]]></description><link>https://community.m5stack.com/post/26824</link><guid isPermaLink="true">https://community.m5stack.com/post/26824</guid><dc:creator><![CDATA[minieigi]]></dc:creator><pubDate>Wed, 23 Oct 2024 17:57:01 GMT</pubDate></item><item><title><![CDATA[Reply to M5Dial external i2C (port A) with Arduino Wire on Wed, 23 Oct 2024 02:23:15 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/minieigi" aria-label="Profile: minieigi">@<bdi>minieigi</bdi></a></p>
<p dir="auto">have you tried to simply use <code>Wire</code>? E.g.</p>
<pre><code>//  i2Ctwo.begin(SDA_2, SCL_2);
  Wire.begin(SDA_2, SCL_2);
</code></pre>
<p dir="auto">In addition you could also try to first release/end the predefined <code>Wire</code>:</p>
<pre><code>  M5.Ex_I2C.release();
</code></pre>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/26820</link><guid isPermaLink="true">https://community.m5stack.com/post/26820</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 23 Oct 2024 02:23:15 GMT</pubDate></item></channel></rss>