mmWave human presence for under $20?!

Yes. At least with the default settings I am using right now…

1 Like

incomingByte is not defined anywhere in that 2nd version of the code. I’ve been playing around trying to fix it, but I’ll admit I’m not 100% why we have to do the push_back in the 1st place, so am not making much progress.

Don’t know how that got in there, I edited the original snippet 28 messages ago to remove the else part.

No worries, I have a working copy now that I re-wrote (well the reads, I haven’t even looked at the writes)… Had nothing else to do. I understand it in much more detail now at least. :slight_smile:

Note that the event mappings are different on the 60GHz sensor than the 24GHz as well. So the radar files would need to be updated, as well as the packet processor for the presence sensor.

This is what I ended up with - NOTE the packet processor doesn’t do anything useful yet or return anything. This was just for debugging:

  void loop() override {
    while (available() > 0)
    {
        bytes.push_back(read());

        //End of Frame is 0x54 0x43
        if((bytes.size() > 2) && bytes[bytes.size()-2] == 0x54 && bytes[bytes.size()-1] == 0x43)
        {
            processPacket();
            bytes.clear();
        }
    }
  }

  void processPacket() {
    //cut off the first 2 header bytes and the last 3 checksum bytes
    bytes.erase(bytes.begin(), bytes.begin() + 2);
    bytes.resize(bytes.size() - 3); 

    //This yields a payloiad like:
    // Payload: 0x80 0x02 0x00 0x01 0x02 
    //   byte[0] = control character
    //   byte[1] = command word
    //   byte[2-3] = length marking
    //   byte[4+] = data (length marker in bytes 2and 3 indicates how much data there is)

    std::string str = "";

    if (bytes[0] == 0x80) // 0x80 = motion
    {
      switch(bytes[1]) {
        case 0x00: //0x00 = motion detection on/off
          // Do stuff - TBD
          break;
        case 0x01: //0x01 = presence
          switch(bytes[4]) {
            case 0x00:
              ESP_LOGI(TAG, "Presence=No one");
              break;
            case 0x01:
              ESP_LOGI(TAG, "Radar detects somebody.");
              break;
            default:
              ESP_LOGI(TAG, "Presence - unrecognized byte4.");
          }
          break;
        case 0x02: //0x01 = motion
          switch(bytes[4]) {
            case 0x00:
              ESP_LOGI(TAG, "Radar detects None.");
              break;
            case 0x01:
              ESP_LOGI(TAG, "Radar detects somebody stationary");
              break;
            case 0x02:
              ESP_LOGI(TAG, "Radar detects somebody in motion");
              break;
            default:
              ESP_LOGI(TAG, "Motion - unrecognized byte4.");
          }
          break;
        default:
          ESP_LOGI(TAG, "Motion control char - Unrecognized command word.");
    }
  }
}

Side note, I measured it, and it takes 30 seconds to go from occupied to unoccupied on the default settings. That isn’t as fast as I thought. It goes from motion to stationary in just a second or two, but 30s to go to unoccupied.

Logs (my packet processor is a bit different than the one posted 28 posts above as IO wanted to see the control character [1st byte below] and do some logging):

[19:27:58][I][PresenceSensor:051]: Payload: 0x80 0x02 0x00 0x01 0x02 
[19:27:58][I][PresenceSensor:087]: Radar detects somebody in motion

[19:28:03][I][PresenceSensor:051]: Payload: 0x80 0x02 0x00 0x01 0x01 
[19:28:04][I][PresenceSensor:084]: Radar detects somebody stationary

[19:28:35][I][PresenceSensor:051]: Payload: 0x80 0x01 0x00 0x01 0x00 
[19:28:35][I][PresenceSensor:069]: Radar detects No one.

[19:28:35][I][PresenceSensor:051]: Payload: 0x80 0x02 0x00 0x01 0x00 
[19:28:35][I][PresenceSensor:081]: Radar detects None.

In general:
0x80 0x01 is presence - noone/someone.
0x80 0x02 is motion - none/stationary/motion.

In retrospect it may have been easier to just use/port the seeeduino arduino libraries for the device… :wink:

Can I get some help in setting up this sensor with the ESP32 without using ESPhome i.e. the esp side code and connection settings.
Thank you

Wouldn’t you just use the arduino code seeduino provides if just trying to get it to work with an esp32?

I have tried this but no luck. Can you kindly guide me on it. Thank you

I’m afraid I can’t right now. I set mine up on an esp8266. To do so I had to change some of the seeduino library (the serial usage/initialization part as I needed soft serial).

