How to read HLK-LD303 24ghz sensor data using arduino

Hi
I am trying to use the digital signal pin 2 , pin 3 of the arduino uno to connect the TX RX pins of the HLK-LD303 module.
And HLK-LD303 module output signal format eg: 55 A5 0A D3 00 58 00 01 01 4C 01 01 7F
How can I read the signal output by the HLK-LD303 module from the arduino uno, and then display the format like
eg: 55 A5 0A D3 00 58 00 01 01 4C 01 01 7F?

You could use Software Serial to receive the data, and
Serial.print(data, HEX); to display the bytes on the serial monitor in hexadecimal format.

Hi
Arduino uno digital pin 2, pin 3, respectively Rx, Tx, concatenate with Tx, Rx of HLK-LD303 to display bytes on serial monitor in hexadecimal format.
But the result is either 1 or 0.
Am I missing any steps?
Below is my current code.

void setup() {
// put your setup code here, to run once:

Serial.begin(115200);
Serial.println("Readly");
pinMode(2,INPUT);// Rx
pinMode(3,OUTPUT);// Tx
}

void loop() {
// put your main code here, to run repeatedly:

char buffer;
buffer= digitalRead(2);

Serial.println(buffer,HEX);
delay(200);
}

digitalRead() just returns the instantaneous HIGH or LOW (1 or 0) state of the port pin.

Arduino uno digital pin 2, pin 3, respectively Rx, Tx, concatenate with Tx, Rx of HLK-LD303

Use the SoftwareSerial library and assign pin 2 to RX, pin 3 to TX. Here is an example that reads a GPS module and prints the ASCII characters to the serial monitor.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); //GPS (RX, TX) check correct pin assignments and baud rate

void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
  Serial.println("GPS start");
}

void loop() {
  while (mySerial.available()) {
    Serial.write(mySerial.read());
  }
}

Hi
I'm new to arduino and I don't know much about some programming parts.
I try to use your method, change the Tx, Rx pins to 10, 11, and connect with HLK-LD303 in series, display the bytes on the serial monitor in hexadecimal format.
And the result I see on the string monitor, the output is in a different format than I need
⸮55
⸮A
⸮0
0
0
0
0
D7
UA5
But the signal I need to output is like eg 55 A5 0A D3 00 58 00 01 01 4C 01 01 7F
What part am I doing wrong?
Below is my code
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);
void setup() {
// put your setup code here, to run once:
mySerial.begin(115200);
Serial.begin(115200);
Serial.println("Readly");

}

void loop() {
// put your main code here, to run repeatedly:

while (mySerial.available()) {
Serial.write(mySerial.read());
Serial.println(mySerial.read(),HEX);
}
delay(200);
}

Please use code tags when posting code.

Delete the useless delay(200), and this line, which writes unprintable characters to the screen.

Serial.write(mySerial.read());

Hi
I don't understand what you mean by 'write unprintable characters to this line of the screen'
Can you give an example?

The backwards question marks you see are an example of what you get when sending unprintable binary data to the serial monitor (using Serial.write()).

HEX is a human readable representation of binary data. ASCII data are usually, but not always, printable characters, like '2', 'A', 'a', '/', etc.

Hi
The signal output by the HLK-LD303 module I use is in hexadecimal, the output format is eg 55 A5 0A D3 00 58 00 01 01 4C 01 01 7F.
But the result displayed now is obviously wrong. Is it related to the use of Serial.write())?

Is there any other way to read this format?

All data are binary, and the module is sending binary data.

The 55 in the first line of your printout is exactly what you expect, and suggests that the program will work if you follow instructions to get rid of the delay() and the serial.write(). I take it that you have not done that.

⸮55

Note: at present, the program won't print leading zeros. It will print A instead of 0A.

I have deleted the delay used in the program.
What do you mean, I don't use the serial.write() function, but use other methods instead?
I currently change the code to the following

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);
void setup() {
  // put your setup code here, to run once:
  mySerial.begin(115200);
  Serial.begin(115200);
  Serial.println("Readly");
 
}

void loop() {
  // put your main code here, to run repeatedly:
  
 while (mySerial.available()) {
    //char a=Serial.write(mySerial.read());
    //Serial.print(mySerial.read(),HEX);
    char a=mySerial.read();
     Serial.print(a,HEX);
  }                   
  
}

Way too fast for SoftwareSerial.
Leo..

Hi
I am reading data from a sensor and the output signal is hexadecimal.
I am currently using serial.print(b[i].HEX); this function to display, how can I convert the displayed content to decimal?
Below is my code

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);
unsigned char a;
unsigned char b[20];
unsigned char i,r;
void setup() {
  // put your setup code here, to run once:
  mySerial.begin(115200);
  Serial.begin(115200);
  Serial.println("Readly");
 
}

void loop() {
  // put your main code here, to run repeatedly:
 
 while (mySerial.available()) {
    //char a=Serial.write(mySerial.read());
    //Serial.print(mySerial.read(),HEX);
     
     
     for (int j=0;j<20;j++)
     {
      a=mySerial.read();
       b[i]=a;       
      Serial.print(b[i],HEX);
      Serial.print(" ");
       
     } 
     Serial.print("\n");
 
    
  }    

 
            
  
}

What do you see when you remove the "HEX" from the Serial.print() line?

Please do not cross post. Moderator notified, continuation of How to read HLK-LD303 24ghz sensor data using arduino - #9 by fong3310

Display information as follows

85 165 10 211 0 12 0 1 7 44 0 0 23 255 255 255 255 255 255 255
85 165 10 211 0 13 0 1 14 39 0 0 26 255 255 255 255 255 255 255
85 165 10 211 0 14 0 1 13 188 0 0 175 255 255 255 255 255 255 255
85 165 10 211 0 15 0 1 47 212 0 0 234 255 255 255 255 255 255 255
85 165 10 211 0 0 0 0 0 0 0 0 215 255 255 255 255 255 255 255
85 165 10 211 0 0 0 0 0 0 0 0 215 255 255 255 255 255 255 255
85 165 10 211 0 0 0 0 0 0 0 0 215 255 255 255 255 255 255 255
85 165 10 211 0 0 0 0 0 0 0 0 215 255 255 255 255 255 255 255
85 165 10 211 0 0 0 0 0 0 0 0 215 255 255 255 255 255 255 25

Understood, thanks
I will post the question in the original place

The correct choices are...

  • Do not crosspost.
  • If you do crosspost, ask a moderator to merge the threads. Flagging a post is a good way to communicate with the moderators.

Threads merged.

The output signal is binary data.

You need to carefully study the device data sheet to learn how to convert the binary data into useful, human readable information.

Post a link to that data sheet, and forum members may be able to help you interpret it.

Below is the datasheet for this sensor
HLK-LD303 24Ghz
HLK-LD303 24Ghz