This is a step by step guide on how to build an mmWave presence detection using DFRobot SEN0395, D1 Mini ESP-8266 and ESPHome.
The custom module in the code above is used to implement a room presense sensor and exposes the presense detection sensor and the radar's configuration variables to Home Assistant via the ESPHome integration.
For a more advanced multi-sensor, including temperature, humidity, air quality and air pressure refer to my project here: https://github.com/igiannakas/Presense-Temperature-Humidity-Air-Quality-multi-sensor-DFRobot-SHT35-or-BME680-
This is based on the excellent work done by CRlogic in the HA forums and documented here: https://github.com/hjmcnew/esphome-hs2xx3a-custom-component/tree/release
In this fork of the code, the code is adapted to:
To make this DIY room presense sensor you'll need the below components:
To get the smallest possible size we stack the sensor on top of the D1 Mini using the pins that come with the D1 mini. The wiring diagram below reflects a stacked configuration: Sensor Pin -> D1 Mini Pin
For the D1, D2, G and 5V pins we will use header and pin connectors soldered on the D1 mini and the mmWave sensor. The D0 - IO2 connection happens via a wire which is soldered on the D0 pad of the D1 mini and the IO2 pad of the sensor.
Solder the header connectors and the single wire to the D1 Mini as below:
Solder the pins to the outer two sets of pads on the sensor (TX, RX, G, V) and then solder the single wire to IO2
Plug in the sensor to the D1 mini,making sure the V sensor pin is aligned to the 5V header on the D1 mini
As you can see this is a super compact sensor, barely bigger than the D1 mini itself.
device_name: the sensor's device name. This must be in lower case and any words separated with hyphens (-). For example: living-room-occupancy-sensor
device_name_pretty: This is the name of the occupancy binary sensor that will be exposed to home assistant. It can be upper and lower case and can contain spaces. For example: Room Name Occupancy Sensor
ssid: type your 2.4ghz wifi SSID
wifi_password: type in your wifi password
For a tutorial on how to setup your esphome instance read up here:
The sensor should be autodetected in your homeassistant dashboard. Go to Settings - Devices & Services and add the integration. Then you should be presented with the following device dashboard:
Here you can:
The sensor distance, latency, mmwave_sensor, sensitivity values are read from the radar's presistent memory. They persist reboots but reporting the values to HomeAssistant is delayed. It will take 5-10 minutes after you reboot the D1 Mini for the values to be reported so be patient until they are populated before making any changes.
Every time you change a value you need to wait ~15 - 20 seconds for the value to be written to the DFRobot radar sensor memory and for the radar to restart. While the D1 mini is writing the values to the radar's memory you'll see the LED light turn red. Once it starts blinking or is off (depending on your settings) the values are now written in memory and are persistent through reboots.
I've designed a basic case for the sensor which should provide a snug fit to its components. The STL file is included in the respository above. The case has been tested with the D1 mini and the above sensor and also with a D1 mini and an LD2410 mmwave sensor.
There are two linds in the file - a tight and a loose fitting one. Depending on your 3d Printer tolerance print one of the two lids to allow for friction fit.
What I have found is that the sensor is very sensitive to motion (which is what you want in order to get room presense). However, that might lead to false positives, when for example, you have a window open and objects move.
In that situation, your best bet is to experiment with placement, the distance parameter and lastly if everything else fails, the sensitivity parameter. You dont want sensitivity too low, as it wont be able to detect the micro movements that humans do when siting around though!
Also if you are sleeping on the sofa and covered with a blanket the sensor might not detect you - a larger cooldown period (latency) can help here but you're trading off the lights being on for longer when noone is actually present.