SoftwareSerial, how do I convert those projects to use the hardware serial on the M5?
-
Hello
I am a newbie trying to understand how to convert the sample grove code for their 125Khz RFID from a SoftwareSerial to be able to connect to the hardware red grove connector on the side of the M5 stack?
Sorry, another newbie question... I am a little confused as the module says grove serial port with TX & RX but the documentation on the grove port on the M5 seems to refer to SLA or SPI?
Also in general question... I see a lot of sample Arduino tutorial code that uses SoftwareSerial, how do I convert those projects to use the hardware serial on the M5?
Thank you for your help.
-
Hello @pipy71
On M5Stack (Fire, Gray, Basic) the red Groove port A is only usable for I2C communication. The reason is that the same GPIOs (21, 22) are used internally for I2C communication with the IP5306 and therefore cannot be reprogrammed to be used as serial port.
Please also check out Pin Map for red Groove Port A here.
For serial communication you'd need a M5GO Bottom (or Bottom2) which provides you with the blue Groove port C.
Thanks
Felix -
Hello,
I'm also trying to make the same RFID reader work with my ExtPort by using the port C and UART
But I cannot get any value from the reader.
Can somebody help me in this ?Here are the details of my setup.
Thank you very much
Regards -
Regarding the RFID module, the Grove connector on the M5Stack provides serial communication, which means you can use either a SoftwareSerial or the hardware serial to communicate with the module. The SLA and SPI interfaces are different types of communication protocols, so they are not relevant in this case.
To use the hardware serial on the M5Stack, you can simply use the standard Serial library in your Arduino code instead of the SoftwareSerial library. The hardware serial on the M5Stack is available on pins 1 (TX) and 3 (RX) of the Grove connector, so you need to connect the RFID module's TX pin to the M5Stack's RX pin and vice versa.
Here's an example code to get you started with using the hardware serial on the M5Stack:
#include <M5Stack.h>void setup() {
M5.begin();
Serial.begin(9600);
}void loop() {
if (Serial.available() > 0) {
// read data from serial and process it
// ...
}
}In this example, we initialize the M5Stack library and then start the hardware serial communication with a baud rate of 9600. In the loop() function, we check if there is any data available on the serial port, and if there is, we can read it and process it accordingly.
I hope this helps! Let me know if you have any more questions.