[presence] Reliable, Multi-User, Distributed Bluetooth Occupancy/Presence Detection

My objective is only to highlight what seems to be a major issue with using a Pi Zero W for WiFi and Bluetooth concurrently that does not seem to have been widely discussed.

All I can say for sure is that I can run bandwidth tests (iperf3) between 2 machines over 2.4GHz WiFi reliably until I startup a Pi (3rd machine) running WiFi and a Bluetooth scan and then the performance test looses data and ssh’s become unresponsive and time out. The pi affects all devices on the 2.4GHz WiFi not just the Pi. It looks like the Pi just splats across everything.

For me turning off WiFi and moving to, in my case, wired Ethernet dongles was a transformation. I now have 3 x Pi Zero W’s each doing Bluetooth scans every 6 seconds and my 2.4GHz WiFi is back to being steady as a rock. Plus random reports of Hue lights going unavailable has stopped as well.

I believe it could be a transformation for other users too and have not seen it as a suggested work around. I would like to see some other users try it and report back their experiences.

With regard to the Raspberry Pi Foundation, I too am a big fan, but when there is a problem they should be encouraged to be open about issues. I have been very surprised how difficult it has been to find out about this problem and had i known in advance i would probably have purchased Pi 3B’s rather than Pi Zero W’s because I now have dongles hanging out of the cases.
I am really only trying to be helpful!
Best Wishes

1 Like

Below is the output from a 30 second iperf3 test between one Pi Zero W and a windows desktop.
On a second Pi Zero W connected to the network over WiFi I start a single Bluetooth scan for 2 non present devices after interval 9-10.
You can see that for the next 11 seconds communication between the first 2 independent devices is trashed. Moving the second Pi Zero W to a wired connection and the independent transfer does not miss a beat! I can add a log of that but there is nothing to see except a constant 40+ Mbps
Regards

$ iperf3 -t 30 -c x.x.x.x
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  5.32 MBytes  44.6 Mbits/sec    0    115 KBytes
[  4]   1.00-2.00   sec  5.36 MBytes  44.9 Mbits/sec    0    127 KBytes
[  4]   2.00-3.00   sec  5.44 MBytes  45.7 Mbits/sec    0    141 KBytes
[  4]   3.00-4.00   sec  5.64 MBytes  47.3 Mbits/sec    0    156 KBytes
[  4]   4.00-5.00   sec  5.44 MBytes  45.6 Mbits/sec    0    164 KBytes
[  4]   5.00-6.00   sec  5.01 MBytes  42.1 Mbits/sec    0    182 KBytes
[  4]   6.00-7.00   sec  4.96 MBytes  41.6 Mbits/sec    0    190 KBytes
[  4]   7.00-8.00   sec  5.04 MBytes  42.3 Mbits/sec    0    190 KBytes
[  4]   8.00-9.00   sec  5.39 MBytes  45.2 Mbits/sec    0    190 KBytes
[  4]   9.00-10.00  sec  5.83 MBytes  48.8 Mbits/sec    0    286 KBytes
[  4]  10.00-11.00  sec  1.95 MBytes  16.4 Mbits/sec    1   1.36 KBytes
[  4]  11.00-12.00  sec  75.9 KBytes   621 Kbits/sec   20   56.9 KBytes
[  4]  12.00-13.00  sec  0.00 Bytes  0.00 bits/sec    0   1.36 KBytes
[  4]  13.00-14.00  sec  32.5 KBytes   266 Kbits/sec   23   33.9 KBytes
[  4]  14.00-15.00  sec  0.00 Bytes  0.00 bits/sec    7   33.9 KBytes
[  4]  15.00-16.00  sec  29.8 KBytes   244 Kbits/sec    5   23.0 KBytes
[  4]  16.00-17.00  sec  0.00 Bytes  0.00 bits/sec    0   23.0 KBytes
[  4]  17.00-18.00  sec  0.00 Bytes  0.00 bits/sec    0   23.0 KBytes
[  4]  18.00-19.00  sec  0.00 Bytes  0.00 bits/sec    0   23.0 KBytes
[  4]  19.00-20.00  sec  0.00 Bytes  0.00 bits/sec    1   1.36 KBytes
[  4]  20.00-21.00  sec   945 KBytes  7.73 Mbits/sec    9   29.8 KBytes
[  4]  21.00-22.00  sec  4.06 MBytes  34.1 Mbits/sec    0   70.5 KBytes
[  4]  22.00-23.00  sec  5.29 MBytes  44.4 Mbits/sec    0   88.1 KBytes
[  4]  23.00-24.00  sec  5.27 MBytes  44.2 Mbits/sec    0   92.2 KBytes
[  4]  24.00-25.00  sec  5.34 MBytes  44.8 Mbits/sec    0   97.6 KBytes
[  4]  25.00-26.00  sec  5.41 MBytes  45.4 Mbits/sec    0    100 KBytes
[  4]  26.00-27.00  sec  5.20 MBytes  43.6 Mbits/sec    0    104 KBytes
[  4]  27.00-28.00  sec  5.18 MBytes  43.5 Mbits/sec    0    107 KBytes
[  4]  28.00-29.00  sec  5.18 MBytes  43.4 Mbits/sec    0    111 KBytes
[  4]  29.00-30.00  sec  5.34 MBytes  44.8 Mbits/sec    0    168 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-30.00  sec   103 MBytes  28.7 Mbits/sec   66             sender
[  4]   0.00-30.00  sec   102 MBytes  28.6 Mbits/sec                  receiver

Look, the point isn’t that 2.4 interference happens for everyone on every network in every circumstance at all times. Depends on hardware, depends on channel use, depends on traffic, etc.

