Using ultrasonic module to check distance
In this week exercise I have decided to test working on ultrasonic module HC-SR04. This module has 2 ultrasonic sensors one of them sends a pulse and other one receives. This makes it possible to measure distance.
HC-SR04 Pins
Ultrasonic sendor module provided 4 nos of pins to interface it with other controller.
  • VCC : This pin is connect to 5 V power supply
  • Trg : To trigger measurement cycle. Make it ON for 10uS
  • Echo : This will become ON for travel time and give reading in uS
Designing of Ultrasonic board
I have decided to take a reference from Ultrasonic board available at Here
I have started designing it in Eagle
Screenshot at 2017-05-16 21_16_52.jpg
Screenshot at 2017-05-16 21_18_57.jpg
Screenshot at 2017-05-16 21_24_46.jpg
Screenshot at 2017-05-16 22_35_16.jpg
Screenshot at 2017-05-16 22_36_36.jpg
Screenshot at 2017-05-16 22_45_57.jpg
Screenshot at 2017-05-16 22_46_00.jpg
Screenshot at 2017-05-16 22_50_35.jpg
Screenshot at 2017-05-16 22_56_41.jpg
Screenshot at 2017-05-16 23_03_18.jpg
Screenshot at 2017-05-16 23_05_07.jpg
Screenshot at 2017-05-16 23_08_42.jpg
Final Board Designed using Eagle
This board is an improved version of board. Which has eliminated all airwires.
Components soldered on Board
I had observed that initially there was a mistake in board
I had resolved it using a jumper wire connecting GND pin of HC-SR04. Later I had also modified board layout to correct this issue.

Programming of Board

    Steps of programming

  • Program Board Using Arduino or FabISP Use prgram
    You need to install TKinter python library to create UI using python. Without which you will encounter with following error.
    Traceback (most recent call last):
      File "hello.HC-SR04_SYK.py", line 17, in 
        from Tkinter import *
      File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in 
        raise ImportError, str(msg) + ', please install the python-tk package'
    ImportError: No module named _tkinter, please install the python-tk package
    
    Instructions to install Tkinter can be found here -> http://www.greenteapress.com/thinkpython/swampy/install.html
    On Linux you can use following command to install Tkinter
    sudo apt-get install python python-tk
    Additionally you may encounter with error like
    Traceback (most recent call last):
      File "hello.HC-SR04_SYK.py", line 18, in 
        import serial
    ImportError: No module named serial
    Resolve this by installing serial.
    sudo apt install python-pip //First install pip
    pip install pyserial
    This will install required pyserial package
  • Connect board to PC using FTDI USB cable
  • Run hello.HC-SR04_SYK.py python ptogram to start UI
    python hello.HC-SR04_SYK.py

Video of Ultranosic sensor working

Files for download

This board is an improved board which has eliminated all airwires
InputBoard.brd InputBoard.sch hello.HC-SR04.c hello.HC-SR04.make hello.HC-SR04_SYK.py