Alright folks, gather ’round! Today I’m gonna walk you through a fun little project I cooked up: wireless foot traffic tracking for retail spots. It’s all about seeing how many people are wandering around a store, without actually counting heads like some kind of weirdo.
The Idea Sparked
So, the whole thing started ’cause a buddy of mine runs a small clothing store. He was always trying to figure out the best times to run sales, and how effective his window displays were. He was basically guessing, and I thought, “There’s gotta be a better way!”
The Tech We Used
- ESP32 Boards: These little guys are the brains of the operation. Cheap, cheerful, and packed with Wi-Fi and Bluetooth.
- Wi-Fi Scanning: The ESP32s are programmed to sniff out Wi-Fi signals from phones. Every phone is constantly broadcasting, trying to connect to Wi-Fi networks, the ESP32 listens to these signals.
- Bluetooth Scanning: Similar to Wi-Fi scanning, ESP32s are also programmed to scan for Bluetooth signals from phones.
- A Raspberry Pi (or similar): This acts as our central server. It collects the data from all the ESP32s and crunches the numbers.
- Some kind of database: I used SQLite, because it’s simple and good enough for the job. You could use MySQL or Postgres if you wanna get fancy.
- Python: To pull data from the database and show it to my buddy on a dashboard.
Getting Our Hands Dirty: The Build
First, I grabbed a few ESP32 boards. I flashed them with some custom firmware that I cobbled together using the ESP32 Arduino core. The code basically tells the ESP32s to:
- Scan for Wi-Fi probe requests and Bluetooth signals.
- Record the MAC addresses (the unique identifier of each device) and the signal strength (RSSI).
- Send this data to the Raspberry Pi over Wi-Fi.
Next up was setting up the Raspberry Pi. I installed Python, SQLite, and Flask (a lightweight web framework for building web applications), then I:
- Created a database to store the data from the ESP32s.
- Wrote a Python script to receive the data, clean it up (removing duplicates and bogus entries), and store it in the database.
- Knocked up a Flask web app to display the data in a simple graph. I showed the foot traffic in real-time, plus a historical view so my buddy could see trends over time.
Putting it all Together
I placed the ESP32s at different spots around my buddy’s shop – near the entrance, by the fitting rooms, and near the checkout counter. I wired them up to USB power adapters (you could also use batteries, but I wanted it to be low-maintenance).
The Raspberry Pi sits in the back office, plugged into the network. Now, whenever someone walks into the store with Wi-Fi or Bluetooth enabled on their phone (which is pretty much everyone these days), the ESP32s pick up their signal. The data is sent to the Raspberry Pi, crunched, and displayed on the web dashboard.
The Results?
My buddy was stoked! He could finally see which days and times were busiest, and which window displays were actually drawing people in. He even tweaked his staffing levels based on the data. It’s pretty cool to see something you built actually making a difference for someone.
Things We Learned (and What We’d Do Differently)
- MAC Address Randomization: Modern phones randomize their MAC addresses to protect privacy. This made things trickier! We tried to mitigate this by looking at the signal strength of the Wi-Fi probes. If we saw the same MAC address with similar signal strengths over a short period of time, we figured it was the same device.
- Calibration is Key: The signal strength of Wi-Fi and Bluetooth signals varies depending on the environment. We had to do some fiddling to get the thresholds just right.
- More sensors, More data: The more ESP32s you have, the better the accuracy.
Wrap-Up
This project was a blast. It’s a real-world example of how IoT (Internet of Things) can be used to solve practical problems. And hey, it was way cheaper than buying a commercial foot traffic counter!