Simple 3D Digital Ruler (Width/Length/Height/Area/Volume)



This Simple Project explains how to Create a Arduino based basic 3D digital ruler using ultrasonic sensors.

Ultrasonic sensors positioned along X,Y & Z planes to measure Length, Width & Height.

By using 4 push buttons the user can choose between Length/Width, Height, Area & Volume.

Measured data is shown in LCD Module.

The circuit is powered by a 5V rechargeable battery pack.

This circuit arrangement can be contained in a small  casing for easy usage.

Note that the ultrasonic sensors must be positioned along X,Y & Z properly for accurate readings.
Also, ultrasonic sensor range is 2cm to 400cm.Any measurement beyond that range will not be accurate. 

Tools & Components

1 X Arduino Nano

3 X Ultrasonic Sensor (HC-SR04)

1 X 16x2 LCD Module

1 X 10K Potentiometer

4 X Push Buttons

1 X Rechargeable Battery

Connecting Components



Ultrasonic Sensor 01 (Length Measurement) Trig. Pin - Arduino Pin D5

Ultrasonic Sensor 01 (Length Measurement) Echo Pin - Arduino Pin D4

Ultrasonic Sensor 02 (Width Measurement) Trig. Pin - Arduino Pin D3

Ultrasonic Sensor 02 (Width Measurement) Echo Pin - Arduino Pin D2

Ultrasonic Sensor 03 (Height Measurement) Trig. Pin - Arduino Pin D6

Ultrasonic Sensor 03 (Heigth Measurement) Echo Pin - Arduino Pin D7

LCD Module D7       - Arduino Pin A4

LCD Module D6       - Arduino Pin A3

LCD Module D5       - Arduino Pin A2

LCD Module D4       - Arduino Pin A1

LCD Module E         - Arduino Pin D13

LCD Module RS       - Arduino Pin A0

LCD Module Vcc       - +5V

LCD Module Vss       -  GND

LCD Module LED(-)  -  GND

LCD Module LED(+) - +5V

LCD Module VEE      - Potentiometer Sig. Pin

Push Button (Length/Width)  - Arduino Pin D12

Push Button (Height)             - Arduino Pin D11

Push Button (Area)                - Arduino Pin D10

Push Button (Volume)           - Arduino Pin D09

Arduino Code

//2020 CraftyBin.blogspot.com
//Author : Chathura H.

#include <LiquidCrystal.h>
LiquidCrystal lcd(A0, 13, A1, A2, A3, A4);


#include <HCSR04.h>
UltraSonicDistanceSensor distanceSensor1(5, 4);
UltraSonicDistanceSensor distanceSensor2(3, 2);
UltraSonicDistanceSensor distanceSensor3(6, 7);

void setup() {
  Serial.begin(9600);
  pinMode(9,INPUT);
  pinMode(10,INPUT);
  pinMode(11,INPUT);
  pinMode(12,INPUT);
  lcd.begin(16, 2);
  }

void loop() {

  Serial.println(distanceSensor1.measureDistanceCm());
  Serial.println(distanceSensor2.measureDistanceCm());
  Serial.println(distanceSensor3.measureDistanceCm());
  delay(500);
 
  if(digitalRead(12) == 1){lcd.print("Length: ");
  lcd.print(distanceSensor1.measureDistanceCm());   
  lcd.print("Cm");
  delay(500);
  lcd.clear();
  delay(1);

  lcd.print("Width: ");
  lcd.print(distanceSensor2.measureDistanceCm());   
  lcd.print("Cm");
  delay(500);
  lcd.clear();
  delay(1);
  }

  if(digitalRead(11) == 1){
  lcd.print("Height: ");
  lcd.print(distanceSensor3.measureDistanceCm());   
  lcd.print("Cm");
  delay(500);
  lcd.clear();
  delay(1);
  }

  if(digitalRead(10) == 1){
  lcd.print("Area: ");
  lcd.print(distanceSensor1.measureDistanceCm() * distanceSensor2.measureDistanceCm());   
  lcd.print("Cm^2");
  delay(500);
  lcd.clear();
  delay(1);
  }

  if(digitalRead(9) == 1){
  lcd.print("Volume: ");
  lcd.print(distanceSensor1.measureDistanceCm() * distanceSensor2.measureDistanceCm() * distanceSensor3.measureDistanceCm());   
  lcd.print("Cm^3");
  delay(500);
  lcd.clear();
  delay(1);
  }
}


Safety First !
Always Connect the power supply if you are absolutely sure that the components are connected correctly without changing polarity and short circuited the wiring.
Even if it seems nothing is wrong : DOUBLE CHECK EVERYTHING !!
Your Feedback is very important to us. 
Please Leave a comment about how you feel about this project.







5 Comments

  1. I always wonder what the precision of this kind of ultrasonic sensors is. Can anyone give me a clue?

    ReplyDelete
    Replies
    1. Based on tests the specifications of the HC-SR04 are:
      - FOV (full cone): horizontal ~21º, vertical ~4º
      - Spatial resolution (full cone): ~0.6-1.4º
      - Range: tested from 5 to 200 cm
      - Accuracy: absolute error ~0.035 cm/cm.
      - Precision: standard deviation ~0.1-0.5 cm

      Delete
  2. Nice project. I want to try. Eventually you can help with some codes ? If not here, to my email?

    ReplyDelete
  3. Your blog is really impressive, you included much knowledge for us. It genuinely had good content. Thanks for sharing this.microsonic ultrasonic sensors

    ReplyDelete

Post a Comment

Previous Post Next Post