@gavin67890 In M5Tough, there is an external board called M5Tough EXT board in which we connect the 24VDC supply. This 24VDC supply is then converted to 5VDC and then it goes to ESP32 through the 5VDC pin on the main board. If i dont make the output_power = false, then the 5VDC pin stays high on the main board and also on the EXT board (from external supply) which does not allow ESP32 to switch on. So if we make it false, then the main board 5VDC output becomes low and then it can be driven by the external supply from the M5 Tough EXT board. This is the only way to power up the M5Tough using 24VDC supply. I am not sure about core2 though. Now i figured that in this scenario, the UART doesnt get disabled. It keeps working, but the sensor communication doesnt work. To my surprise, if i disconnect the sensor while the power is on and reconnect it, the sensor start communicating. I feel that somehow, ESP32 doesnt like that the sensor is powered up before the ESP32 is initialized as both the sensor and ESP32 are getting powered by the same external 5VDC supply. Now the only option for me is to setup a GPIO pin to drive a mosfet which would then power up the Sensor after ESP32 is initialized. But i feel there must be a much simpler way to do this via programming.
Posts made by samkhan2050
-
RE: M5 Tough UART Communication
-
RE: M5 Tough UART Communication
@felmue and @gavin67890. Thanks for trying to help us out. I am glad to inform that the serial communication worked. Somehow, its not Serial2, but Serial1 which is UART at pin 13 and 14 of M5Tough. Additionally, M5Tough.h library didnt work, we had to use M5Unified. Everything is working fine now except, one issue. Till now we were running the M5Tough using the USB cable. FOr it to be used in our application, we need to provide it with 24DC power supply. In order to enable 24VDC power supply input for M5Tough, we need to add the following code in the setup:
auto cfg = M5.config();
// MBus power input
cfg.output_power = false;
M5.begin(cfg);The issue is that when i do that my UART connection stops working. It seems as if cfg.output_power = false disables the UART port or something. What could be the possible reason? Any guesses?
-
RE: M5 Tough UART Communication
@felmue I am @Alee35's colleague. I connected the Vcc(5VDC) and the Gnd pins only and measured the voltage on the TX and RX pins of the VLD-1 Eval board. On Tx pin there is no voltage, but on the RX pin i am getting 3.3V. Is it becuase the sensor waits for the INIT command before transmitting the data on UART? In any case i switched the wiring and the sensor is still non responsive. I double checked for loose wiring and for any other wiring issues but everything seems to be in order. I tested the sensor again by connecting it to serial terminal and it is giving correct output. I also checked the voltage on pin 13 and 14 of M5, pin 13 which is RX has 0 V and pin 14 which is Tx has 3.3V. We tested with ESP32 programming via PlatformIO with multiple permutations and combinations on serial ports, pin nos etc, but nothing seems to work. I also programmed another new M5Tough with UiFlow but the result is same. See below a screenshot of the UIFlow code in Python. We are completely stuck and are surprised that such a simple thing isnt working. Pls advise if you can think of something which might help.
import os, sys, io
import M5
from M5 import *
from hardware import *label0 = None
#uart2 = Nonedef setup():
global label0, uart2uart2 = UART(2, baudrate=115200, bits=8, parity=None, stop=1, tx=9, rx=10, rts=-1, cts=-1, txbuf=256, rxbuf=256, timeout=0, timeout_char=0, invert=0, flow=0)
M5.begin()
Widgets.fillScreen(0x222222)
label0 = Widgets.Label("Text", 152, 96, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)uart2.init(baudrate=115200, bits=8, parity=0, stop=1, tx=32, rx=33, rts=-1, cts=-1, txbuf=256, rxbuf=256, timeout=0, timeout_char=0, invert=0, flow=0)
uart2.write('I')
uart2.write('N')
uart2.write('I')
uart2.write('T')
if uart2.read(1):
label0.setText(str(uart2.read(10)))def loop():
global label0, uart2
passif 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") -
Garbage Values shown in Serial Monitor
Hi, I am new to M5 Atom lite. I programmed it with the following code to test its functionality, but i am getting garbage values on the serial monitor. I tried changing the serial monitor to all the baud rates available including 9600 and 115200, but no success.
#include "M5Atom.h"
void setup(){
M5.begin(true, true, true); // Clear the serial port buffer and set the serial port baud rate to 115200. Initialize I2C. Initialize the LED matrix
}void loop(){
M5.update(); //You need to add m5.update () to read the state of the key, see System for details
if (M5.Btn.isPressed()) { //If the button is pressed
Serial.println("Button is pressed.");
}
delay(20);
}