mmWave Presence Detection - ESPHome style

I read similar. Waiting on my ceramics from Amazon. I would have ordered from Digikey but as always, didn’t realize until after I ordered the sensor.

@Steveo - whelp… …now that I have a SeedStudio mmwave. It sees through my drywall+2x4 walls with the default sensitivity. This definitely makes it more precarious to position and tune.

Appreciate the custom .h file. Have you taken a stab at the sensitivity settings?

The following is my shot in the dark at interpreting User Manual Section 8.1

Peer review the bytearray below? I have no experience here…

My interpretation of Section 8.1 Fig A

Start Len Len2 Func Add1 Add2 Data Check1 Check2
0x55[1] low[1] high[1] 0x01[1] (read)
0x02[1] (write)
0x04[1] (system params) 0x0C[1] (threshold) 0x01-0x0A[1] crc16_L[256] crc16_H[256]

I am unsure about the correct length per Section 8.1 Bb.

Length = Data Length + Function Code + Address Code 1 + Address Code 2 + Data + Checksum.

Length of 517 = 1 + 1 + 1 + 1 + 1 + 256 + 256

Decimal of 517 is hex of 0x205 ?

Assuming I want the lowest sensitivity of 1 that gives me the following ESPHome yaml,

uart.write: [0x55,0x205,0x02,0x04,0x0C,0x01,$crc16_L,$crc16_H]

Did I get any of that correct?

There’s another thread about this mmWave sensors and they just answered to your question here:

Let us know how’s everything!

I got mine today so I’ll see if I can do something on the weekend with them :slight_smile:

Thanks for the link, I’ll take a look!

Fantastic, fed up of waiting for the FP1 and all the other off the shelf ones have few reviews/equally expensive. I’ll get a DFRobot ordered this afternoon thanks!

With some excellent assistance from @phillip1 I am going to have to echo this post.

The SeeedStudio Human Presence Module tries to be too smart for its own good is not really comparible with the DFRobot.

The DFRobot is adjustable in distance and milliseconds. This means you can be 6" away from it and it won’t trigger if that is what you want. The SeeedStudio on the lowest sensitivity stays “ON” for a three bedroom apartment.

The SeeedStudio stays “ON” for ages when you might think no one is around. The DFRobot can be set to a delay of 25ms increments.

So from a use-case perspective - if you want “movement-based” detection in milliseconds for individual rooms. Get the DFRobot. Combined with a PIR, it makes an excellent motion lighting sensor. Fast and reliable.

If you want to get away with fewer sensors and can live with greater on-to-off latency, get the SeeedStudio.

1 Like

Completely agree! “it tries to be too smart for its own good.”

I would add that when setting the sensitivity to low, the seeed starts failing to pick up non-moving targets.
I personally like setting up the DFRobot one with an output latency of 0s to get more of the underlying data and then process it myself for fantastic results.

I’ve learned that the distance setting is really quite important. What you want for presence detection is high sensitivity in a targeted, generally smaller area such as a room. The DFRobot one lets you do that, and with the Seeed, who knows what you could be detecting 15m away.

You can always get a radar motion detector + the DFRobot (which still has a 9m max range!) to detect through walls.

1 Like

This is an excellent strategy.

@phillip1 In an effort to make tuning the DFRobot easier for the masses, perhaps your CPP skills could look over the following lambdas?

I’ve tried about every “float to string” google search and continue to misunderstand the type errors.

number:
  - platform: template
    name: distance
    id: distance
    min_value: 0
    max_value: 127
    initial_value: 9
    step: 1
    restore_value: true
    unit_of_measurement: 15cm
    set_action:
      - uart.write: "sensorStop"
      - uart.write: !lambda
                        std::string cm = to_string(x)
                        return printf("outputLatency -1 0 %c", cm);
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - uart.write: "sensorStart"
      
  - platform: template
    name: latency
    id: latency
    min_value: 0
    max_value: 2000
    initial_value: 200
    step: 1
    restore_value: true
    unit_of_measurement: 25ms
    set_action:
      - uart.write: "sensorStop"
      - uart.write: !lambda
                        std::string ms = to_string(x)
                        return printf("outputLatency -1 0 %c", ms);
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - uart.write: "sensorStart"

I have this Zigbee Menselijke Aanwezigheid Sensor Tuya Smart Pir Mmwave Radar Bewegingsmelder Fall Detectie Verlichtingssterkte Monitor App Alarm Dc 12V| | - AliExpress

