I am trying to build a people tracking sensor for counting the traffic of a specific area (building or shopping street). I need to detect people coming in or out of a room, also if two people are walking thorugh an entrance at the same time. I would like to use two infrared sensors and need a simple low cost solution.


  • entrys up to five meters
  • send data to cloud to display in app
  • bidirectional
  • count multiple people passing

Might there be an already existing solution with code that I can just use for my project? Which technology should I use? and which hardware?

  • What does "entrys up to five meters" mean? Also how do you expect it sensors to be able to detect direction?
    – hardillb
    Jan 23, 2020 at 14:45
  • 1
    if you want to use only two IR sensors, then the sensors would have to be two IR cameras
    – jsotola
    Jan 23, 2020 at 15:28
  • 2
    Did you make any research? Google yields pyimagesearch.com/2018/08/13/opencv-people-counter researchgate.net/post/… github.com/topics/people-counter ...
    – jcaron
    Jan 23, 2020 at 17:46
  • 1
    Yes I did make research but there are so many ways and many of them are to complex for me. I also decided now that just counting the people bidirectional is enough, no need to detect multiple people passing. It needs to be low cost so maybe an arduino sensor (light barrier) and microcontroller - but how to connect them and make them work? and What cabels to connect?
    – zarakl
    Jan 25, 2020 at 13:49

1 Answer 1


Imagine two TOF sensors side by side in a corridor. If sensor 1 triggers, then sensor 2, you have movement in one direction. And vice versa.

If you want to check if there are two people, you must have 4 sensors, so you can measure distance for each side of the corridor. Or, you can place the sensors in two opposite sides and count on the person not moving diagonally.

Sending data to the cloud is easily done with and ESP32.

This is as simple and low-cost as I could think. (Good luck finding a suitable sensor though)

  • 1
    This definitely won’t work for a busy 5 meter wide passageway. An overhead camera with image processing is probably going to be a lot more accurate. Of course it require more processing power, but I’m pretty sure it can still run on pretty cheap hardware.
    – jcaron
    Jan 23, 2020 at 21:07
  • 1
    Thank you! This is what I am looking for. But I dont know how to connect the devices and what kind of hardware I need to be able to do that..
    – zarakl
    Jan 25, 2020 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.