Collecting and displaying serial data from a radar module

Hi all,
So I recently purchased a 24GHz human presence radar module from micradar that has an onboard MCU that processes the echo data and packages it before output via a UART port. What I want to do is connect the radar module to the arduino Uno's Tx and Rx pins and get the arduino to display the received packets on the serial monitor. The data from the radar module is such that the received stream always begins with the 2 bytes 0x53 0x59 and ends with the 2 bytes 0x54 0x43. The UART data stream could vary to max of 14bytes. Below is the piece of code i wrote to collect this data via an arduino Uno and display it on the serial monitor;

const unsigned int PACK_SIZE = 14;
int inByte1;
int inByte2;
unsigned int recvdByte = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0){
    int pack[PACK_SIZE];
    
  
    inByte1 = Serial.read();
    inByte2 = Serial.read();

    if(inByte1 != 84 && inByte2 != 67){
      pack[recvdByte] = inByte1;
      pack[recvdByte+1] = inByte2;
      recvdByte += 2;
    }
    else{
      pack[recvdByte] = inByte1;
      pack[recvdByte+1] = inByte2;
      recvdByte = 0;
    }
    for(int i = 0; i < PACK_SIZE; i++)
    {
      Serial.print(pack[i],HEX);
    }
    Serial.println();
  }
}

Unfortunately, I get no transmission over the UART ports and can't figure out what is wrong with my code.

Which Arduino board are you using ?
Are you sure that the output from the sensor is not at RS232 levels ?
How is the sensor connected to the Arduino ?
Have the two devices got a common GND connection ?

I'm using an arduino Uno
The sensor's output is TTL
I hooked the 5V line of the sensor to one of the arduino 5V pins and the GND line of the sensor to one of the arduino GND and then the Rx line of sensor to Tx line(Pin 1) of arduino and Tx line of sensor Rx (Pin 0)line of arduino.
If I may add the main issue lies in parsing the data accordingly and displaying it. I have verified and there is no issue in communication between the sensor and the arduino UNO

Don't use pins 0 and 1 of the Uno as they are used by the Serial monitor and to upload code.

You could create a second serial interface by using SoftwareSerial on 2 other pins, but that will not run reliably, if at all, at 115200 baud. Have you got control of the baud rate of the sensor ? In fact, do you even know what its baud rate is ?

As an alternative, use an Arduino with a second (or more) hardware serial interface

I do understand that pins 0 and 1 are used during code upload, so I have the sensor hooked up only after uploading the code, and it works fine when I display only individual bytes. The main issue occurs when I try parsing and displaying the data using the code in the original post and it doesn't work.
Sorry for not specifying earlier but the baud rate of the sensor's UART interface is set at 115200 by the manufacturer and i have no control over it. Thanks for your suggestions!

Hello obatala
You may start doing a data logging using a terminal program to check the protocol.

You can't connect two devices to the same UART at the same time and expect them to work. Uno board has a USB-UART adapter chip which is permanently connected to pins 0, 1. If you connect another device to those same pins, the signals from the two devices will be in conflict.

You can use software serial on a different pair of Uno pins, but check that the software serial library you select supports 115200.

A better solution would be an Arduino with a second UART, such as a Pro Micro.

Thanks alot UKHeliBob,
Indeed though inconsistent with expectations a few times, the SoftwareSerial helps alot.

Thanks @PaulRB
Did not have another board with multiple UART ports so tried the SoftwareSerial and it works quite well

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.