Goliath Spring 2018 – Ultrasonic Sensor Testing

Written By: Milton Ramirez (Electronics & Control Engineer)

Verified By: Ernie Trujillo (Project Manager)

Approved By: Miguel Garcia (Quality Assurance)

Table of Contents

Introduction

The ultrasonic sensor works by one side sending an Ultrasonic sound and the other side recording the distance by how long it takes to listen to the echo. The sound that the sensor produces is so low that it cannot be heard by human ears.

Figure 1 – Fritzing diagram of the testing set up.

Parts

  • Arduino Uno R3
  • 4 alligator wires
  • 4 jumper wire t
  • Ultrasonic sensor

Testing

So, for my test, I connect an Ultrasonic sensor to an Arduino Uno microprocessor. Then upload a code that was found in a library called new ping that already had a code called newpinnexample that worked with the ultrasonic and then displayed the values in the serial monitor in Arduino. This code has the delay at 50 ms but I changed this to 300ms, so it can be a little easier to keep track of all the values that are being displayed in the serial monitor in the Arduino program. Another thing I needed to change was the max value since the code had it set to 200cm. I changed this to 500  since most product descriptions for this sensor say that the max distance is between 400cm-500cm.

Figure 2 – Code. Picture of the code used to test the Ultrasonic

Results

For the most part, most of the results I got were similar to what the product description said, the minimum value I was able to get was 2cm. Anything lower than that would result in 0 cm.

Figure 3 – Serial motor capture displaying what happen if you covered you hand over the Ultrasonic sensor.

 

Figure 4 – Serial monitor capture at a fixed point.

As you can see in Picture 3 there seem to be a +/- 1 margin of error in the reading in the Ultrasonic sensor.

Figure 5 – Serial Print of the max values

As you see, the max value that I was able to record was 403cm which is in between the max range in the sensor description, which is supposed to be between 400cm-500cm.

Conclusion

In conclusion, the Ultrasonic sensor seems to be a great option to use in the collision avoidance part of the class’s projects. The only problem with the sensor is that it needs 5V to operate and cannot be directly connected to any pins in the 3Dot board since the 3dot can only supply 3.3V. It might also be tedious to code since you might have to make a condition statement that can overcome the margin of error in the readings.

References

  1. https://www.mouser.com/ProductDetail/OSEPP-Electronics/HC-SR04?qs=wNBL%252bABd93PqZEhuhHkuOw%3D%3D&gclid=Cj0KCQjw0PTXBRCGARIsAKNYfG0ABolQAfXGFxkBtA86J-wariihJlxa73V3iyIKwpgaNUm7F2vtmasaAptuEALw_wcB