C1001 60GHz mmWave Indoor Fall Detection Sensor init error!!!
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
Hi,
Here, I encountered an initialization error with the C1001 60GHz mmWave sensor when using it with the Arduino MKR WiFi 1010 and ESP-WROOM-32, the output and code in below.
serial monitor output:
========================
init error!!!
Initialization successful
Start switching work mode
error!!!
error!!!
error!!!
error!!!
error!!!
Code:
============================
/**
* @file sleep.ino
* @brief This is an example of the C1001 mmWave Human Detection Sensor detecting the presence of people and their respiration and heart rates.
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @license The MIT License (MIT)
* @author [tangjie]([email protected])
* @version V1.0
* @date 2024-06-03
* @url https://github.com/DFRobot/DFRobot_HumanDetection
*/
#include "DFRobot_HumanDetection.h"
// Declare hu as a global variable so it's accessible in all functions
DFRobot_HumanDetection hu(&Serial1);
void setup() {
Serial.begin(115200);
// Begin Serial1 with TX = Pin 14, RX = Pin 13
Serial1.begin(115200);
Serial.println("Start initialization");
// Attempt to initialize the sensor
while (hu.begin() != 0) {
Serial.println("init error!!!");
delay(1000);
}
Serial.println("Initialization successful");
Serial.println("Start switching work mode");
// Switch to sleep detection mode
while (hu.configWorkMode(hu.eSleepMode) != 0) {
Serial.println("error!!!");
delay(1000);
}
Serial.println("Work mode switch successful");
Serial.print("Current work mode:");
// Check and print the current work mode
switch (hu.getWorkMode()) {
case 1:
Serial.println("Fall detection mode");
break;
case 2:
Serial.println("Sleep detection mode");
break;
default:
Serial.println("Read error");
}
// Configure the LED and reset the sensor
hu.configLEDLight(hu.eHPLed, 1); // Set HP LED to ON
hu.sensorRet(); // Module reset
Serial.print("HP LED status:");
// Check and print the LED status
switch (hu.getLEDLightState(hu.eHPLed)) {
case 0:
Serial.println("Off");
break;
case 1:
Serial.println("On");
break;
default:
Serial.println("Read error");
}
Serial.println();
Serial.println();
}
void loop() {
Serial.print("Existing information:");
// Check and print if someone is present
switch (hu.smHumanData(hu.eHumanPresence)) {
case 0:
Serial.println("No one is present");
break;
case 1:
Serial.println("Someone is present");
break;
default:
Serial.println("Read error");
}
Serial.print("Motion information:");
// Check and print motion status
switch (hu.smHumanData(hu.eHumanMovement)) {
case 0:
Serial.println("None");
break;
case 1:
Serial.println("Still");
break;
case 2:
Serial.println("Active");
break;
default:
Serial.println("Read error");
}
// Print body movement parameters, respiration rate, and heart rate using print and println
Serial.print("Body movement parameters: ");
Serial.println(hu.smHumanData(hu.eHumanMovingRange));
Serial.print("Respiration rate: ");
Serial.println(hu.getBreatheValue());
Serial.print("Heart rate: ");
Serial.println(hu.getHeartRate());
Serial.println();
delay(1000);
}
The begin/init routine is rather simple, it reads a small amount of data off the serial port. Since you are using an ESP32,
#if defined(ESP32)
Serial1.begin(115200, SERIAL_8N1, /*rx =*/D3, /*tx =*/D2);
#else
Serial1.begin(115200);
#endif
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
Hit Submit before I was done, since you are using an ESP32, why not include the additional port setup parameters for the begin() function? I'm not sure what the defaults are for the ESP-WROOM-32's non-native UART pins. Browsing the various project examples I find these additional parameters included in all of them.
* https://wiki.dfrobot.com/SKU_SEN0623_C1001_mmWave_Human_Detection_Sensor#target_5
Also, the ESP-WROOM-32's native UART pins are GPIO16 and GPIO17, you could give them a try.
Lastly, are your RX and TX connected to the correct GPIOs on the ESP32? Are they crossed or directly connected?
I had similar issues until I soldered the connections and made sure it had enough power and it works as expected now.
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)