In these times of social distancing many larger stores now have people on the front door ensuring that it does not become too crowded inside the store. Smaller stores in strip-malls cannot afford to do this. At-risk individuals are particularly concerned about entering small spaces with many people inside. This project creates a simple RED/GREEN indicator that can be placed by the front door.
Sample display with prominent red/green LED and explanatory text.
Using Bluetooth Low Energy scanning on an Arduino MKR1010 it is able to reliably count how many cell phones are nearby and warn when the store is busy or reassure at risk individuals that now would be a good time to come inside.
Internally it tracks every BLE device nearby and figures out which ones are duplicates caused by iPhone and Android MAC address randomization.
Here for example it has five recent MAC addresses that could represent individual devices but it has determined that there are in fact only three active devices:
Without this feature the number would be significantly inflated as phones hop MAC addresses at random intervals to evade attempts to track them. Using an algorithm similar to ones used to layout events on a calendar this project calculates a minimum-possible cell phone presence count.
In this example there were around 30 different MAC addresses but the algorithm packs them into 11 columns avoiding any overlaps and deduces that there are at least 11 different BLE devices (which is a long way off the 30 you might otherwise detect if all you do is count distinct MAC addresses)
Here's what the MAC address hopping looks like in practice: A single device changes MAC address (color) periodically. In this case the changes are spaced fairly evenly but that too is randomized and sometimes they change far more frequently.
Put 20 of these in a small space and it becomes much harder to see what's going on:
The actual hardware to achieve this is remarkably simple. All you need is an Arduino MKR1010 with BLE capabilities and two LEDs: one red and one green. I used the Lilypad LEDs here because they include the current limiting resistor. I also added a couple of CAT5 jacks with PCB mounts so that the BLE sensing component can be placed more centrally in the store and the LED display can be placed in the front window and CAT5 is cheap and easy to run.
Here's the box containing the MKR1010 and the CAT5 jack. The only wires run from GND, PIN6 and PIN7 to the jack. Pick your own arrangement for the wires on the jack since you control both ends.
Here are the small CAT5 jack PCBs, I found them on eBay.
Running the project is simple: download the repository from Github, open the INO file and upload it to your MKR10101. You can try it out without even wiring up the LEDs, just connect the Serial Monitor and watch it discover all your BLE devices and then watch it shuffle them around to determine which ones are real and which are phantoms caused by MAC address randomization.
This project is deliberately kept simple and aimed at a practical, ready to go solution to the current COVID-19 crisis. If you have a small retail store you could build and install this in a matter of hours and reassure your at risk customers that it's safe to enter the store.
CustomizationThere are hundreds of ways this project could be customized if you want to take it further. Here are some ideas for you:
- Use higher-powered LEDs with a transistor for each.
- Use a servo and make an analog-clock-style pointer display that displays the risk in a more analog fashion.
- Adjust the detection range with an RSSI limit.
- Adjust the device counts at which it changes colors.
- Make the pulsing brighter as the number of devices increases.
- Add a Smartphone app that talks to the MKR1010 during setup to adjust these values.
- Adjust the dwell-time before it decides that a device has departed.
- Create a mesh network and cover a larger area with multiple scanners.
- Report statistics back to a web site (would need to turn off Bluetooth, turn on WiFi and then switch back as currently the MKR1010 doesn't seem to support both simultaneously). Below, for example is a plot of activity by time of day by range by number of devices. This could be invaluable extra data for a small store owner trying to figure out staffing levels during these rapidly changing times.
If you want to take this further or have any feedback I'd be happy to chat to you on Twitter DM or in email.
Comments