Using Sonar To Measure Traffic Speeds

One of the most common ways of measuring the speed of a vehicle is by using radar, which typically involves generating radio waves, directing them at a moving vehicle, and measuring the various ways that they return to the device. This is a tried-and-true method, but can be expensive and technically complex. [GeeDub] wanted an easier way of measuring vehicles passing by his home, so he switched to using sonar instead to measure speeds based on the sounds the cars generate themselves.

The method he is using is similar to passive sonar in submarines, which can locate objects underwater based on the sounds they produce. After a false start attempting to measure Doppler shift, he switched to time correlation using two microphones, essentially using stereo audio input to detect subtle differences in arrival times of various sounds to detect the positions of passing vehicles. Doing this fast enough and extrapolating the data gathered, speed information can be calculated. For the data gathering and calculation, [GeeDub] is using a Raspberry Pi to help keep costs down, and some further configuration of the microphones and their power supplies were also needed to ensure quality audio was gathered.

With the system in place in a window, it detected around 9,000 vehicles over a three-day period. The software generates a normal distribution of vehicle speeds for this time, with the distribution centered on around 35 MPH, slightly above the posted speed limit of 30. As long as there’s a clear line of sight to the road using this system it’s just as effective as some other passive systems we’ve seen to measure vehicle speed. Of course, active speed measurement systems are not out of the realm of possibility if you’re willing to spend a little more.

21 thoughts on “Using Sonar To Measure Traffic Speeds

  1. This is such a neat project. I live in a narrow, residential street, with a 30mph limit, but the street is used as a rat-run, by drivers who habitually exceed the 30mph limit.

    Some arrogant drivers look at as a challenge to see just how fast they can drive down the street.

    Perhaps, if a camera was incorporated, the vehicle registration plates could be photographed too.

    Persistent offenders could be reported to the authorities.

      1. Thanks for the tip!
        I think video machine vision using openCV is a bit daunting, but it clearly has some nice features. With the heavy lifting already done, I think I will give it a try and compare the performance.

  2. interesting how people who are at home enough to moniter
    traffic,would respond to having eveything they order online,
    double in cost and time to deliver
    and to make things realy fair ,would agree as part of bieng
    allowed to report others,to having there licence imediately
    susspended for commiting the same offence

    1. I don’t think so. You are saying that all fast deliveries take half the time because the drivers drive above the speed limit. So, if the ware got instantaneously in the hands of the driver after someone pays the purchase, he would have to drive twice as fast as the speed limit. Even worse, the ware stays most of the time in the warehouse. So, the driver would have to drive even faster.

      1. our whole society is built on hussle,marginilized
        workers,roped into the “gig economy”,garbage truck
        drivers getting paid as “piece work”,many thousands
        of “personal shoppers”,food deliver,courier drivers,taxis,
        boy and girl racers,a huge number of them getting
        paid from some bodys app,a nice little SAS that they
        manage from home
        you realy want them to slow down?,then get a law passed that mandates that part of the app sending
        them down the road,automaticaly dings them for
        speeding,easy peasy,gps,cell triangulation,guggle maps,inertia sensors,android auto
        oh but wait,then it will be impossible to pit one against
        the other and the result will be a set wage,and working
        conditions for everyone on the road
        and then yes,costs will double

        1. My favorite trend is for “densification” douchebags to call for the elimination of parking in their city, citing the myth that this will magically make it possible to walk 50 miles to work or to carry appliances, lumber, bags of dirt, or a family’s groceries on a bike.

          Then the same douchebags call for the removal of lanes from their streets, making it impossible for delivery trucks to pull out of traffic… and then they complain about trucks blocking the street or bike lane.

    2. I live on a busy corner where idiots try to prove their manhood by gunning it at 3am. Some of them you can hear fade out over the next several *minutes*. They’re not delivering a damn thing except insomnia to this entire side of town.

      1. Except that exhaust noise isn’t really proportional to vehicle speed – so much as design. An electric car could be doing 0-60 pulls on your block and all you’d really hear is tyres squealing.

        If you hear it for minutes, it’s probably just a really loud vehicle like a motorbike. Or a rust bucket with a leaky exhaust… Or something little like a Honda Civic with a stupid aftermarket pipe on it.

        I have the pleasure of owning a sports sedan – I could probably make annoying exhaust noises by your house for 2.5 seconds before (1) being too far away to bother you and (2) lifting off the throttle – with resultant noise reduction.

    3. By your logic then drivers should drive even faster to find the optimum max speed where the cost of cheaper delivered goods is balanced by the cost of maimed drivers.
      How old are you? 14 ? ….

  3. I have been working on a much smaller version of this project for catching cats speeding down a hallway, unfortunately it turns out that cats, unlike cars, are stealth targets. They are too fuzzy for active sonar, too quiet for passive sonar, to small for radar and too quick for cheap ToF laser sensors (10hz). I might have to resort to using a feline ballistic chronograph.

      1. My cats like to tear around the house as fast as possible using the hallway as a drag strip. The idea was to use a simple sonar distance module to check for the presence of cat and calculate their max speed as they pass by and take a picture. Polling the sonar module was quick enough for the speeds required and would work with humans but the cats absorb too much of the ultrasound to get any measurement.

        Next I tried a doppler radar human presence sensor, it outputs a signal who’s frequency is proportional to the speed of the target and amplitude is proportional to the returned radio signal. Again this worked great for people but cats running straight at the module present so small a cross section that the return signal is weaker than the noise floor.

        Finally I grabbed a cheap I2C time of flight laser module, it has a range of about 2 meters, uses an infrared beam that reflects will from cats and is pretty accurate. But it can only be polled at about 10hz which is too slow to catch enough samples as the cats are moving in 2D not just along the line of the beam.

        1. I have a “Hot Wheels” branded radar speed gun, I think it was a clearance item for $10 over a decade ago. IIRC it uses X-band radar. A Hot Wheels car is metal, so it gives a better reflection than a cat, but a cat is bigger, so maybe the effects cancel out? Might be worth a shot, if you can find a similar unit for cheap.

  4. Although maybe out of the poster’s budget, there are some very nice mmWave radar sensors from OmniPreSense (https://omnipresense.com/product-category/sensor/) that work extremely well. The units range in price from $189 to $249, are small, reliable, very accurate, and can be connected to whatever embedded system the user would want. The sensors can be bought from the various online suppliers and so are easy to get. I had one project where I tried several approaches that were less costly than the OmniPreSense device and they all had issues. I bit the bullet, paid the additional $, and never looked back and the system has worked flawlessly for several years. Sometimes time is $… just a thought.

    1. Thanks for the note. One aspect of an active radar I was trying to avoid is the need to put the transmitter/receiver very close to the roadway (< 10 m). This means an outdoor installation with power near the curb which I didn't find appealing. Remote sensing at a significant stand-off distance from the road is a big benefit too.

    1. The driver should decide this, just as they do now, but the default should definetly be the speed limit. A lo of cars already have sign-detection and adaptive cruise-control, and have 2 modes: Constant and “adaptive”(Follow the speed-signs), and will always keep a adjustable distance to the car in front if it’s going slower. My car (Audi) is adjustable from roughly 0.75s to 2 seconds of distance

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.