TL; DR
Monitoring the change in the level of the Wi-Fi signal from IoT devices permanently located around the house allows you to make a completely software (dedicated hardware is missing) volumetric motion sensor in the apartment, which quite accurately shows the presence of actively moving (in fact, not sleeping) people.
Background
There is an ordinary "IT specialist's apartment" with a "smart home" system based on Home Assistant:
Homemade light switches based on ESP8266 + MSP430
Several sensors for temperature / humidity, CO2 and air quality.
Bathroom / toilet fan controller
a pair of Sonoff Mini for the rest.
Communication between devices - via Wi-Fi + MQTT. To minimize the impact of low-speed ESPs on the "working" Wi-Fi network, a separate Wi-Fi network for IoT is launched on a separate Raspberry Pi 3, based on the standard hostapd . In total, there are 12 devices in the IoT Wi-Fi network .
An MQTT broker was launched on RPi, and Home Assistant was launched on the "home server".
Idea
Wi-Fi . / RSSI, . , wi-fi - .
- , , " " - .
iw dev wlan0 station dump, :
Station 60:01:94:21:f8:4c (on wlan0) inactive time: 8000 ms rx bytes: 11269629 rx packets: 91423 tx bytes: 6159821 tx packets: 70707 tx failed: 0 signal: -53 [-53] dBm tx bitrate: 1.0 MBit/s rx bitrate: 54.0 MBit/s ... connected time: 763375 seconds Station 18:fe:34:98:dc:81 (on wlan0) inactive time: 4000 ms rx bytes: 11388688 rx packets: 92101 tx bytes: 6143200 tx packets: 70205 tx failed: 39 signal: -40 [-40] dBm tx bitrate: 1.0 MBit/s rx bitrate: 18.0 MBit/s ... connected time: 763378 seconds
RSSI ("signal: -40 [-40] dBm") , iw - .
iw RSSI - :
, "" +/- 10 dBm. , "" .
:
(" ")
, " "
, . - , .
4 :
~4:30. , - . , - , " " .
" " - .
500 RSSI iw dev wlan0 station dump.
, Raspberry Pi .
1024 " ":
$RSSI = -65; # iw dev dump
$baseline = ($RSSI + 1023 * $baseline) / 1024;
256 " ".
" " "" "" wi-fi .
:
("IW Signal Distance") . - .
Empirically, we can assume that IW Signal Distance> 1 (green horizontal) correspond to the activity of people in the room. But this boundary is likely to be different for other room configurations and device counts.
results
The system has been operating in this form for over two years, and quite reliably shows activity inside the apartment, with minimal influence from neighbors.
My implementation of the algorithm is available on github (https://github.com/k-korn/misc-scripts/tree/main/iwmon), but it is quite specific (Perl + Zabbix + visualization in Grafana) - and therefore a ready-made solution "plug and play "still cannot serve.