I'm working on a project, and I purchased a 24 GHz "Human existence/presence" mm Wave sensor from micradar, the R24DVD1. The output of the module is serial data which varies in length and is of the structure shown below;
The Data element of the stream could get as large as 5bytes and as show each package ends with a 0x54 0x43. My intention is to have my Arduino Uno read the data for further processing. Since I use the Arduino Uno which has only one physical serial port, I felt using it to read the sensor data could prove problematic since the pc is equally connected to that serial line via USB. So I decided to use the SoftwareSerial to read the data from the senor then forward it to the pc and I wrote the following code for that;
#include <SoftwareSerial.h>
const int txpin = 3;
int const rxpin = 2;
SoftwareSerial mySerial(rxpin,txpin);
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);
mySerial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
if (mySerial.available() > 0){
int pack[PACK_SIZE];
inByte1 = mySerial.read();
inByte2 = mySerial.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();
}
}
I would like to know if my thought process in reading and parsing the data is correct because the output is quite inconsistent to what I expect