SEN0609 (C4001) major issues

userHead Jason.Doe 2024-07-26 11:44:27 1521 Views1 Replies

So I recently purchased two SEN0609(c4001) mmwave sensors that I have been working with ESP32 WROOM dev devices to develop interfaces/code for. 

for reference, I have been using the github demo code and the communication document (https://dfimg.dfrobot.com/5ea64bf6cf1d8c7738ad2881/wiki/3b88a4ecd7d7f18918a0fa8ba1f970c6.pdf) for my development. 

 

My issue is with the sensor internal flash settings that store the baud speeds and how I can no longer reset the configuration back to 9600. 

bear with me as I try to run through the series of events that led me to where I am. 

 

The first sensor, working with Arduino IDE, I was writing, debugging and uploading new scripts to tweak the sensor to a usable speed/format for my home assistant integrations. The current stage of this development included a built in web server for the esp32 that shows the various data points from the sensor, along with some basic uart command buttons and settings to make simple adjustments. all working within the testing environment, but I was trying to perfect some data delays. No MQTT data was being sent anywhere and this was just to get the root code down. 

 

One updated firmware upload, which has no major changes other than a delay(100) added to a specific portion of the code, allowed the esp32 to boot up, acknowledge a connection to the sensor, but then stopped all reading from the sensor coming back through the arduino serial monitor. This was very strange because the sensor constantly (unless filtered via code), constantly put out distance or presence values via the serial. (something like DHD or DPH or whatever, followed by a series of numbers).

Nothing. racked my brain to figure this out, finally started fresh with brand new ESP32 and brand new SEN0609 sensor. ran SAME code that “broke” the sensor last time, this time working perfectly. So I continued my development. 

 

Fast forward a bit, I decided to run a very very simple program that would allow to me test some of the commands listed in the pdf file provided by the company (communications protocols) to see how the (SECOND) sensor reacted to varies commands (IE setRunApp, sensorStop getTrigRange, ETC), all executed with success and proper responses. Via the serial monitor, the commands were sent in whole, “IE: Sent: sensorStop”.

Then, like a cave man with the IQ of 12, I sent the commands, “sensorStop, getUart, setUart 4800, saveConfig, resetSystem 0”

This wrote the new uart setting to the flash memory of the sensor and now the ESP32 can not send new commands to the sensor to change mode or anything else. 

the line in Arduino that addressed the pins was this: sensorSerial.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN);. In order for the ESP32 to read the sensor data at all, I have to change the 9600 to 4800. 

But, no matter how I send the command to stop the sensor, or reset the config, etc, the sensor will not receieve the full command, it only takes it in 2 or 3 characters at a time. Here is an example of how the logs reads my attempt with any commands:
05:39:45.709 -> Sent: sensorStop
05:39:48.702 -> Enter commands to send to the sensor:
05:39:48.702 -> Received: s
05:39:48.702 -> Received: Error
05:39:48.702 -> Received: DFRobot:/>$DFDMD,1,1,1.326,0.177,2932, , *
05:39:48.702 -> Received: e
05:39:48.702 -> Received: Error
05:39:48.702 -> Received: n
05:39:48.702 -> Received: Error
05:39:48.702 -> Received: s

I have spent days writing different scripts to send the commands at different bauds, added delays, buttons, command boxes, direct injection through scripts, etc. every single command only comes through 2 or three characters at a time. I am at a lost. two of these sensors are unable because I *think", the sensors internal flash can be reset to normal 9600 uart. 

 

So…
1) is there any for of hardware, shortcircuit style factory reset I can do to the sensors to revert them back to factory, so I can resume my development? 

2) If not, does anyone know of a way to force reset or at least, force uart back to 9600 so I can resume this? I am at the end of my attempts so the only next step is to discard them and try different sensors/brands etc. 
 

 

this may or may not matter, but the last script i tried, to send commands, is this (for arduino):

#include <HardwareSerial.h>
#include <DFRobot_C4001.h>

// Define serial communication with the sensor
HardwareSerial sensorSerial(2); // Use Serial2 (UART2)

// Define the pins for the sensor
const int RX_PIN = 17;
const int TX_PIN = 16;


void flushSerial() {
 while (sensorSerial.available()) {
   sensorSerial.read();
 }
}

void setup() {
 // Initialize Serial Monitor for debugging
 Serial.begin(115200);
 while (!Serial);

 // Initialize Serial communication with the sensor
 sensorSerial.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN);
 Serial.println("Set baud, pins, etc");
 

}

void loop() {
 // Check if data is available from the Serial Monitor
 if (Serial.available()) {
   String command = Serial.readStringUntil('\n');
   command.trim(); // Remove any leading/trailing whitespace
   sensorSerial.println(command); // Send the command to the sensor
   Serial.print("Sent: ");
   Serial.println(command);
 }

 // Check if data is available from the sensor
 if (sensorSerial.available()) {
   String response = sensorSerial.readStringUntil('\n');
   Serial.print("Received: ");
   Serial.println(response);
 
 }
}