K-LD7 with Arduino uno


I want to connect K-LD7 radar to Arduino uno.
but I don't know what is my problem.... help me please.

this is a link to the datasheet of the K-LD7
-> [RF Beam] DataSheet_41. K-LD7 radar transceiver : CRAECA 판매 제품 각종 자료실

and this is my code

void setup() {
  Serial.begin(115200);
  mySerial.begin(115200);
}

void loop() {
  if (mySerial.available()) {
    byte header1 = mySerial.read();
    byte header2 = mySerial.read();

    if (header1 == 0x54 && header2 == 0x44) {
      byte distanceLSB = mySerial.read();
      byte distanceMSB = mySerial.read();
      uint16_t distance = (distanceMSB << 8) | distanceLSB;
      
      byte speedLSB = mySerial.read();
      byte speedMSB = mySerial.read();
      uint16_t speed = (speedMSB << 8) | speedLSB;
      
      byte angleLSB = mySerial.read();
      byte angleMSB = mySerial.read();
      uint16_t angle = (angleMSB << 8) | angleLSB;
      
      byte magnitudeLSB = mySerial.read();
      byte magnitudeMSB = mySerial.read();
      uint16_t magnitude = (magnitudeMSB << 8) | magnitudeLSB;
      

      Serial.print("Distance: ");
      Serial.print(distance / 100.0, 2);
      Serial.println("m");

      Serial.print("Speed: ");
      Serial.print(speed / 100.0, 2);
      Serial.println("m/s");

      Serial.print("Angle: ");
      Serial.print(angle / 100.0, 2);
      Serial.println("deg");

      Serial.print("Magnitude: ");
      Serial.print(magnitude / 100.0, 2);
      Serial.println("dB");
    }
  }
}

I moved your topic to an appropriate forum category @kokm.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Using the advice in the link given in reply #2, You will post a link to the datasheet of the K-LD7?

1 Like

Sorry, this is my first post.
Thank you for your advice.

@kokm welcome to the forum.

Software serial is not recommended for band rate of 115200.

The data sheet states the band rate is 34800, still perhaps a stretch for Softwareserail, but try it.

The data sheet says you are looking at 3.3 volt logic level serial communication, which means it can be wired to RX and TX on whatever serial port you rig up. You may need level translating for your 5 volt UNO.

Lastly it is not clear that the device will just send you information. At a glance, it seems like you may have to talk to it and ask it to tell you what you want to know.

Llastly lastly, it would be 100 percent easier to conduct initial experimentds with the device just using a terminal program and a USB to serial converter. no Arduino, no code to suspect. Of anything.

CoolTerm and PuTTY are two well-known and respectable terminal programs.

Get the device talking, worry about the UNO and all that other stuff until you can see it working.

HTH

a7

Thank to your help!! I will try it.

I've tried, but nothing appears on my serial monitor. Should I consider switching from the Arduino Uno to another option?

Tried what?

Please post the code and schematic from your experiment.

Show how all parts are connected, with attention to sources of power and how power gets to the parts that need it.

another option?

It's not an UNO problem. You could try a terminal emulator.

Did you read the data sheet to determine what you need to do to get values from the device?

a7

I connected pin 1 (GND) of the radar to GND, pin 3 (VCC) to 3.3v, pin 4 (RX) to pin 10, and pin 5 (TX) to pin 11. I tried running it in the Arduino IDE with the baud rate set to either 34800 or 38400 bps as advised, but nothing appeared.
I am using a USB cable compatible with the Arduino Uno for power supply, and it is powered from my laptop.
And this is my code.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);  // RX on pin 10, TX on pin 11

void setup() {
  Serial.begin(34800);
  mySerial.begin(34800);
}

void loop() {
  if (mySerial.available()) {
    byte header1 = mySerial.read();
    byte header2 = mySerial.read();

    if (header1 == 0x54 && header2 == 0x44) {
      byte distanceLSB = mySerial.read();
      byte distanceMSB = mySerial.read();
      uint16_t distance = (distanceMSB << 8) | distanceLSB;
      
      byte speedLSB = mySerial.read();
      byte speedMSB = mySerial.read();
      uint16_t speed = (speedMSB << 8) | speedLSB;
      
      byte angleLSB = mySerial.read();
      byte angleMSB = mySerial.read();
      uint16_t angle = (angleMSB << 8) | angleLSB;
      
      byte magnitudeLSB = mySerial.read();
      byte magnitudeMSB = mySerial.read();
      uint16_t magnitude = (magnitudeMSB << 8) | magnitudeLSB;
      

      Serial.print("Distance: ");
      Serial.print(distance / 100.0, 2);
      Serial.println("m");

      Serial.print("Speed: ");
      Serial.print(speed / 100.0, 2);
      Serial.println("m/s");

      Serial.print("Angle: ");
      Serial.print(angle / 100.0, 2);
      Serial.println("deg");

      Serial.print("Magnitude: ");
      Serial.print(magnitude / 100.0, 2);
      Serial.println("dB");
    }
  }
}

Looks like you are sure the thing is just gonna start talking at you.

Does the datasheet support this?

Try using serial printing to monitor you program flow, viz:

  if (mySerial.available()) {
    byte header1 = mySerial.read();

    Serial.print("I see "); Serial.println(header1, HEX);

It's 38400 for sure. I don't think you are getting any characters up from the device for one or more of the reasons I have suggested.

Did you need to worry about the 5 volt UNO vs. the 3.3 volt device attached?

What did you learn when you tried simply talking to it using a terminal emulator?

The default baud rate is 115200 (page 13 of data sheet)

You have the TX, RX pins connected wrong.
Should be this way:
Pin 4 (RX) -> UNO pin 11 (TX)
Pin 5 (TX) -> UNO pin 10 (RX)

Yes, THX. I did not find the nice data sheet with my tablet at the beach. Whatever I did find obvsly did not stick in my mind for three seconds or, less likely, was different. Or another device on another thread altogether. :expressionless:

115200 makes using Software serial a potential part of the problem.

It might be possible to configure it for a lower rate using a terminal emulator, or a real port on a different Arduino board.

TBH the data sheet does not make it clear, to me, that the default can be changed and made to survive a power cycle.

The data sheet also nicely illustrates the conversational nature of interacting with the device. It's not going to just start sending. Anything.

a7

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