@xbr11332003
Tried every UART write command and arduino is not receiving data.
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.
X
Posts made by xbr11332003
-
RE: M5Dial UART Write not sending data
-
M5Dial UART Write not sending data
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.
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")
Arduino 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() > 0) { // read the incoming byte: incomingByte = Serial.read(); // say what you got: Serial1.print("I received: "); Serial1.println(incomingByte, DEC); } }