Vehicle Counter
Sunday, April 04, 2021
We live near a highway that is well travelled by tourists in the summer, so I wanted to get a count of how many vehicles pass by, so I built this vehicle counter.   Laser is best but requires a reflector across the highway.  It's best because it is On-Off.  My LIDAR sensors didn't have the range, and the ultrasonic (shown below) is "noisy", i.e. NOT On-Off, so filtering and multi-sampling must be done.

Copyright 2021 Queenidog - All Rights Reserved
Laser sensor - a relay that gets activated when hit by beam
I'm using an Arduino Nano MCU module
Ultrasonic sensor. Too noisy, too much overhead to worry about
Laser in box at right hitting a mirror and returning to hit the sensor on left
This is a Sharp LIDAR sensor - not enough range, can't use
Box with LCD and MCU inside.  Power is external
This is the Benewake TF-Mini attached to top of my computer monitor, shooting across room to my tool box.
Here's another view, of sensor on top of monitor. I block it to simulate a vehicle blockage





 11.1 m/s

 13.9 m/s

 16.7 m/s


















































 bus, semi

 72 pass






Transit times are based on average length of vehicle shown in table,  at 3 speed limits.  Very crude determination because speed is assumed,   not necessarily followed and vehicle lengths are averages.  Speed not  measured (another project).

The posted speed limit where the sensor is located, is 40 kph, or 11.1 meters/second.
Monday, November 15, 2021
Update: (Nov 14, 2021)  Project is complete, ie it is working on the bench...field trials starting soon.

I went back to LIDAR, using a Benewake TF-Mini sensor, good for 36+ feet (12 M) under good conditions.  The LIDAR (an acronym for Light Detection and Ranging)  generates  an infrared light of 850 nM wavelength, so it is invisible.  The unit has electronics to help discriminate from false signals and has a tight focused beam with a refresh rate of 100Hz.  I'm not using it as a range device, I'm using it as a detector, so I had to do some coding to make that happen.

See new  (last 4) photos below.

How it works (Theory of Operation)
Monday, November 15, 2021
The LIDAR sends out an invisible infrared light  that reflects back when it hits an object, the object in this case being a vehicle.  If there is no vehicle, there is no bounce back (as long as nothing is in the way and within the range of the LIDAR, e.g. grass in the ditch across the highway).  This is the "idle state" where the system waits for a block.   When a vehicle blocks the way, a timer starts and when the vehicle passes, the timer stops.  The transit time is an indication of what type of vehicle it was, e.g. a motorcycle will "fly" past the sensor faster than a 70 passenger bus.   See table after the photos for transit times.

The sensor does provide me the range, i.e. the distance to the object, so I can use this to determine if traffic is in near lane or far lane, an indication of direction of flow. (Not implemented yet).

Download Arduino (C++) file