Ultrasonic Tape Measure




About: Lazy Old Geek

Have you ever wanted an ultrasonic tape measure, like this Stanley? (See picture). Well, I have but then I am a Lazy Old Geek. I don’t really need one but I thought I’d try to make one. And naturally, I thought of an Arduino.

August 2012 update: I just found out the software used in this Instructable does not work in the latest Arduino environment, 1.0. I think it is the LCDKeypad library but haven't found an updated version or software fix. However, this does work with version 023. LOG

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Parts List

Arduino                                  $17.60 (Duemilanove 2009) ebay.com
HC-SR04 Ultrasonic           $  4.61 ebay.com

LCD Keypad (Arduino)       $  8.88 ebay.com

Now I realize this is about $30 where the Stanley is available for around $24 but these parts are not committed to one function like the Stanley is.

Parts selection:
I wanted an Arduino that was shield compatible. I already have two, a Freeduino and Seeduino so I decided to buy a third. Right now, one of the best deals I liked is for a standard Arduino Duemilanove 2009 on ebay.
By the way, mine came with an Atmega 328-PU instead of the ‘standard’ Atmega328P-PU. I discussed this in another Instructable:


The LCD keypad also has Arduino support plus five user pushbuttons and a 16x2 (16 characters x two rows) display.

Step 2: Mechanical Design

First:I checked the Arduino pins used by the LCD Keypad. They are A0, D4, D5, D6, D7 and D8.
I’d already tested the HC-SR04. I’d set it up to use D2 and D3 and it needs 5V and Ground. So there would be no pin conflicts.

Modification1: The HC-SR04 had male right angle header pins coming out of the bottom of the module. To save room, I wanted them to come straight out of the PCB.
One way: So what I did was unsoldered the four pin connector, removed it and replaced it with straight male pins. (See picture) I also put some electrical tape on the back of the PCB to hopefully prevent it from shorting out.
Better way: That was a hard way to do it. I think a better way would be to take some pliers and carefully straighten the pins. They would be too long but could be cut off.

Second: Tthe LCD keypad is a standard shield and fits right onto a shield-compatible Arduino. The problem is how to connect the HC-SR04 to the system. I didn’t want to solder it directly to the shield or the Arduino.
Well, the LCD keypad has a nice feature. It has the standard male header shield connectors but it also has some extra 0.1” solder pads outside of the shield connectors but connected to the shield pins. (See picture)
This is the schematic for the HC-SR04 wiring that I used. (See picture)
Modification2: On the bottom of the LCD Keypad, I soldered two male header pins for 5Vdc and GND, so that they pointed downward. (See picture) This was so the connectors and wires would be out of the way for viewing the LCD.
On the top side, I soldered three male header pins on D1, D2  and D3. I used three pins so that it was easier to distinguish the two connectors though I only connected wires to D2 and D3.

TIP: If I was thinking ahead, I would probably have soldered complete six and eight pin male header strips. These might be useful for future projects.
Since it is easy to flip connectors, I used some red nail polish to mark one side of each connector and header.

Step 3: Software Design

The LCD keypad and HC-SR04 each have Arduino libraries that have to be added to your Arduino software. Attached
The HC-SR04 libraries had some functions that would print out measurements in inches but I wanted a little better resolution so I wrote my own.

Technical stuff:
Theory of Operation: Basically, the user sends a trigger pulse to the module which sends out an ultrasonic wave. After a period of time the receiver gets back a reflection. The duration determines the distance. The documentation gives a little formula to find distance.
Distance = ((Duration of high level)*(Sonic :340m/s))/2
Now this is a not very clear even for a Geek but I figured out that it meant.
Distance in Meters = Duration in Sec * 340 Meters/Sec/2
The documentation isn’t very clear but the HC-SR04 library has a function called Timing. It is based on pulseIn and returns a duration in microseconds(uSec)
I want Distance in inches

So I used the following algebraic transformations:
Distance M = Dur uS *340M/1000000uS/2
DistancecM=Dur uS*340cM/10000uS/2
Distance In = Dur uS * 133.85827In/10000uS/2
Distance In = Dur uS *.013386 In/2
Distance In = Dur uS *0.00669 In

In my code: distanceIn=ultrasonic.Timing()*0.00669;

For the rest of the world which probably prefers centimeters:
distance cM= ultrasonic.Timing()*0.0170;

I also wrote it so that if the distance is over 60in(5foot) then it would convert the output to feet.

The LCD keypad has 16 characters x 2 lines so I divided it up into four sections. The software is setup so that it will continually sample the distance. If the user presses the ‘Select’ button, it will save the value at one of the four locations and move to the next location.

Some of the manufactured electronic tape measures will actually calculate area and/or volume but I didn’t bother.

My Arduino sketch is attached.


Step 4: Operation and Conclusions

For portability, I used a six-AA battery pack from Adafruit
with rechargeable batteries.

It works pretty good. The resolution is supposed to be 0.3cM(0.12in). That seems reasonable. The range is supposed to be 450-500cM(16.4feet). Now I only got about 11feet. (still investigating).
The effective angle is supposed to be less than 15 degrees so you have to take that into consideration.
Sometimes, when I press the Select button, it fills several locations. I need a debounce circuit. But right now I just push the reset button.

