Interfacing seeed esp32c3 with radar sensor

Hello
I should interface Seeed sensor Module MR24HPB1 ,Human Stationary Presence Radar Sensor with ESP32 C3 board
#include <radar.h>

#ifdef AVR

** #include <SoftwareSerial.h>**

** SoftwareSerial SSerial(2, 3); // RX, TX**

** #define Serial1 SSerial**

#endif

#define MESSAGE_HEAD 0x55

int data[14] = {0};

int i = 0;

int Msg;

int Situation_action;

radar RADAR;

void setup()

{

** Serial1.begin(115200);**

** Serial.begin(115200);**

** Serial.println(“Readly”);**

}

void Bodysign_judgment(int ad1, int ad2, int ad3, int ad4, int ad5){

** float s;**

** s = RADAR.Bodysign_val(ad1, ad2, ad3, ad4, ad5);**

** if(s > 1.5 && s < 35){**

** Serial.println(“SOMEBODY STOP”);**

** }**

** else if(s < 1.5){**

** Serial.println(“NOBODY”);**

** }**

** else if(s > 35){**

** Serial.println(“SOMEBODY MOVE”);**

** }**

}

void loop()

{

** Serial.println(“Readly 40”);**

** Msg = Serial1.read();**

** delay(1000);**

** delay(1000);**

** if(Msg == MESSAGE_HEAD){**

** Serial.println(“Readly 47”);**

** for(i = 0; i<14; i++){**

** data[i] = Msg; **

** Msg = Serial1.read();**

** Serial.println(“Readly 46”);**

** if (Msg == MESSAGE_HEAD){**

** RADAR.Situation_judgment(data[5], data[6], data[7], data[8], data[9]); //雷达数据解码**

** if (Situation_action = 1){**

** Serial.println(“radar said nobody”);**

** }**

** if (Situation_action = 2){**

** Serial.println(“radar said somebody move”);**

** }**

** if (Situation_action = 3){**

** Serial.println(“radar said somebody stop”);**

** }**

** if (Situation_action = 4){**

** Serial.println(“radar said no move”);**

** }**

** if (Situation_action = 5){**

** Serial.println(“radar said somebody close”);**

** }**

** if (Situation_action = 6){**

** Serial.println(“radar said somebody away”);**

** } **

** continue;**

** }**

** delay(25);**

** }**

** }**

This library i will be using GitHub - Seeed-Studio/Seeed_Arduino_24GHz_Radar_Sensor
I found issues
ESP-ROM:esp32c3-api1-20210207

i think all those ** will cause some sort of problem…

Hi there,
Yea I wouldn’t use Software Serial for that, also speed either, 9600 is most standard.
It’s the second Serial port (hardware) why not jut use Serial1 and Serial both hardware ports are available.

/*
  Multiple Serial test (works and tested on Xiao ESP32C3)

  Receives from the main serial port, sends to the others.
  Receives from serial port 1, sends to the main serial (Serial 0).
*/

void setup() {
  Serial1.begin(9600);
  delay(1000);//relax...Get Ready for serial port
  //Serial1.begin(9600,SERIAL_8N1, 8,7); //int8_t rxPin=8(GPIO20), int8_t txPin=7(GPIO21) 
  Serial.begin(9600);
  while (!Serial);
  delay(1000);//relax...Get Ready for serial port
  Serial.println();
  Serial.println("Power ON \n ");  // Let's BEGIN!!
Serial1.print("\r");
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.write(inByte);
  }
}

HTH
GL :slight_smile: PJ

@PJ_Glasso That code give no output

Hi there,
Yea you need to change the pins to 7 & 6 respectively… try that or use the Soft Serial method , Have a look at the Xiao connected with the GPS demo I posted on here for the code.
HTH
GL :slight_smile: PJ

Works like a champ!

https://forum.seeedstudio.com/t/reading-distance/275885/6?u=pj_glasso

HTH
GL :slight_smile: PJ