This article describes the building and development of a warning device to help alleviate the danger of a concealed entrance to a busy ‘A’ road in the Peak District in the UK. The plan is simply to have a traffic sensor some distance up the road which turns on a warning light at the concealed entrance to indicate oncoming traffic. The sketch shows the approximate positions of the warning light and the sensor.
The sensor needed to be discrete in the sense that it must not interfere with either the road or the traffic so it had to be able to detect the traffic whilst still being set back from the road. This was not so that it had to be hidden, just that I didn’t want to get into trouble because of vehicles clouting it as they went past.
The sensor is based on an ultrasound proximity sensor controlled by an Arduino microcontroller. The microprocessor causes the ultrasound sensor to emit a short 30kHz pulse and then it waits for the echo. If it returns between 5ms and 20ms, it means that there’s some object on this side of the road. If it has to wait longer than that it assumes that either there’s no traffic or the traffic is on the other side of the road.
The system uses just 3 wires from the Arduino, one to control and receive data from the sensor and 2 to control the LEDs in the warning light. It also runs from a regulated 12V supply. So, basically its dead simple, its a switch that turns on and off a light. There is some slight intelligence in the program running in the microcontroller to filter out “noise” so that we only recognise real traffic.
A bit if research
Initially, I built a prototype using the development version of the Arduino, called the Uno which was connected to an ultrasound sensor and an LCD panel. As you can see in the picture the prototype was battery-powered and had the addition of an LCD panel so that I could see more clearly the kinds of readings the sensor was getting.
Please note the careful addition of some sellotape to keep the LCD to the wooden box! The program was written so that each time a vehicle went past, the LCD displayed the time of the echo in microseconds, followed by the loop count. The basic operation of the program is extremely simple as shown below:
The counter shown on the LCD above shows a loop count of 11 which is typical for a small car travelling about 50 mph. Lorries tend to register over 40 loop counts. The flowchart above shows that the program is set to ignore the first 2 loops to eliminate random ultrasound noise in the environment. When the first loop occurs that resets the counter, there’s also some more program code that displays the current loop count and echo time on the LCD. Its only shown if a vehicle has actually been detected.
Once I was happy with the operation, I built a ‘production’ version which was basically a tiny, cheaper version of the Arduino called the Arduino Pro Mini which is only 33mm x 18mm. I ran this off a regulated 12V supply which I found lying around in the bottom of a drawer of bits and pieces! Whenever I have a hardware failure of anything electrical I always try to salvage something even if only the plug on the lead! In this case I assume it was some kind of router or modem or something which had failed and I was left with one of these switch mode DC power supplies by 3COM in a plug which produced 12V at 1.5A – ample for my needs. So I just needed to wire up 2 small PCBs, the ultrasound sensor and the Arduino controller. Here’s the rear view in the back of the MDF box I made:
You can see the red and black wires come from the 12V DC power supply and the blue and yellow wires are the data transmission wires. I glued the PCB’s in place with a small glue gun. From the front it all looks quite presentable:
The loudspeaker horn-shaped enclosure is just to keep the rain off the ultrasound sensor rather than for any acoustic benefit. 175 yds down the road we have the LED gate lights which get switched on when the system detects a vehicle as shown:
The top red light shows that there is power to the system. The second row of green lights flicker and are there to reassure me that the program is running. If it crashes, these will be either fully on like the red ones in the second picture or off. either way I will know that the vehicle detection has failed. Finally the third row of lights come on to warn that a vehicle is coming. The are high brightness red LEDs because I was concerned about the sun shining on the light and confusing whether it’s on or not. There’s absolutely no issue here. When it’s on you definitely know about it. All these enclosures, as well as being painted green are also coated in copious coats of yacht varnish to try to keep out the moisture.
At some stage I’ll have to insert the inevitable YouTube video of a car coming down the road and switching on the light!
As soon as I’ve got everything together, I’ll provide a download of the technical aspects of this, the circuit diagram and the actual program. In the meantime you might be interested in the cost. It basically breaks down into 4 items:
|Ultrasound Sensor||Proto-Pic Ltd||£14.00|
|Arduino microcomputer||Proto-Pic Ltd||£13.00|
|LEDs, and components for gate lamp||Technobots||£4.50|
The wood, paint, varnish, 12v power supply etc also had a cost but as these were bits just lying around in the garage I can’t really put a value on them. The active components came to about the same as the 200 yds of alarm cable, but the 6 seconds of notice we get of oncoming traffic is worth every penny.
I’ve just discovered a really cheap doppler radar module (around £30) which is 1/10th of the previous one I found. So I’d quite like to experiment with this, then it would be worth monitoring the speed of the traffic as well as the frequency, and this could then be uploaded to a server. You will have to come back in a few months to see if we’ve got anywhere. I have another urgent project which will have to come first though – a seismometer!