Coding Camp – Part 10: Measure the distance with Ultrasonic

Let us learn how to use GPIO output, IRQ input and system timer with a Ultrasonic distance measuring module. Note that the distance sensor is additionally required (https://wiki.odroid.com/odroid_go/arduino/31_ultrasonic_distance_meter).

Figure 1 - You can have a portable Ultrasonic distance meter in your hand
Figure 1 – You can have a portable Ultrasonic distance meter in your hand

Requirements

Make sure that you have these products:

  • ODROID-GO
  • Ultrasonic Ranging Module HC – SR04
  • Jumper Wires and a Breadboard full size or half size
  • An auxiliary battery if using it portable
  • This module requires 5V input power, but ODROID-GO outputs 3V3 for the power pin(#6) on its header pins. Thus, it is required to use the 5V USB VBUS pin(#10) with an external USB power source.
  • Alternatively, you can use a Step-up DC-DC converter and a level shifter.
  • A MicroUSB cable

You will also need to set up the development environment for Arduino on your system.

Hardware Setup

Please refer to Figure 2 when you set up your hardware. We used the following parts:

  • Ultrasonic sensor: HC-SR04
  • Step-up DC-DC 3V3 to 12V(set to 5V for now) converter: MT3608
  • Logic level converter: BSS138
  • ODROID-GO: fritzing_odroid-go.fzpz
  • Mini-360 DC-DC Buck converter: mini-360_dc-dc_buck_converter.fzpz
  • HC-SR04: hc-sr04.fzpz

Figure 2 - Wire Diagram
Figure 2 – Wire Diagram

Next, download the Fritzing example file from odroid-go-ultrasonic-sensor.fzz.

Import and Compile, Upload to ODROID-GO

Click the Files → Examples → ODROID-GO → Applications → Ultrasonic_Distance_Meter menu to import and press CTRL-U to compile/upload.

Figure 3 - Load Arduino Ultrasonic Distance Meter Application
Figure 3 – Load Arduino Ultrasonic Distance Meter Application

Uploading is complete when the message “Hard resetting via RTS pin…” is seen.

Testing

After the upload completes, ODROID-GO reboots automatically. The screen shows a measured distance in inch, cm units when an obstacle is detected at the front of the Ultrasonic sensor. If the measurement conditions are not met, such as a distance that is too far or too short, the result text on the screen will be colored red. If it measures normally, the text will be colored green.

Be the first to comment

Leave a Reply