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 ?

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

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 ?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.