ShopBot Challenge

Participated in the
ShopBot Challenge

Arduino Challenge

Participated in the
Arduino Challenge

1 Person Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

25 Discussions


6 years ago on Introduction

I replicated the tape measure exactly, but hooking up Trig & Echo to 2,3 results in it just showing 0.0 and not measuring. I transferred it to my mega 2560 and it works when assigned pins not connected to the LCD shield. I would like to know what i'm doing wrong with my UNO R3.

Thank You,
Albert L. Chupick

1 reply

Reply 6 years ago on Introduction

The way I would troubleshoot it:
0. Do a visual inspection of your work to look for shorts, solder bridges or cold solder joints.
1. Connect HCSR04 and LCD to UNO R3
2. Without power, with a DMM, measure for continuity between HCSR04 Trigger and D2 on the UNO R3 which is Atmega328 pin 4.
3. Measure continuity between Echo and Atmega pin 5
4. If ok, then turn on power and make sure you have 5V and ground on the HCSR04
5. Load sketch and carefully wiggle all added connections to see if you get any reading.
6. If still not working, turn off power and make sure pin 4 or 5 aren't bent over instead of going into the socket.
7. If still not working and you have one, try a different Atmega328.

Hope this helps.



6 years ago on Step 4

I installed all the library files but after compiling I get this error -

In file included from sketch_dec06a.cpp:2:
C:\Users\Chris\Desktop\ARDUINO\arduino-1.0.1\libraries\HC_SR04Ultrasonic/Ultrasonic.h:11:22: error: WProgram.h: No such file or directory

The HC_SR04 library has been installed. Anyone any ideas please - still relatively a noob . Tx

2 replies

Reply 6 years ago on Step 4

Its ok I got it, for anyone else you need to 'edit' the library files and change anything that says wprogram to arduino if you are using a newer version of arduino.


Reply 6 years ago on Step 4

Thanks for figuring this out. This Instructable was written using Arduino 0023 Environment and I don't have the hardware readily available. When Arduino released 1.0.0, I heard that were some compatibility problems. Usually, when I run into a problem, I'll revert to the older Environment. But your solution is probably better.




7 years ago on Introduction

I'm a total Noob. I can't figure out how to even save this so i can compile it. I can't figure where to save it to. I don't have the sub folders as described.

3 replies

Reply 7 years ago on Introduction

I just discovered that this software will not work with the latest Arduino environments. However you can still get and use older versions like 0023 that does work.



Reply 7 years ago on Introduction

Hopefully, you are using a Windows computer as I'm not familiar with Linux or Mac. I assume you already have the Arduino software loaded onto your computer. You should have a directory called Arduino-???. Mine is Aruduino-0023 for the version number. Under this is a subdirectory called libraries. Unzip the first three downloads and copy the zipped directory into libraries. So under libraries you should have directories called HC_SRO4Ultrasonic, LCD4Bit_mod and LCDKeypad.
The UltraRanger file is the program sketch. I don't think it matters where you store it but I store all of my sketches in a directory under Arduino-0023 called MTS. So it would look like this c:\arduino-0023\MTS\UltraRanger.
TIP: Apparently a .pde file has to be in a subdirectory of the same name. So I have UltraRanger.pde under UltraRanger directory.
Now I'm not sure but it seems like sometimes I had to reboot my computer to get the Arduino environment to see everything.
Now when you start up your Arduino software, you go to file open and find the UltraRanger directory and open up UtraRanger.pde.

Hope this helps.



Reply 7 years ago on Introduction

I have it working now. Finally. I was having the same problem as crack hacker.
When using Arduino-1.0 you have to change all of the WProgram.h to Arduino.h for it to work with the new software. I thought i was downloading it wrong. Very cool project. Thanks for the Instructable.


7 years ago on Introduction

Hey thanks a lot for the instructable! It's very helpful for beginners such as myself. The device's simplicity makes it easy to understand, as well as add new features to it in the future. Your shared knowledge is much appreciated!

1 reply

Reply 7 years ago on Introduction

I started using the Arduinos as they are user friendly and there is so much support online. For all the help I received and receive, I like to pay back with some of my own experiences.



Reply 7 years ago on Introduction

i am having some trouble with the include header for the lcd keypad. i am using arduino 1.0 IDE and the libraries i have downloaded just toss errors when compiling. did you have this trouble?


Reply 7 years ago on Introduction

I didn't have any trouble with the libraries but I think I used Arduino version 22.

I suspect you need to update your Arduino IDE but you might also try to reload the header files. One source is:

though the download is an *.rar file

Iteadstudio has some good information on the HC-SR04.

Hope this helps.



Reply 7 years ago on Introduction

arduino 1.0 is the most current IDE.

not having trouble with the ultrasonic just the lcd keypad thing but i will check out the site you mentioned.

thanks for the reply bro


Reply 7 years ago on Introduction

You're right. I didn't know they changed their revision numbering. If you don't have any luck, you might try 0022, I know mine worked with that one.



7 years ago on Introduction

Very nicely done! I take it that the distance is measured from the very front of the device? Would it be easy enough to add a variable adding the length of the device so that it could be placed against a wall, for example? I'm assuming you could just add the measurement to dist before the printLCD?