Okay, so I’ve been wanting to track how many people come in and out of my workshop for a while now. Just curious, you know? I looked at some ready-made solutions, but they were either too expensive or overkill for my simple needs. So, I decided to build my own darn foot traffic counter!

The Plan

My idea was pretty straightforward:

  • Use a sensor: I needed something to detect when someone walked by.
  • Count the ins and outs: Keep track of people entering and leaving separately.
  • Generate a report: Get a daily summary of the traffic.

Getting Started: The Sensor

I played around with a few different sensors. At first, I tried a simple infrared (IR) breakbeam sensor. It worked okay-ish, but it was a little finicky. Sometimes it would miss people, or get triggered by, like, a stray piece of dust. Not ideal.

Then, I stumbled upon these ultrasonic distance sensors. You know, the kind they use for those robot car projects? Those things are surprisingly accurate! I grabbed one of those – much better!

The Brains: Microcontroller Magic

Now, the sensor needed a brain. I went with an ESP32 microcontroller. I like these things because they’re cheap, have built-in Wi-Fi, and are pretty easy to program using the Arduino IDE.

I wired up the ultrasonic sensor to the ESP32, making sure to get the power and signal pins right (always double-check those!). Then I started coding.

The Code: Counting People

The code was the trickiest part, but also the most fun. Here’s how I tackled it:

  1. Detecting Movement: The ultrasonic sensor sends out a ping and measures how long it takes to bounce back. By constantly checking this distance, I could tell when someone was passing by.
  2. In or Out?: This was the clever bit. I set up a “virtual line.” If someone crossed the line going “in” (distance decreasing), I incremented the “in” count. If they crossed going “out” (distance increasing), I incremented the “out” count. I had to play around with the threshold values to make sure it was reliable.
  3. Debouncing:This means making sure the counter only records 1 in or out per person and not multiple due to hand wave.
  4. Keeping Time: I used the ESP32’s built-in real-time clock to keep track of the day.

The Reports: Showing the Data

I wanted the reports to be simple, just a daily count of “ins” and “outs.” So, I set up the ESP32 to send the data by serial output.

I print the “in” and “out” counts every time to my serial monitor. It’s super basic, but it gives me exactly the information I wanted!

Putting It All Together

After a bit of testing and tweaking, I had a working foot traffic counter! I mounted the sensor and ESP32 above my workshop door, and now I can see how many people are coming and going each day.

It’s not the fanciest system, but it works! And the best part is, I built it myself. That’s always a good feeling.