<?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 &amp; CAN using PlatformIO]]></title><description><![CDATA[<p dir="auto">Has anyone got the m5Stack dial to work with the CAN (Controller Area Network) Unit SKU: U085 using PlatformIO?</p>
<p dir="auto">I have got all the examples to compile OK but now I want to connect to the CAN unit I get errors.</p>
<p dir="auto">Yours Simon M.</p>
]]></description><link>https://community.m5stack.com/topic/5866/m5dial-can-using-platformio</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Mar 2026 12:34:43 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5866.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 03 Dec 2023 14:42:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5Dial &amp; CAN using PlatformIO on Fri, 19 Jan 2024 17:54:11 GMT]]></title><description><![CDATA[<p dir="auto">I did get this to work.  I'm using this library for the CAN part:</p>
<p dir="auto"><a href="https://github.com/aaknitt/esp32_can/tree/master" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/aaknitt/esp32_can/tree/master</a></p>
<p dir="auto">Put this code in lib and change the pin designations in esp32_can.cpp:<br />
ESP32CAN <strong>attribute</strong>((weak)) CAN0(GPIO_NUM_1, GPIO_NUM_2) ;</p>
<p dir="auto">platformio.ini looks like this:</p>
<p dir="auto">[env:m5stack-stamps3]<br />
platform = espressif32<br />
board = m5stack-stamps3<br />
framework = arduino</p>
<p dir="auto">lib_deps =<br />
<a href="https://github.com/collin80/can_common" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/collin80/can_common</a><br />
<a href="https://github.com/plapointe6/EspMQTTClient" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/plapointe6/EspMQTTClient</a><br />
m5stack/M5Dial<br />
m5stack/M5Unified</p>
<p dir="auto">upload_speed = 1500000<br />
monitor_speed = 115200</p>
<p dir="auto">Plug it into Port B</p>
<p dir="auto">Setup code is like:<br />
CAN0.setCANPins(GPIO_NUM_1, GPIO_NUM_2);<br />
USBSerial.println("Set CAN pins...");<br />
CAN0.begin(500000);<br />
USBSerial.println("CAN has started...");<br />
CAN0.watchFor();<br />
CAN0.setCallback(0, theCanDecoder);</p>
<p dir="auto">If you want full code I can probably clean this all up and publish on Git.</p>
]]></description><link>https://community.m5stack.com/post/23407</link><guid isPermaLink="true">https://community.m5stack.com/post/23407</guid><dc:creator><![CDATA[uberdweeb]]></dc:creator><pubDate>Fri, 19 Jan 2024 17:54:11 GMT</pubDate></item><item><title><![CDATA[Reply to M5Dial &amp; CAN using PlatformIO on Wed, 13 Dec 2023 22:13:02 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/65972">@samarkh</a></p>
<p dir="auto">these GPIOs look ok to me. Hmm, not sure why it doesn't work on M5Core2 though. Sorry.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/23035</link><guid isPermaLink="true">https://community.m5stack.com/post/23035</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 13 Dec 2023 22:13:02 GMT</pubDate></item><item><title><![CDATA[Reply to M5Dial &amp; CAN using PlatformIO on Wed, 13 Dec 2023 18:05:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4037">@felmue</a><br />
I used<br />
/* set CAN pins */<br />
// GROVE connector GPIO pins<br />
CAN_cfg.tx_pin_id = GPIO_NUM_32;  // Use this order only<br />
CAN_cfg.rx_pin_id = GPIO_NUM_33;</p>
<p dir="auto">and I'm able to see activity on the CAN bus using an oscilloscope.</p>
]]></description><link>https://community.m5stack.com/post/23030</link><guid isPermaLink="true">https://community.m5stack.com/post/23030</guid><dc:creator><![CDATA[samarkh]]></dc:creator><pubDate>Wed, 13 Dec 2023 18:05:06 GMT</pubDate></item><item><title><![CDATA[Reply to M5Dial &amp; CAN using PlatformIO on Wed, 13 Dec 2023 16:46:48 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/65972">@samarkh</a></p>
<p dir="auto">I assume you've adapted the TX and RX GPIOs for M5Core2 accordingly, yes?</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/23029</link><guid isPermaLink="true">https://community.m5stack.com/post/23029</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 13 Dec 2023 16:46:48 GMT</pubDate></item><item><title><![CDATA[Reply to M5Dial &amp; CAN using PlatformIO on Wed, 13 Dec 2023 10:57:33 GMT]]></title><description><![CDATA[<p dir="auto">As yet I have only got the M5Stack ATOMIC CANBus Base and CANBus Unit to work with the following code using Atom Lite &amp; Atom Matrix :-</p>
<p dir="auto">#include "M5Atom.h"<br />
#include &lt;ESP32CAN.h&gt;<br />
#include &lt;CAN_config.h&gt;</p>
<p dir="auto">#define CAN_BASE      // Remove to use external CAN bus via Grove cable<br />
//#define CAN_RECIEVER  // Remove to make sender</p>
<p dir="auto">#define CAN_MSG_ID 0x001</p>
<p dir="auto">CAN_device_t CAN_cfg;              // CAN Config.<br />
unsigned long previousMillis = 0;  // will store last time a CAN Message was sent                                // send.  将存储上次发送CAN消息的时间。<br />
const int interval = 80;           // interval at which send CAN Messages (milliseconds).</p>
<p dir="auto">const int rx_queue_size = 10;  // Receive Queue size.<br />
int LedNumberCount      = 0;<br />
int waitCANData         = 0;</p>
<p dir="auto">uint8_t msgcnt = 0;</p>
<p dir="auto">void setup()<br />
{<br />
M5.begin(true, true, true);<br />
Serial.println("Atom Install OK....");<br />
M5.dis.fillpix(CRGB(100, 0, 0));          //Fill the LED Matrix RED<br />
delay(2000);</p>
<p dir="auto">#ifdef CAN_BASE   // CAN base is used<br />
//default<br />
CAN_cfg.tx_pin_id = GPIO_NUM_22;<br />
CAN_cfg.rx_pin_id = GPIO_NUM_19;</p>
<p dir="auto">#else<br />
// Grove<br />
CAN_cfg.tx_pin_id = GPIO_NUM_26;<br />
CAN_cfg.rx_pin_id = GPIO_NUM_32;<br />
#endif</p>
<pre><code>CAN_cfg.speed = CAN_SPEED_500KBPS;

CAN_cfg.rx_queue  = xQueueCreate(rx_queue_size, sizeof(CAN_frame_t));

ESP32Can.CANInit();
Serial.println("CAN Install");
M5.dis.fillpix(CRGB(0, 100, 0));  //Fill the LED Matrix GREEN
</code></pre>
<p dir="auto">M5.dis.fillpix(CRGB(HUE_GREEN));  //Fill the LED Matrix GREEN<br />
#ifdef CAN_RECIEVER<br />
Serial.println("Set as RECIEVER");<br />
#else<br />
Serial.println("Set as SENDER");<br />
#endif<br />
}</p>
<p dir="auto">void loop()<br />
{<br />
unsigned long currentMillis = millis();</p>
<p dir="auto">#ifdef CAN_RECIEVER<br />
// recieve CAN Message<br />
CAN_frame_t rx_frame;</p>
<pre><code>if (xQueueReceive(CAN_cfg.rx_queue, &amp;rx_frame, 3 * portTICK_PERIOD_MS) ==  pdTRUE) 
{
    if (rx_frame.FIR.B.FF == CAN_frame_std) 
    {
        Serial.printf("New standard frame");
    } 
    else
    {
        Serial.printf("New extended frame");
    }

    if (rx_frame.FIR.B.RTR == CAN_RTR) 
    {
        Serial.printf(" RTR from 0x%08X, DLC %d\r\n", rx_frame.MsgID, rx_frame.FIR.B.DLC);
    }
    else
    {
        Serial.printf(" from 0x%08X, DLC %d, Data ", rx_frame.MsgID, rx_frame.FIR.B.DLC);
        for (int i = 0; i &lt; rx_frame.FIR.B.DLC; i++) 
        {
            Serial.printf("0x%02X ", rx_frame.data.u8[i]);
        }
        Serial.printf("\n");
        if (rx_frame.data.u8[0] == 0x01) 
        {
            CAN_frame_t tx_frame;
            tx_frame.FIR.B.FF   = CAN_frame_std;
            tx_frame.MsgID      = CAN_MSG_ID;
            tx_frame.FIR.B.DLC  = 8;
            tx_frame.data.u8[0] = 0x02;
            tx_frame.data.u8[1] = rx_frame.data.u8[1];
            tx_frame.data.u8[2] = 0x00;
            tx_frame.data.u8[3] = 0x00;
            tx_frame.data.u8[4] = 0x00;
            tx_frame.data.u8[5] = 0x00;
            tx_frame.data.u8[6] = 0x00;
            tx_frame.data.u8[7] = 0x00;
            ESP32Can.CANWriteFrame(&amp;tx_frame);
        }
    }
}
</code></pre>
<p dir="auto">#else<br />
// Send CAN Message<br />
if (currentMillis - previousMillis &gt;= interval)<br />
{<br />
// ESP32Can.CANInit();<br />
previousMillis = currentMillis;<br />
CAN_frame_t tx_frame;<br />
tx_frame.FIR.B.FF   = CAN_frame_std;<br />
tx_frame.MsgID      = CAN_MSG_ID;<br />
tx_frame.FIR.B.DLC  = 8;<br />
tx_frame.data.u8[0] = 0x01;<br />
tx_frame.data.u8[1] = msgcnt;<br />
tx_frame.data.u8[2] = 0x00;<br />
tx_frame.data.u8[3] = 0x00;<br />
tx_frame.data.u8[4] = 0x00;<br />
tx_frame.data.u8[5] = 0x00;<br />
tx_frame.data.u8[6] = 0x00;<br />
tx_frame.data.u8[7] = 0x00;</p>
<pre><code>    ESP32Can.CANWriteFrame(&amp;tx_frame);
    // ESP32Can.CANStop();
    msgcnt++;
    if (msgcnt &gt; 29) 
    {
        msgcnt = 0;
    }
}

CAN_frame_t rx_frame;

if (xQueueReceive(CAN_cfg.rx_queue, &amp;rx_frame, 3 * portTICK_PERIOD_MS) == pdTRUE) 
{
    if (rx_frame.FIR.B.FF == CAN_frame_std) 
    {
        Serial.printf("New standard frame");
    } 
    else 
    {
        Serial.printf("New extended frame");
    }

    if (rx_frame.FIR.B.RTR == CAN_RTR) 
    {
        Serial.printf(" RTR from 0x%08X, DLC %d\r\n", rx_frame.MsgID,
        rx_frame.FIR.B.DLC);
    } 
    else 
    {
        Serial.printf(" from 0x%08X, DLC %d, Data ", rx_frame.MsgID,
        rx_frame.FIR.B.DLC);
        for (int i = 0; i &lt; rx_frame.FIR.B.DLC; i++) 
        {
            Serial.printf("0x%02X ", rx_frame.data.u8[i]);
        }
        Serial.printf("\n");

        if (rx_frame.data.u8[0] == 0x02) 
        {
                if (rx_frame.data.u8[1] &lt; 25)
            {
                M5.dis.drawpix(rx_frame.data.u8[1], CRGB(100, 0, 0));
            } 
            else if (rx_frame.data.u8[1] &gt; 27) 
            {
                M5.dis.fillpix(CRGB(0, 0, 20));
            }
            waitCANData = 0;
        }
    }
}
</code></pre>
<p dir="auto">#endif<br />
// waitCANData<br />
M5.update();<br />
if (M5.Btn.isPressed())<br />
{<br />
M5.dis.clear();<br />
M5.dis.fillpix(CRGB(0, 100, 0));<br />
esp_restart();<br />
}<br />
delay(10);<br />
}</p>
<p dir="auto">when I modify it to work with the Core2, it compiles OK but no echo back. what am I missing?</p>
]]></description><link>https://community.m5stack.com/post/23027</link><guid isPermaLink="true">https://community.m5stack.com/post/23027</guid><dc:creator><![CDATA[samarkh]]></dc:creator><pubDate>Wed, 13 Dec 2023 10:57:33 GMT</pubDate></item><item><title><![CDATA[Reply to M5Dial &amp; CAN using PlatformIO on Wed, 13 Dec 2023 10:46:23 GMT]]></title><description><![CDATA[<p dir="auto">The solutions I found worked are<br />
For the M5Dial<br />
Platform.ini :-</p>
<p dir="auto">; PlatformIO Project Configuration File<br />
;<br />
;   Build options: build flags, source filter<br />
;   Upload options: custom upload port, speed and extra flags<br />
;   Library options: dependencies, extra library storages<br />
;   Advanced options: extra scripting<br />
;<br />
; Please visit documentation for the other options and examples<br />
; <a href="https://docs.platformio.org/page/projectconf.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.platformio.org/page/projectconf.html</a></p>
<p dir="auto">[env:m5stack-stamps3]<br />
platform = espressif32<br />
board = m5stack-stamps3<br />
framework = arduino<br />
lib_deps =<br />
m5stack/M5Dial@^1.0.2<br />
m5stack/M5Unified@^0.1.11<br />
m5stack/M5GFX@^0.1.11<br />
platform_packages = framework-arduinoespressif32@<a href="https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.14.zip" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.14.zip</a><br />
upload_speed = 1500000<br />
monitor_speed = 115200</p>
<p dir="auto">Start of code:</p>
<p dir="auto">/**</p>
<ul>
<li>@file encoder.ino</li>
<li>@author SeanKwok (<a href="mailto:shaoxiang@m5stack.com" target="_blank" rel="noopener noreferrer nofollow ugc">shaoxiang@m5stack.com</a>)</li>
<li><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/263918">@brief</a> M5Dial Encoder Test</li>
<li>@version 0.2</li>
<li>@date 2023-10-18</li>
<li></li>
<li></li>
<li>@Hardwares: M5Dial</li>
<li><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/280973">@Platform</a> Version: Arduino M5Stack Board Manager v2.0.7</li>
<li>@Dependent Library:</li>
<li>M5GFX: <a href="https://github.com/m5stack/M5GFX" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5GFX</a></li>
<li>M5Unified: <a href="https://github.com/m5stack/M5Unified" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Unified</a><br />
*/</li>
</ul>
<p dir="auto">#include "M5Dial.h"</p>
<p dir="auto">void setup()<br />
{<br />
auto cfg = M5.config();<br />
M5Dial.begin(cfg, true, false);<br />
......<br />
.....<br />
.....<br />
etc</p>
<p dir="auto">and for the M5 Core2<br />
Platformio.ini =<br />
; PlatformIO Project Configuration File<br />
;<br />
;   Build options: build flags, source filter<br />
;   Upload options: custom upload port, speed and extra flags<br />
;   Library options: dependencies, extra library storages<br />
;   Advanced options: extra scripting<br />
;<br />
; Please visit documentation for the other options and examples<br />
; <a href="https://docs.platformio.org/page/projectconf.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.platformio.org/page/projectconf.html</a></p>
<p dir="auto">[env:m5stack-core2]<br />
platform = espressif32<br />
board = m5stack-core2<br />
framework = arduino<br />
platform_packages =<br />
framework-arduinoespressif32@<a href="https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.14.zip" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.14.zip</a><br />
lib_deps =<br />
m5stack/M5Unified@^0.1.11</p>
<p dir="auto">upload_speed = 1500000<br />
monitor_speed = 115200</p>
<p dir="auto">and start of code:</p>
<p dir="auto">/*</p>
<ul>
<li>Minimum code to get a display on the</li>
<li>M5Stack Core2</li>
<li>Using PlatformIO and Arduino</li>
<li></li>
</ul>
<p dir="auto">*/<br />
#include &lt;Arduino.h&gt;<br />
#include &lt;M5Unified.h&gt;<br />
#include &lt;M5GFX.h&gt;</p>
<p dir="auto">void setup()<br />
{<br />
M5.begin();<br />
....<br />
etc</p>
<p dir="auto">and for the M5Stack Core3S</p>
<p dir="auto">Platformio.ini<br />
; PlatformIO Project Configuration File<br />
;<br />
;   Build options: build flags, source filter<br />
;   Upload options: custom upload port, speed and extra flags<br />
;   Library options: dependencies, extra library storages<br />
;   Advanced options: extra scripting<br />
;<br />
; Please visit documentation for the other options and examples<br />
; <a href="https://docs.platformio.org/page/projectconf.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.platformio.org/page/projectconf.html</a></p>
<p dir="auto">[env:m5stack-cores3]<br />
platform = espressif32<br />
board = m5stack-cores3<br />
framework = arduino<br />
lib_deps =<br />
tinyu-zhao/BMI270_Sensor@^0.0.1<br />
m5stack/M5CoreS3@^0.0.4<br />
m5stack/M5Unified@^0.1.11<br />
platform_packages =<br />
framework-arduinoespressif32@<a href="https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.14.zip" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.14.zip</a></p>
<p dir="auto">build_flags =<br />
-DESP32S3<br />
-DBOARD_HAS_PSRAM<br />
upload_speed = 1500000<br />
monitor_speed = 115200</p>
<p dir="auto">and code start<br />
/*</p>
<hr />
<ul>
<li>Copyright (c) 2023 by M5Stack</li>
<li>
<pre><code>             Equipped with M5CoreS3 sample source code
</code></pre>
</li>
<li>Visit for more information:</li>
<li><a href="https://docs.m5stack.com/en/core/CoreS3" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/core/CoreS3</a>  - Docs</li>
<li><a href="https://github.com/m5stack/M5CoreS3" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5CoreS3</a>      - GitHub</li>
<li></li>
<li>Describe: Hello World</li>
<li>Date: 2023/5/3</li>
</ul>
<hr />
<p dir="auto">*/</p>
<p dir="auto">#include &lt;Arduino.h&gt;<br />
#include &lt;M5CoreS3.h&gt;</p>
<p dir="auto">void setup()<br />
{<br />
M5.begin(true, true, false);  // Init M5CoreS3.<br />
...<br />
etc</p>
<p dir="auto">Yours Simon M</p>
]]></description><link>https://community.m5stack.com/post/23026</link><guid isPermaLink="true">https://community.m5stack.com/post/23026</guid><dc:creator><![CDATA[samarkh]]></dc:creator><pubDate>Wed, 13 Dec 2023 10:46:23 GMT</pubDate></item><item><title><![CDATA[Reply to M5Dial &amp; CAN using PlatformIO on Mon, 04 Dec 2023 19:01:11 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/65972">@samarkh</a></p>
<p dir="auto">which examples have you tried? Maybe this <a href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/twai.html#examples" target="_blank" rel="noopener noreferrer nofollow ugc">example</a> code can help?</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/22962</link><guid isPermaLink="true">https://community.m5stack.com/post/22962</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Mon, 04 Dec 2023 19:01:11 GMT</pubDate></item></channel></rss>