mmWave Presence Detection - ESPHome style

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?

In the UK they’re lower priced if you’re buying more than 1 and then qualify for free shipping. Otherwise I found if you really just want the one then pimoroni was the cheapest option.

In Ireland it was almost 35€ each even with free shipping due to import tax

I paid the equiv of €36 for one in the UK so not far off!

BTW, I found that if you have access to a card that has no fees on currency transactions (like revolut) it’s slightly cheaper to pay in dollars!

Hello @crlogic , @all
I received the sensor as well and do the wiring + take the example of code.
So far so good :slight_smile: !

I added a “device_class: motion” into the binary_sensor.

It’s wired with nodemcu. GPIO13 and GPIO15 for UART and GPIO16 (which is the only one apparently with a pull_down resistor) for connecting the IO2 from the sensor.

I don’t understand exactly the latency. I need to play a bit with the config :slight_smile: What is the usecase ?

Probably a bad description on my part :man_shrugging: :slight_smile:

It is the duration after motion is no longer detected and the sensor reporting off. No different to the delayed_off: filter that ESPHome offers.

1 Like

I’m not sure about my reasoning:

Modify values are saved into the sensor flash. It means that is maintain after a complete shutdown and restart. Supposed true.

But HA states will not be aligned with the real value of the sensor after the restart. There are may be a way to maintain the value saved in HA as well to keep the same. (There is no API code to read the data after save).

It’s correct ?

After you have found the value best suited for that sensor/placement; adjust the YAML initial_value:

1 Like

if you want to have the slider on latency, you can add
mode: slider

There is a bug that will solve the restore_value

Anyone who has been following this thread could give us a TLDR; ? Would be really appreciated since there’s another thread that has been opened on this topic recently

OP was updated 5/20/22 w/ latest developments.

What other thread?


Here my first 3dprint

I will fix the sensor with the 2 unused pins. It can be with USB cable from left or right.
Also it’s possible to move the sensor from left or right for small adjusment

1 Like

Nice print. Holding the sensor by the two top pins is neat.