Okay, so I’ve been messing around with this idea of counting people in stores, not just for kicks, but to actually use that data for something useful. You know, like, understanding when the store is busiest, how many staff you really need, and whether that fancy new display is actually drawing people in.

I started out pretty basic. My first thought was, “I need a sensor.” So I grabbed one of those cheap infrared beam break sensors – the kind you see in, like, a garage door opener. The idea was simple: when someone walks through the door, they break the beam, and I count that as one person.

I wired this thing up to a little Arduino board I had lying around. The coding was surprisingly easy – just a simple counter that went up every time the beam was broken. I slapped together a quick-and-dirty display using some LEDs to show the count. Boom! Person counter, version 0.1.

But, let’s be real, this was super crude. Here’s why:

  • Double Counting: If two people walked through close together, it might count them as one. Or, someone could walk in and out quickly and get counted twice.
  • No Direction: It didn’t know if someone was entering or exiting. That’s kinda important if you want to know how many people are actually in the store.
  • Zero Insights: It just gave me a number. Big whoop. I wanted to know when people were coming in, not just how many.

So, back to the drawing board. I figured I needed something smarter. I swapped out the single beam break sensor for a pair of them, placed a short distance apart. This way, I could tell the direction someone was walking based on which beam broke first.

This made the code a bit more complex, but nothing crazy. I basically checked which sensor triggered first, waited a bit, and then checked if the other sensor triggered. If it did, I knew the direction. If not, it was probably just someone waving their hand or something.

Still, just knowing “in” or “out” wasn’t enough. I needed that sweet, sweet data. So I ditched the LEDs and connected the Arduino to my computer. I wrote a simple Python script to read the data from the Arduino and store it in a CSV file – basically a spreadsheet. Each entry had a timestamp (when the person entered or exited) and the direction.

Now we’re getting somewhere! I could import this CSV into a spreadsheet program (I used Google Sheets because it’s free and easy) and start making some charts. I could see the busiest times of day, the average number of people in the store, and even start to predict staffing needs based on the day of the week.

It should also be very easy to visualize it with a simple graph, and draw some conclusions, like peak times during the week, or if there is any direct impact after that day that had a big marketing campaign, which allows us to adjust the strategy on the fly.

This is still a work in progress, of course. There are tons of improvements I could make:

  • Use a more robust sensor, maybe a camera with some basic image processing.
  • Move the data storage and processing to a Raspberry Pi, so it can run independently of my computer.
  • Create a web dashboard to visualize the data in real-time.

But even this simple setup has been incredibly insightful. It’s shown me that my initial guesses about peak hours were way off, and that I could probably optimize staffing levels to save some money. Plus, it’s just plain cool to see the data flowing in and being able to make sense of it.