<?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 UART Write not sending data]]></title><description><![CDATA[<p dir="auto">The following M5Dial/UIFlow 2.0 code is able to receive data from Arduino Uno r4 wifi, but i cannot get data to Arduino.  Using basic example Arduino code that works on other devices.  Am i missing something?  Tried every write command in UART list.</p>
<pre><code>import os, sys, io
import M5
from M5 import *
from hardware import *



label0 = None
label1 = None
label2 = None
rotary = None
uart1 = None


def btnA_wasClicked_event(state):
  global label0, label1, label2, rotary, uart1
  rotary.reset_rotary_value()
  label0.setText(str(rotary.get_rotary_value()))
  label1.setText(str(rotary.get_rotary_value()))
  print(uart1.read(1)[0])
  uart1.write(bytes([1]))


def btnA_wasHold_event(state):
  global label0, label1, label2, rotary, uart1
  label1.setText(str('hold'))
  label2.setText(str('Label'))


def setup():
  global label0, label1, label2, rotary, uart1

  M5.begin()
  Widgets.fillScreen(0x222222)
  label0 = Widgets.Label("0", 96, 80, 1.0, 0xffa000, 0x222222, Widgets.FONTS.DejaVu72)
  label1 = Widgets.Label("label1", 88, 158, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
  label2 = Widgets.Label("label2", -21, 114, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu9)

  BtnA.setCallback(type=BtnA.CB_TYPE.WAS_CLICKED, cb=btnA_wasClicked_event)
  BtnA.setCallback(type=BtnA.CB_TYPE.WAS_HOLD, cb=btnA_wasHold_event)

  label1.setColor(0xcc33cc, 0x33ff33)
  rotary = Rotary()
  uart1 = UART(1, baudrate=9600, bits=8, parity=None, stop=1, tx=13, rx=15, txbuf=256, rxbuf=256, timeout=0, timeout_char=0, invert=0, flow=0)


def loop():
  global label0, label1, label2, rotary, uart1
  M5.update()
  if rotary.get_rotary_status():
    label0.setText(str(rotary.get_rotary_value()))


if __name__ == '__main__':
  try:
    setup()
    while True:
      loop()
  except (Exception, KeyboardInterrupt) as e:
    try:
      from utility import print_error_msg
      print_error_msg(e)
    except ImportError:
      print("please update to latest firmware")
</code></pre>
<p dir="auto">Arduino Code:</p>
<pre><code>int incomingByte = 0; // for incoming serial data

void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial1.begin(9600);
}

void loop() {
  // reply only when you receive data:
  if (Serial1.available() &gt; 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial1.print("I received: ");
    Serial1.println(incomingByte, DEC);
  }
}
</code></pre>
]]></description><link>https://community.m5stack.com/topic/6570/m5dial-uart-write-not-sending-data</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 23:25:11 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6570.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Jun 2024 13:48:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5Dial UART Write not sending data on Tue, 25 Jun 2024 15:45:11 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/116438">@xbr11332003</a></p>
<p dir="auto">have you tried to send the data with trailing CR LF? E.g. <code>uart1.write('hallo\r\n')</code>? Works for me.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/25677</link><guid isPermaLink="true">https://community.m5stack.com/post/25677</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Tue, 25 Jun 2024 15:45:11 GMT</pubDate></item><item><title><![CDATA[Reply to M5Dial UART Write not sending data on Mon, 24 Jun 2024 03:04:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/116438">@xbr11332003</a><br />
Tried every UART write command and arduino is not receiving data.<br />
Serial monitor on Arduino prints -1.   Again, I can send data to m5dial but arduino does not receive.  Other arduino boards work flawlessly.  Please help felix.</p>
]]></description><link>https://community.m5stack.com/post/25663</link><guid isPermaLink="true">https://community.m5stack.com/post/25663</guid><dc:creator><![CDATA[xbr11332003]]></dc:creator><pubDate>Mon, 24 Jun 2024 03:04:13 GMT</pubDate></item></channel></rss>