Object measurements

Hello everyone,

How can we measure length, breadth and height of the object with ultrasonic sensor ?

Suppose that the sensor is in a fixed position facing a flat surface

  • Measure the distance to the flat surface
  • Place the object against the flat surface and measure the distance to the object front face
  • Subtract one distance from the other and you have the first dimension
  • Turn the object and repeat for second dimension
  • Turn the object and repeat for third dimension

You could take all 3 measurements at the same time if the object were placed in a corner instead of against a flat surface but you will need 3 sensors

1 Like

I have 3 different sensors. Do I need to use any formula ?

If I told you that the distance to the wall was 30cm and with the object in place against the wall the distance to the object was 10cm could you calculate the object dimension in that direction

When you say 3 different sensors do you mean 3 sensors of the same type or something else ?

Yes it’s same type of sensors

That makes it easier

Can you measure the distance from the sensor to an object using one of them ?

How about the calculation I asked about in post #4 ?

Yes I can measure the distance

Post your code that does one measurement

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code

They typical ultrasonic sensor output cone is 15 degrees. The granularity of such measurements would not give a near accurate rendering of the object. Use LIDAR, I use a TFMiniP as a visual scanner for my hexapod, with a 2 degree beam width, I am able to discern a 2 inch pipe at 10feet. Better LIDAR’s give better results.

This is code for distance

const int trigPin =9;
const int echoPin =10;

long duration;
int distance;

void setup() {

pinMode (trigPin, OUTPUT);
pinMode (echoPin, INPUT);
Serial.begin(9600);

}

void loop() {
digitalWrite (trigPin, LOW);
delayMicroseconds (2);

digitalWrite (trigPin, HIGH);
delayMicroseconds (50);
digitalWrite (trigPin, LOW);

duration = pulseIn (echoPin, HIGH);
distance = duration*0.034/2;

Serial.print ("Distance: ");
Serial.println (distance);

}[quote=“zeel_749, post:1, topic:856435, full:true”]
Hello everyone,

How can we measure length, breadth and height of the object with ultrasonic sensor ?
[/quote]

Have you read the suggestions earlier in the topic ?
If you can measure from the sensor to a surface then you can measure to the face of an object placed on that surface and calculate the dimension of the object in that direction

Either place the object in each of the 3 orientations and measure each dimension one after the other, or set up the 3 sensors pointing to the 3 surfaces of a corner, place the object in the corner and measure all 3 dimensions at once.

Where are you stuck ?