mmWave Presence Detection - ESPHome style

You can likely make it work with the following in your esphome config:

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf

There may be other changes needed to get the c3 working. Note that there is a bug (with a workaround) when using the esp-idf framework. See https://github.com/hjmcnew/esphome-hs2xx3a-custom-component/issues/9

1 Like

Thank you @hjmcnew , I was able to get this working and added my comments in GitHub :slight_smile:

Are the mmwave_presence_detection and num_targets sensors intended to work “out of the box” or is there some configuration necessary? I have tried the configuration values for distance (5.8), latency (90), and sensitivity (7) with mmwave_sensor == on referenced in OP but I’m not getting any changes to the sensors. The LED on the device continues to blink, I’m not sure if this is good or an error condition.

Yes

Classic signs of no UART communication occurring.

Hello, is it possible to know the speed with which the object is approaching? I would like to see if it is possible to sense the movement speed of the cars.

I would not use this sensor for that. It is not designed w/ that in mind and the target detection refresh is far too slow if you ask me.

I know that the RFBeam K-LD2 advertises “Object speed measurement systems” and likewise the K-LD7 does as well.

There are many other options on AliExpress that market this feature.

1 Like

Hi everyone. Thank you all for your great contributions to this project.

I am a begginer to all this but i decided to try this setup. Im having a lot of trouble even after browsing this thread and trying different things.

I have an esp32 board and have wired up the SEN0395 and tried adding it through ESP home to HA. The binary sensor seems to be working but I cannot get the sensitivity, distance, and latency to work. I saw that the advice is to check the UART wiring for the TX/RX pins so this is my current wiring:

Next I downloaded the files from the repo, using install method 2 my esp device config looks like

> esphome:
>   name: mmwave-occupancy
> 
> esp32:
>   board: nodemcu-32s
>   framework:
>     type: arduino
> 
> # Enable logging
> logger:
>   level: debug
> 
> 
> # Enable Home Assistant API
> api:
>   encryption:
>     key: "xxxxx"
> 
> ota:
>   password: "xxxxx"
> 
> wifi:
>   ssid: !secret wifi_ssid
>   password: !secret wifi_password
> 
>   # Enable fallback hotspot (captive portal) in case wifi connection fails
>   ap:
>     ssid: "Mmwave-Occupancy"
>     password: "xxxxx"
> 
> captive_portal:
>     
>     
> substitutions:
>   device_name: lounge mmwave
>   
>   # This will vary based on your board
>   uart_tx_pin: GPIO17
>   
>   # This will vary based on your board
>   uart_rx_pin: GPIO16
>   
>   # This will vary based on your board
>   gpio_pin: GPIO23
>   
>   # (Optional) Path to the leapmmw_sensor.h file relative to your esphome configuration directory
>   header_file: leapmmw_sensor.h
> 
> packages:
>   remote_package:
>     url: https://github.com/hjmcnew/esphome-hs2xx3a-custom-component
>     ref: release
>     file: packages/leapmmw_sensor.yml

After installing and connecting to HA it looks like this.
image

Binary sensor works and responds accurately with room occupancy. Cannot control LED, sensitivity, distance, latency :grimacing:
Any guidance on what I can do to figure this out?

Wiring/GPIO looks good.

You copied the leapmmw_sensor.h and installed it in your ESPHome folder?

I took the zip folder from the repo and emptied the whole thing into my ESP home folder :smiley:
image

.h check

For kicks, try GPIO 5 & 18 ?

ok so now wiring is sensor rx > GPIO18 and sensor tx > GPIO 5 and the yaml looks like this:
image
After reinstall still no change in HA :frowning:

Thanks for checking the other pins.

Paging @hjmcnew - were you able to create the branch w/ UART debugging enabled?

Might shine some light on what could be going on here.

@1st_timer Alternatively until that branch is deployed. Do you have a USB serial adapter? Confirming on a PC can be a useful step.

No unfortunately I don’t. Ill see if maybe I can get one in the coming days and I could post again.
Otherwise if I should just be patient I can do that too :slight_smile:

Ill continue to tinker with it…I was having the same problem with a second sensor I tried to build (hoping it would go better) on an ESP8266 D1 Mini. Ill try swapping cables and boards out and let you know if i stumble on it…

There is an option to edit the yaml. Just not at a PC to offer a better example.

If I understand this correctly…through the yaml we should specify the tx and rx pins?

uart:
  tx_pin: 18
  rx_pin: 5
  baud_rate: 9600

Like this for my example? Forgive me if im way off lol

Replace the uart section in leapmmw_sensor.yml with;

uart:
  id: uart_bus
  tx_pin: ${uart_tx_pin}
  rx_pin: ${uart_rx_pin}
  baud_rate: 115200
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);

Then you should see uart debug information printed to the logs where >>> represents the ESP sending information to the sensor and <<< is the response.

I was just able to get back at this now. So ive replaced the uart section in this file with your code.
image.

But when I click logs on the esphome page it just gives me the binary sensor information.

I think im missing something again. Ive restarted HA and reinstalled to the ESP. How can I access the logs youre referring to? Ive seen the logs in posts above showing the >>> and <<< but i don’t know how to get to that.

That’s the place. With those logs open, change the LED switch and copy/paste the results from the log output in a codeblock.

heres a bunch of key presses I tried:

[19:36:56][D][switch:013]: 'led' Turning ON.
[19:36:56][D][switch:017]: 'mmwave_sensor' Turning OFF.
[19:36:56][D][switch:037]: 'mmwave_sensor': Sending state OFF
[19:36:56][D][switch:037]: 'led': Sending state ON
[19:36:59][D][switch:013]: 'mmwave_sensor' Turning ON.
[19:36:59][D][switch:037]: 'mmwave_sensor': Sending state ON
[19:37:08][D][switch:017]: 'mmwave_sensor' Turning OFF.
[19:37:08][D][switch:037]: 'mmwave_sensor': Sending state OFF
[19:37:15][D][switch:017]: 'led' Turning OFF.
[19:37:16][D][switch:017]: 'mmwave_sensor' Turning OFF.
[19:37:16][D][switch:037]: 'led': Sending state OFF
[19:37:19][D][switch:013]: 'mmwave_sensor' Turning ON.
[19:37:19][D][switch:037]: 'mmwave_sensor': Sending state ON
[19:37:27][D][number:054]: 'sensitivity' - Setting number value
[19:37:27][D][number:113]:   New number value: 5.000000
[19:37:27][D][switch:017]: 'mmwave_sensor' Turning OFF.
[19:37:27][D][switch:037]: 'mmwave_sensor': Sending state OFF
[19:37:29][D][switch:013]: 'mmwave_sensor' Turning ON.
[19:37:29][D][switch:037]: 'mmwave_sensor': Sending state ON

When you said reinstalled to the ESP, you recompiled and flashed it (OTA)?

I don’t see any debug logs.

Yes i flashed it OTA. Just to be safe I just clicked the clean build files option in ESPhome dashboard and then clicked install again (OTA). Log still showing the same output when I try to adjust settings.