Okay, so I’ve been messing around with this visitor counting thing for the hospital, and let me tell you, it’s been a journey. Started off pretty simple, or so I thought.

The Initial Idea

My first thought was, “Hey, how hard can it be? Just count people coming in and out, right?” I figured I could slap together something basic with a couple of sensors and a little bit of code. I went and grabbed some infrared sensors – seemed like the easiest option at the time.

Setting Things Up

I started by placing the sensors at the main entrance. One on each side of the door, seemed logical. Wired them up to a little microcontroller – an Arduino, because, why not? It’s what I had lying around.

  • First try: Placed sensors, wired them up, wrote some super basic code to just count every time the beam was broken.

And… it kinda worked. Except it didn’t. It counted, sure, but it counted everything. People walking in, people walking out, people just kinda milling about near the door. Even a stray balloon set it off. Total mess.

Back to the Drawing Board

So, I realized I needed to get a bit smarter about this. It wasn’t just about counting breaks, it was about figuring out the direction people were moving. Did some digging, found out about using two sensors, spaced a bit apart. The order in which the beams break tells you if someone’s coming in or going out.

  • Second try: Added a second sensor, rewrote the code to check which sensor broke first.

This was better. Way better. It could actually tell the difference between someone entering and someone leaving. Still not perfect, though. Sometimes it would double-count if people walked really close together. Or if someone stopped right in the doorway, it would get confused.

Getting Fancy (and a Little Frustrated)

I spent a good chunk of time just tweaking the code, trying to filter out the weird edge cases. Added some delays, some logic to ignore super-fast consecutive triggers. It was a lot of trial and error. I even considered using those fancy ultrasonic sensors, but they seemed like overkill for this.

I’m adjusting some code and delay time, filtering out edge cases. Consider using another sensors but it not necessary.

The ( মোটামুটি) Finished Product

After a bunch of tinkering, I finally got something that’s… pretty reliable. It’s not going to win any awards for innovation, but it does the job. It accurately counts people coming in and out, and it doesn’t get fooled by balloons (most of the time).

It is pretty good right now, but I will keep testing and collecting data to improve my code.

The biggest lesson? Sometimes the “simple” projects are anything but. And sometimes, you just gotta keep plugging away until it works. It’s all about persistence, and maybe a little bit of stubbornness. I would like to sharing more details in the future!