About The Problem
I wanted to explore HMMD mmWave thus I connected the sensor up with esp32c6. For starters, I used the software serial, but the data coming through seemed garbled up. My initial suspect were the high baud rate 115200, thus I switched from Software to Hardware serial.
After switching to hardware serial, although I was able decode and use the data, the data stream seemed to hang after 1-2 messages from the sensor. Hence my problem, in theory the sensor should always send the datastream, but the link seems to break after 1-2 messages when using hardware serial.
About My Setup
- I’m using vscode with pio and arduino framework.
https://github.com/Seeed-Studio/platform-seeedboards.gitas platform- Sensor is connected to D6/D7
here’s that manufacturer recommends (uses software serial, garbles up data)
#include <SoftwareSerial.h>
SoftwareSerial mySerial(D7, D6); // RX, TX
void sendHexData(String hexString) {
// Convert hex string to bytes
int hexStringLength = hexString.length();
byte hexBytes[hexStringLength / 2];
for (int i = 0; i < hexStringLength; i += 2) {
hexBytes[i / 2] = strtoul(hexString.substring(i, i + 2).c_str(), NULL, 16);
}
// Send bytes through software serial
mySerial.write(hexBytes, sizeof(hexBytes));
}
void readSerialData() {
// Read and print data from software serial
while (mySerial.available() > 0) {
char incomingByte = mySerial.read();
Serial.print(incomingByte);
}
}
void setup() {
// Start the serial communication with a baud rate of 115200
Serial.begin(115200);
mySerial.begin(115200);
// Wait for the serial port to initialize
while (!Serial) {
delay(100);
}
// Hex string to send
String hex_to_send = "FDFCFBFA0800120000006400000004030201";
sendHexData(hex_to_send);
}
void loop() {
// Read and print serial data
readSerialData();
}
Here’s the code that I’m using (uses hardware serial, data stops coming through after 1-2 messages)
#include <Arduino.h>
#include <HardwareSerial.h>
HardwareSerial mySerial(0); // RX, TX
void sendHexData(String hexString) {
// Convert hex string to bytes
int hexStringLength = hexString.length();
byte hexBytes[hexStringLength / 2];
for (int i = 0; i < hexStringLength; i += 2) {
hexBytes[i / 2] = strtoul(hexString.substring(i, i + 2).c_str(), NULL, 16);
}
// Send bytes through software serial
mySerial.write(hexBytes, sizeof(hexBytes));
}
void readSerialData() {
// Read and print data from software serial
while (mySerial.available() > 0) {
char incomingByte = mySerial.read();
Serial.print(incomingByte);
}
}
void setup() {
// Start the serial communication with a baud rate of 115200
Serial.begin(115200);
mySerial.begin(115200);
// Wait for the serial port to initialize
while (!Serial) {
delay(100);
}
// Hex string to send
String hex_to_send = "FDFCFBFA0800120000006400000004030201";
sendHexData(hex_to_send);
}
void loop() {
// Read and print serial data
readSerialData();
}