I was stuck on this a while as well. The only extra thing I needed to do to get it working in the end was to change the library to use Serial2 instead of Serial1.

Pin connections are as follows:

  • MMWave RX → ESP32 TX2 (GPIO17)
  • MMWave TX → ESP32 RX2 (GPIO16)
  • MMWave 5v → ESP32 VIN
  • MMWave GND → ESP32 GND

I then can just run the code from here (and I assume some of the code in this thread will work also)

Kindly share your findings about the connection with ESP8266 and the code as well. I have some ESP8266, can give it a try.
Thank you

Thank you for your response. Just two questions :slightly_smiling_face:

  1. Are you able to detect human stationary presence with good results?

  2. I find many codes on the the link that you mentioned. Can you kindly be specific about whcih code gave you success.

Thank you

I used following example. I used PIN 2 and 3 of Arudino UNO to connect sensor’s Tx and Rx and got three states 1) NOBODY, 2) SOMEONE MOVING, and 3) SOMEONE STOP.
Now I have following questions and comments.

  1. Can we connect it with esp and what should be done with esp32/esp8266 to specify pin numbers in code?
  2. The sensor says NOBODY after 2min of stationarity even if I was there in the field of antenna radiations? Are you guys experiencing the same?
#include <sleepbreathingradar.h>

SleepBreathingRadar radar;

void setup()
{
  radar.SerialInit();
  Serial.begin(9600);
  delay(1500);
  Serial.println("Readly");
}

void loop()
{
 radar.recvRadarBytes();                       //Receive radar data and start processing
 if (radar.newData == true) {                  //The data is received and transferred to the new list dataMsg[]
    byte dataMsg[radar.dataLen+1] = {0x00};
    dataMsg[0] = 0x55;                         //Add the header frame as the first element of the array
    for (byte n = 0; n < radar.dataLen; n++)dataMsg[n+1] = radar.Msg[n];  //Frame-by-frame transfer
    radar.newData = false;                     //A complete set of data frames is saved
    
    //radar.ShowData(dataMsg);                 //Serial port prints a set of received data frames
    radar.Bodysign_judgment(dataMsg, 1, 15); //Output of human movement using sign parameters
  }
  
}

1 Like

Good day everyone,

From the above discussion - if I want to make DIY mmwave sensor - that would detect presence without falling/sleep behavior - which sensor should I go for?

I recently got FP1 and its good at detecting humans but it seems that its field detection is pretty small.

Thank you

1 Like

Hey there, I’ve been reading your thread, it’s looks fantastic, but there is one thing I don’t understand, I bought the 24GHz mmWave Sensor - Human Stationary Presence Module, and I read the instructions about how to connect the sensor and testing it from their wiki seeed studio, and when I tried it, I had some issues, for example, if I use the demo 1 it can’t return to the “NOBODY” status and I receive false positives about what the sensor is receiving and just shows “Somebody Stop” instead “NOBODY”, could you help me to resolve this, please. I don’t know exactly what have to change. I am a junior development. Thank you.

Sorry that I only have a moment to share a few thoughts. The sensor does have an issue with not returning to nobody status. You can fix this a little bit by reducing the sensitivity down to or near the minimum. Or more easily solve your issue by purchasing a DFRobot Sen0395 which is a better sensor for doing presence detection.

The 24GHz Human Stationary Presence is mainly good for detecting the activity level in a room between 1-100 in my opinion.

Anyone experimented with this one HLK-LD116-24G. it’s a 3 pin module, so I guess I’ll have to connect the VO pin to RX pin do D1 mini and see what kind of data it sends

Merry Christmas Guys! Had read all the threads here and appreciate the feedback about Seeed’s mmWave radars, especially the negative ones, that’s what drives us to improve. We just released a 24GHz mmWave Sensor - Human Static Presence Module, it is the lite version of the old one. We cut the price to $6.9, and we open more underlying parameters to make the sensitivity range fit the need of different application scenarios. We already released a detailed ESPHome integration wiki: LinkStar Home Assistant - Seeed Wiki. We really hope we will not let you down this time.

More importantly, how can I invite @crlogic and @philip1 to test it, will be a pleasure if we can send it with XIAO ESP32C3 together.

3 Likes

Can you tell us what is different/improved?

[edit] - after skimming through Building a smart home control centre around Home Assistant | Seeed Studio Wiki I have to commend the significant effort put into it. The most thorough and invested effort from a mmWave vendor I have seen to date.

Big thanks for the esphome support
Does your team have a recommended settings for rooms with ceiling fans?
Currently using the sensor mostly for bathrooms and areas without fans