Serial communication does not work in my special case

I'm using a "SEIDAR" radar sensor. It has an UART (Rx/Tx) interface and sends measured speed data over on Tx automatically when the target object moves. It is great up to this. But because of any special reason I want to read the configuration of the sensor. That can be do to send a special "packet" (a sequence of bytes) to the sensor. (0x7e, 0x7e, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xef )
If I connect to the sensor with a simple USB/UART board and send the configuration query packet from my PC it is working well and sends back the configuration packet as needed.
BUT if I connect the sensor to my ARDUINO UNO UART (Rx/Tx) and send the config query packet then no answer from the sensor.

I have compared the two cases (1. when data comes from the PC and 2. when the data comes from UNO) by a serial port sniffer and with oscilloscope too and the two byte stream seems to be identical.

What the problem can be?

on UNO I use thsi to send and receive bytes:

packet[] = {
 0x7e, 0x7e, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xef  
};

void setup()
{
 Serial.begin(115200);
 delay(1000);
}

void loop()                                                                                                                                                                                                                                                                                  
{
 //config request;
  for(int i=0;i<16;i++){
    Serial.write(packet[i]);
 }
 while (Serial.available() > 0 ) {
   int rb = Serial.read();
   Serial.print(rb,HEX);
 }  
 delay(1000);
}```

I am guessing that you forgot to give a link to the technical data on the radar device.

Does the packet of bytes need to be terminated with a Carriage Return, a Linefeed or maybe both ?

Sorry, but I afraid I do not understand what you say. What "link" do you mean?

in the packet the start is 0x7e, 0x7e and the end is 0xef,0xef

The link to the technical data on the device you are trying to talk to. Also know as a manual and a data sheet.
Paul

If I send exactly these 16 bytes from UNO no response from the sensor. :roll_eyes:

How do you know?

Can we trust the code that you posted as it does not compile ?

I am checking the sensor's Tx pin by oscilloscope and also I check the port with the serial sniffer.
Next to these if something would come from sensor my code would write it out to the serial monitor (see my code part given above)

Do you mean the code that does not compile ?

I can't see how. It looks like you're using the (only) serial port to communicate with the sensor. Are you somehow echoing that to the serial monitor?

Sorry. As I copied my code missed "byte"

byte packet[] = {
 0x7e, 0x7e, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xef  
};
Of course my code is compiled well

this way:

 while (Serial.available() > 0 ) {
    int rb = Serial.read();
    Serial.print(rb,HEX);
    digitalWrite(13, HIGH);
  }  

ahhh, this "SEIDAR" is a Chinese senzor with minimal documentation...

Please post what you have, however limited

SYD-K1 Communication protocol.pdf (121,4 kB)

On a Arduino Uno, the "Serial" is pin 0 and 1. They are used to upload a sketch and for the Serial Monitor.

So my questions are: Is the radar sensor also receiving the same data when the Arduino IDE uploads a sketch ? How do you know that you are reading data from the radar sensor instead of the Serial Monitor on the computer ? When you have received something, why do you send it back as HEX to the radar sensor.

I do not see any where in the thread where you are using a RS-485 adapter for your Arduino.
The document states: "RS485 communication interface is adopted". What are you using?

Paul

1 Like