Reading databurst by serial2
Posted: Fri Feb 14, 2020 6:07 pm
I am using a ESP32 WROOM-32 with arduino IDE 1.8.10 with
I am trying to read a databurst from a MT382, an electrical energy meter.
It is real burst 325 chars of 9600 bps.
Basically it is very simple:
Data does not come consecutive.
Connecting my logic analyzer:
one can see: Serial2.availble becomes active after about 100 chars.
trace 1: Incoming dat 9600 bps UART2
trace 2: Serial2.read activity
trace 3: Actual output 115200 bps UART0
Even when i send a few chars into UART2, Serial2.availble becomes active much later than the first incoming char.
I am trying to read a databurst from a MT382, an electrical energy meter.
It is real burst 325 chars of 9600 bps.
Basically it is very simple:
- #define RXD2 16
- #define TXD2 17
- #define Led_Catch 5
- {
- pinMode(Led_Catch, OUTPUT);
- // Setup serial ports
- Serial.begin(115200);
- Serial.println("Uart0 started 115200 bps.");
- Serial2.begin(9600, SERIAL_8N1, 16, 17);
- Serial.println("Uart2 started 9600 bps streight.");
- }
- void loop()
- {
- char c;
- while (Serial2.available() > 0)
- {
- digitalWrite(Led_Catch,HIGH);
- c = Serial2.read();
- Serial.print(c);
- digitalWrite(Led_Catch,LOW);
- }
- delay(1000);
- }
Connecting my logic analyzer:
one can see: Serial2.availble becomes active after about 100 chars.
trace 1: Incoming dat 9600 bps UART2
trace 2: Serial2.read activity
trace 3: Actual output 115200 bps UART0
Even when i send a few chars into UART2, Serial2.availble becomes active much later than the first incoming char.