One of the most important types of information an internet of things device might want to collect is either when something moves in front of it or if it is about to collide with something. It is especially important if the device is a mobile one. In order to acquire this information some sort of range sensor is required. Two that we have been working with here at UNH Connectivity are the HC-SR04 ultrasonic range sensor and the Sharp GP2Y0A02YK0F Infrared range sensor. While one would expect either device to get the job done, there are some differences.
The environment and application of the device has a huge impact on the operation of these sensors. Our project requires range measurements to be taken outside in all weather conditions during the day. Initially when using the infrared range sensor inside it produced clear data but, when it was brought outside for further testing, the results became sporadic.
An infrared range sensor works by sending our infrared light and measuring the strength of the light that is reflected. The stronger the reflection the closer the object! Something that can interfere with the infrared sensors operation is other sources of infrared light. The sensor will measure more infrared light as being reflected even though some of the light is not part of the reflection. Our results outside were erroneous because the sun emits light in the same frequency as the infrared spectrum used to by the sensor.
The opposite effect was found for the Ultrasonic sensor. Outdoors the range sensor properly operated within the manufacturer specified operational range. However, when measuring inside the building, the sensor measured values around 40cms whether or not there was anything in front of it.
Ultrasonic sensors use a similar method of range sensing, by sending out a pulse of sound at an ultrasonic frequency and measuring the time it takes to hear the sound bounce back. Using the known speed of sound and the time interval between the pulse and the echo the distance can be calculated. If there are other sources of ultrasonic noise in the vicinity, the sensor will hear that and give an improper distance measurement. It is also possible for a previous pulse to echoed off multiple things and seem to trigger the sensor early. Although ultrasonic sensors should in theory operate indoors fine there was some sort of interference with our tests indoors giving us inconsistent results.
Infrared range sensors will work best for an indoor application where the sun won’t interfere with it. Alternatively the ultrasonic sensor worked better for us outside where we weren’t getting an echo from our small room. That’s just something to consider when choosing range sensing hardware!