Worked out of the box with zigbee2Mqtt and seems to work well with presence. There are some sensitivity params as well

My DFRobot arrived today so will be getting that hooked up soon, thanks for all the info in this thread as otherwise I’d be a bit lost on where to start!

Am I right in thinking based on the ESPHome yaml in your OP you’ve wired up the TX (to GPIO18), RX(to GPIO19) AND GPIO(to GPIO23) pin to your board? As without the TX/RX you’re unable to modify certain distance settings? Also the esphome code in the OP your most up to date version of code for this?

Thanks once again!

Oh no… And I bought 3 of them! :frowning:

I will still give it a try this weekend but one of my use cases was to reliably turn on and off the lights of the kitchen faster :frowning:

@crlogic what’s your experience with returns to Digikey?

I have five of these DFRobot now, each wired to suit their deployment with other sensors and different dev boards. So be sure to wire them up and adjust the yaml GPIO to suit your actual deployment.

As for UART, yes that is entirely optional. And yes you are correct that without UART you will be using the stock distance and delay parameters setting per the DFRobot wiki :slight_smile:

I would highly recommend configuring serial as it makes them very versatile.

As for the rest of the yaml - yes it works and works well. If any new developments occur I will be sure to update.

Good luck and have fun!

1 Like

The SeeedStudio or DFRobot?

The DFRobot are excellent for lighting. Especially with a PIR. Sadly the SeeedStudio are not really suitable IMHO. I have never tried to return anything to Digikey - sooo let me know how it goes!

1 Like

SeeedStudio

If that’s the case I think I won’t wast my time and will try to return them, I’ll let you know!

How about something like this?

Then you can just specify the cm and it will convert it for you (rounding up so 1cm => 15cm, 0cm => 0cm, 15cm => 15cm, 16cm => 30cm)

unit_of_measurement: cm
step: 15
min_value: 0
max_value: 1350
initial_value: 500

!lambda
int cm = (int)ceil(x / 15.0);
std::string s = "outputLatency -1 0 " + to_string(cm);
return std::vector<unsigned char>(s.begin(), s.end());
Or you can use code for 15cm increments
unit_of_measurement: 15cm
step: 1

!lambda
std::string s = "outputLatency -1 0 " + std::to_string((int)x);
return std::vector<unsigned char>(s.begin(), s.end());

Also, on the DFRobot page, it seems to show that the range is >9m??
Sensing distance: “16.5m” “detRangeCfg -1 0 110”. Implying the max range is at maybe 1650cm or more.

1 Like

@phillip1 - amazing! That makes this DFRobot fully configurable using sliders (number) in HA !

image

This is what I ended up with. I started with no delay but the commands would sometimes stumble over themselves. A small delay between each worked.

number:
  - platform: template
    name: distance
    id: distance
    min_value: 0
    max_value: 1350
    initial_value: 315
    optimistic: true
    step: 15
    restore_value: true
    unit_of_measurement: cm
    set_action:
      - uart.write: "sensorStop"
      - delay: 1s
      - uart.write: !lambda
                      int cm = (int)ceil(x / 15.0);
                      std::string cms = "detRangeCfg -1 0 " + to_string(cm);
                      return std::vector<unsigned char>(cms.begin(), cms.end());
      - delay: 1s
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - delay: 1s
      - uart.write: "sensorStart"
      
  - platform: template
    name: latency
    id: latency
    min_value: 0
    max_value: 65000
    initial_value: 12500
    optimistic: true
    step: 25
    restore_value: true
    unit_of_measurement: ms
    set_action:
      - uart.write: "sensorStop"
      - delay: 1s
      - uart.write: !lambda
                      int ms = (int)ceil(x / 25.0);
                      std::string mss = "outputLatency -1 0 " + to_string(ms);
                      return std::vector<unsigned char>(mss.begin(), mss.end());
      - delay: 1s
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - delay: 1s
      - uart.write: "sensorStart"

I will update the OP and give credit where credit is due. Thank you again!

I haven’t tested that far and see no reason to doubt it on my experiences to date.

4 Likes

That is sweet! Just bought the last two digikey had in stock. Now to add a minimum distance setting :wink:

1 Like

I think I bought the other 2 yesterday since it was saying 4 on stock LOL

I can’t imagine the use-case, do tell!

Or better yet, if you are looking for another project, we got some for ya :wink:

Is that for the dfrobot mmwave sensor on digikey?
Are they lower priced there?