mmWave Presence Detection - ESPHome style

What does “slightly better” mean??

From a use-case perspective, the 2nd sensor I have deployed as a bed occupancy device has three nights of testing. In those three nights, it has only missed us for a total of three seconds; lol.

I was more going for that they changed the regulations and glad its not worse :slight_smile:

I see there are a few different types of 24Ghz mmwave sensors on aliexpress. Is the DFRobot SEN0395 better or what you happened to use? I am supper impressed that this tech detects such small movements. so it detects small movements like you breathing while asleep?

I dont want to purchase an inferiour sensor, nor do i want to pay more than i need to. Then i can buy more :smiley:

Are these all the same kind of thing? Happy to buy some random sensors for less than £2, but when we are in the £20-30 i need to be more careful

https://www.aliexpress.com/item/1005003561244819.html
https://www.aliexpress.com/item/1005001316230502.html
https://www.aliexpress.com/item/1005002580340475.html

ahh roger that.

Don’t overlook Digikey/Mouser. The DFRobot link is only $3 cheaper than what I paid and Digikey normally arrives in 2 days :slight_smile:

The DFRobot is my first experience w/ mmWave. I searched digikey, found a sensor that was available, a good price, had a datasheet and wiki.

Easily

Yes I agree. And would caution against buying anything that you might not be able to build. So a datasheet is needed at minimum. Understanding how to communicate is typically the next challenge. And tuning options are helpful such as occupied to unoccupied delay. That parameter alone often makes or breaks a product decision.

What also attracted me to the DFRobot is that binary GPIO is all that is needed. UART is optional. Unclear about the other sensors linked. If UART parsing is needed then that is potentially more challenging for some. I have no developer experience. So byte arrays scare me :o

2 Likes

Thank for the reply. I have purchased 2 of the modules and its magic. I never thought a western supplier could compete with aliexpress. Those 2 you recommended had high shipping (with me being in the uk) But then i found a uk supplier pimoroni which had them on offer for £17. Free postage over £30 so I bought 2 which arrived the next day :slight_smile:

I see you have used uart. Is this just for seeing what data it returns or is it needed for calibration. I have just used the GPIO pin and it works as a binary sensor. Not tested it much, but wondered if i need to mess around with uart. I only as as i am using a D1 mini, so an esp8266 which doesnt have hardware support for uart and falls back to software. I havnt heard of it either, so would require some research

Note that this regulation change only affects UWB (ultrawide band) operation in the 24GHz spectrum. Narrow band operation is not affected. UWB type bandwidths are typically used by much more expensive mmWave detectors that create point clouds and very fine ranging data. Like these mmWave body scanners you find at airports or automotive ranging systems. The presence detection modules we’re talking about here, which basically just return a binary state, will work fine on 24GHz narrow band mode and won’t be affected by the regulation changes.

1 Like

UART is completely optional.

My first build was GPIO only while I struggled with the ESPHome UART code.

UART lets you change detection distance. So if you want to tune the detect distance, you don’t need it after that. You could trigger from a specific point in a hallway as an example.

You also get detection delay. From 25ms up :wink:

To confirm - have any of you successfully implemented these in your homes? How has it functioned?

Next mmWave project arrived today! RFBeam K-LD2

It does not detect static motion. Out of the box it provides approaching or receding detection and will report off when just standing still (like a PIR).

Hallway WLED effects + movement direction here we come!

2 Likes

@crlogic do you know if the DFRobot chip can be connected directly to an esp8266 board? I’m curious to tinker with this but my experience with esphome is limited to cameras and other multi sensors that I was able to find guides for.

The FP1 is sweet but if I can build my own that would be even better. Thanks!

The DFRobot is 3.3V GPIO/UART so a direct connection is fine. As long as you have a 5V source to power it.

I did my second build this way.

And the full yaml posted will get ya going. So if you can flash an MCU (eg ESPHome flasher) you are all set!

Thank you for getting back to me! Now I can order the DFRobot :nerd_face:

@crlogic I’m sorry to bug you again but I can’t seem to get this thing working!

I have everything wired up and installed. The sensor shows in Home Assistant but it never detects anything.

I’m also not getting any errors which is making it harder to figure out. Do I have to do anything special within HA besides the standard upload to the esp8266 board?

Would suggest posting your wiring, yaml and checking the GPIO with a multimeter.

I swapped the tx/rx pins on the esp8266 and now I get the following which from what I can tell from the dfrobot wiki means that it detects people:

[D][text_sensor:067]: 'uart_readline': Sending state '$JYBSS,1, , , *'

The binary_sensor exposed to HA doesn’t seem to use that though…

my yaml:

esphome:
  name: mmwave-bathroom
  includes:
    - uart_read_line_sensor.h

esp8266:
  board: nodemcuv2

# Enable logging
logger:
  baud_rate: 0
  #You're using the same serial port for logging and the UART component. 
  #Please disable logging over the serial port by setting logger->baud_rate to 0.

# Enable Home Assistant API
api:
 services:
      # Service to send a command directly to the display. Useful for testing
    - service: send_command
      variables:
        cmd: string
      then:
        - uart.write: !lambda
                        char buf[128];
                        sprintf(buf, "%s\n", cmd.c_str());
                        std::string s = buf;
                        return std::vector<unsigned char>( s.begin(), s.end() );
ota:
  password: "pwd"

wifi:
  ssid: "wifi"
  password: "pwd"
  manual_ip:
    static_ip: 192.168.30.64
    gateway: 192.168.30.1
    subnet: 255.255.255.0
    dns1: 192.168.30.1
    dns2: 192.168.20.220

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Mmwave-Bathroom Fallback Hotspot"
    password: "KTCmi5SSUH06"

captive_portal:

binary_sensor:
- platform: gpio
  name: pico_mmwave
  device_class: presence
  pin:
    number: GPIO16
    mode: INPUT_PULLDOWN

uart:
  id: uart_bus
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 115200

text_sensor:
  - platform: custom
    lambda: |-
      auto my_custom_sensor = new UartReadLineSensor(id(uart_bus));
      App.register_component(my_custom_sensor);
      return {my_custom_sensor};
    text_sensors:
      id: "uart_readline"

Correct. It uses the GPIO in your config. Did you check voltage at the ESP as well as the sensor?

Helps to post the wiring used.

The voltage is 4.81 from what I can tell.

I switched to the IO2 pin and now the presence sensor says Home! I think that may have been the issue.

I’m going to test and see if it stops detecting if I leave it alone in this room for a bit. Thank you for being so responsive as I barely tread water trying to sort this thing out.

I was reading a GitHub issue about 8266’s lacking the pulldown options of the ESP32.

Would recommend disconnecting the sensor GPIO and use a multimeter to read the voltage on IO2 in order to confirm the sensor is working.

Laying it flat on a table should read low.

It seems to be functioning properly. As soon as I enter the room it’s in it switches to on and then when I leave it switches to off. I put it in a 3d printed case for a multi-sensor for the time being.

Now I need to put it to use and see if I can pull it off without my wife getting upset :slight_smile:

Glad to hear you got it working :slightly_smiling_face:

how does mmwave detect presence?