It’s good to hear your network is unaffected. I still recommend monitor over presence because by running either script you are causing interference with adjacent devices using 2.4GHz spectrum, whether on your network or otherwise. If these devices are modern, it’s highly unlikely the interference will matter. On the other hand, if neighboring devices are older, cheap, or otherwise have lower noise tolerance, the constant scanning operation of presence can throttle performance or knock services offline.

Your single datapoint here doesn’t reflect the experience of a substantial number of users. It doesn’t mean that other users don’t understand the “real” problem or that other users haven’t tried switching interfaces. It also doesn’t mean that your neighbors are unaffected by your presence node. Do any of your neighbors have a baby monitor that runs on 2.4GHz? There’s a chance that constant scanning is causing that baby monitor to lose connection with the base for extended periods of time. Switching to monitor substantially mitigates that risk by reducing the number of name scans to a bare minimum.

… I’m really not sure what purpose we’re serving here by trying to rank and compare two different issues.

TL;DR Interference exists. Wi-Fi issues on a $5 computer exist. monitor is better suited for almost all circumstances than presence.

3 Likes

I’ve searched the thread and haven’t seen anyone with this issue yet. I have monitor up and running on a pi zero and it is reporting to my mqtt broker and updating the sensors in HA like it should. However, the only way it will update is to issue the sudo bash monitor.sh command from ssh. Once I do that I can see the whole process running and everything updates as it should.

I also have two scripts on HA to start the depart and arrival scans. These scripts work while I’m running the bash monitor.sh. But if I exit out of ssh and try them, nothing updates.

Also tried a reboot of the raspberry pi but that doesn’t seem to work. It’s like monitor is only running when I issue the command to start it. Is this normal? What else can I check?

have you tried restarting the service?

sudo systemctl restart monitor

I get this:
raspberrypi systemd[1]: monitor.service: Failed with result ‘exit-code’.

Also, when I do a sudo service monitor status I get this:
● monitor.service - Monitor Service
Loaded: loaded (/etc/systemd/system/monitor.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Sat 2019-02-16 23:09:22 GMT; 9s ago
Process: 12474 ExecStart=/bin/bash /home/pi/presence/monitor/monitor.sh & (code=exited, status=210/CHROOT)
Main PID: 12474 (code=exited, status=210/CHROOT)

So I did a clean re-install from scratch and it appears to be working now. Initially I was using presence. I uninstalled presence and installed monitor but I guess something got messed up in the process. Clean install seems to have fixed it.

Is this the correct path?

You could remove the service and have monitor create it again.

Ah ha! As I stated, I was using presence prior. That path is not right and probably where I messed up. Which is why a clean install fixed it. Totally my mistake.

All is good now. Been up and running for the last 8 hrs with no issues.
sudo service monitor returns
monitor.service - Monitor Service
Loaded: loaded (/etc/systemd/system/monitor.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-02-17 02:53:15 GMT; 8h ago

1 Like

I have to admit that I did not read all 809 posts to date, but I did a cursory scan and did some googling. My question is the PI 0 W limit 1 per customer. The limit you to 1 then charge $10 shipping. Am I missing something or would you be better off just buying the new PI 3B+?
How do people get 3 and 4 PI 0’s?

Living near a microcenter helps, but any Pi will run the script.

I hear you. I had a friend stop by once as he was coming through Dallas. They did not have any in the brick and mortar at the time. I guess it’s better now? Is there a trick if you are at the store? Some sort of secret handshake? :grin: How many will the store let you have?

1 Like

@andrewjfreyer have you seen the updates for the new 5.1 bluetooth protocols? It looks very awesome and looks like they are gearing towards more home automation applications https://www.google.com/amp/s/staceyoniot.com/bluetooth-5-1-the-missing-link-for-presence-and-context-in-the-smart-home/amp/

1 Like

mmhhh, could someone tell me which typew of beacon work well? I would use one in the car (but do not have a always on power USB, so I need a battery type, if exist)

Great. I wonder if anyone know about GPS Galileo application: it’s the European GPS system which has an accuracy of 1 meter (compared to 10-20 meter of the USA GPS), and if I am not mistaken works better inside the house (?)

Hi,

Galileo uses a similar frequency band as GPS, similar transmission power and therefore its performance indoors should be similar to GPS. The accuracy outdoors is claimed to be 1m comparing to 5m (GPS, GLONASS), however in practice the difference is barely notable. Most modern GNSS receivers use as many systems as possible to obtain best precision.

Hi again, I just realized, answering to previous post went a bit off-topic. Now for a topic-related question:

I have recently installed monitor and it is giving great results. However there is one thing I’m not sure I understand:
Based on the things I’ve read monitor is supposed to be checking presence of devices that have recently come into the range automatically based on listening to packets advertising random macs. However, in my experience, running monitor with no special parameters and default config it only detects presence upon monitor startup and on manual arrive/depart requests.

I am aware that android phones are not advertising by default, but according to nrfConnect, my laptops are.
The question is: Shouldn’t be Monitor checking presence of all not-present devices when laptop starts advertising? Or am I getting the whole concept wrong?

Thanks for responses.

You checked it yourself?

I have done some basic checks. I’m hardware developer for Boat monitoring devices that use GPS, GALILEO, GLONAS, and QZSS on our side of the planet. I’ve done some comparison between this and previous model which didn’t have Galileo: when PDOP is good, there is not much difference in the radius of points acquired while the device is standing still.
And Galileo devices are (unfortunately) not working any better when indoors.

mmhhh and I thought that Galileo would revolutionize the way we use GPS … I guess it isn’t