# Distance measuring (particular ambient conditions)

**URL:** <https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141>\
**Category:** Sensors\
**Created:** [November 30, 2023, 8:46am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141 "2023-11-30T08:46:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 8:46am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/1 "2023-11-30T08:46:51Z")

</div>

Good morning,  
I am creating a simple robot to mark some lines on a field. My problem is that I need a distance sensor to measure the distance of my robot from the wall so that the marked line is as much straight as possible (parallel to the wall). However the sensor should satisfie two basic requirements:

1. It should measure distances between 1 to 5 meters
2. It should not be too pricy (let's say less expensive than 10 dollars)
3. It should be able to take the measurament even if the wall has a really irregular texture

Anyone has an idea on how to achieve this?  
Thank you all in advance

---

<div class="post-metadata">

**Author:** ![wvmarle](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wvmarle/32/1013044_2.png) [@wvmarle](https://forum.arduino.cc/u/wvmarle)\
**Post date:** [November 30, 2023, 10:26am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/2 "2023-11-30T10:26:51Z")

</div>

Get a distance sensor that can handle that range.  
Like the ultrasonic HC-SR04 or ToF based VL53L0X. Both are cheap, less than a dollar or a few dollars depending on what dollars you're using.

---

<div class="post-metadata">

**Author:** ![anon95813201](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon95813201](https://forum.arduino.cc/u/anon95813201)\
**Post date:** [November 30, 2023, 10:57am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/3 "2023-11-30T10:57:28Z")

</div>

> [@anon39181962](#):
>
> is as much straight as possible

That's quite a vague requirement. Would +/- 5cm be good enough?

---

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 11:29am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/4 "2023-11-30T11:29:41Z")

</div>

Probably not.  
+/- 1cm is the maximum.  
There's a reason behind this number: the marked line is 10 cm wide so I accept maximum 1 cm of deviation from the absolute straight path (or in other words a 10% error margin)

---

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 11:32am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/5 "2023-11-30T11:32:25Z")

</div>

From my experience ultrasonic sensor cannot handle 5 meters distances with a good level of precision. I have never used ToF sensosr but I have read online that they are not good for extremely rough textures. Am I wrong?

---

<div class="post-metadata">

**Author:** ![anon95813201](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon95813201](https://forum.arduino.cc/u/anon95813201)\
**Post date:** [November 30, 2023, 11:36am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/6 "2023-11-30T11:36:51Z")

</div>

> [@anon39181962](#):
>
> +/- 1cm is the maximum.

Probably not possibe on a 10 dollar budget.

---

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 11:43am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/7 "2023-11-30T11:43:06Z")

</div>

Ok then what percentage of error on 10 cm should I admit to stay in my budget?

---

<div class="post-metadata">

**Author:** ![anon95813201](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon95813201](https://forum.arduino.cc/u/anon95813201)\
**Post date:** [November 30, 2023, 11:53am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/8 "2023-11-30T11:53:13Z")

</div>

Give me a few days

---

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 11:57am UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/9 "2023-11-30T11:57:19Z")

</div>

Otherwise are there any ways to ensure that the line is straight?

---

<div class="post-metadata">

**Author:** ![wvmarle](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wvmarle/32/1013044_2.png) [@wvmarle](https://forum.arduino.cc/u/wvmarle)\
**Post date:** [November 30, 2023, 12:09pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/10 "2023-11-30T12:09:10Z")

</div>

Now you give a different requirement.

First you asked for x cm from a wall, now you ask for the line to be straight. That are DIFFERENT requirements, which have different possible solutions. If you have a straight wall that is completely free of obstacles for the length of the line you want to draw, following that COULD be a solution if the line happens to be parallel to that wall.

For straight lines I'm thinking of laser guidance, though don't recall having seen that in conjunction with Arduino/hobby projects. Basically place the robot on one end of the line, and a beacon on the other end, and have the robot go straight towards that beacon. Should be quite similar to line following though the line sensing part may be a bit trickier.

---

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 12:14pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/11 "2023-11-30T12:14:20Z")

</div>

Ok I am sorry. The correct requirement is the line must be parallel to wall

---

<div class="post-metadata">

**Author:** ![anon95813201](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon95813201](https://forum.arduino.cc/u/anon95813201)\
**Post date:** [November 30, 2023, 12:17pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/12 "2023-11-30T12:17:56Z")

</div>

This device has an acuracy of +/-2.5cm at 5 meters or less but it's more than $10

> **[LIDAR-Lite v3 - SEN-14032 - SparkFun Electronics](https://www.sparkfun.com/products/14032)**
>
> This is the LIDAR-Lite v3, a compact optical distance measurement sensor. When space and weight requirements are tight, the LIDAR-Lite v3 soars!

---

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 12:25pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/13 "2023-11-30T12:25:56Z")

</div>

Unfortunately price is a problem because I have some mechanical and electronical equipment on my robot that already costs a lot. If there are any cheaper ways to do the job it would be perfect. Otherwise I will just pay

---

<div class="post-metadata">

**Author:** ![anon95813201](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon95813201](https://forum.arduino.cc/u/anon95813201)\
**Post date:** [November 30, 2023, 12:36pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/14 "2023-11-30T12:36:27Z")

</div>

Offhand I don't have a solution.  
Maybe another forum member has done something similar with the acuracy you want.

---

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 12:42pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/15 "2023-11-30T12:42:09Z")

</div>

Maybe if I explain you what this robot should do it would be easier to find a solution together.

I own a small football court where I usually play with my friends. The court is not perfect, the surface it's not perfectly even and also the football goals are not perfectly aligned.

Since today we always used a manual machine to mark lines with chalk powder but it's always a boring work that requires a lot of time.

I am trying to create a robot that can do this job for us marking lines with powder chalk. The best idea I had to try to make the lines is to make them parallel to walls as we used to do when we did this job manually. I don't know if it is a good idea or maybe i should switch to another method to solve the problem.

---

<div class="post-metadata">

**Author:** ![anon95813201](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon95813201](https://forum.arduino.cc/u/anon95813201)\
**Post date:** [November 30, 2023, 12:46pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/16 "2023-11-30T12:46:02Z")

</div>

Are you saying that when you did it manually you were able to keep the distance of the line from the wall to within +/- 1cm. How did you do that?

---

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 12:49pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/17 "2023-11-30T12:49:48Z")

</div>

I didn't think about this particular 😅. Excuse me if it was a loss of time.  
We were surely able to achieve pretty straight lines without curves and quite parallel to wall (we measured the distance from the wall at one end of the court, placed a small wood piece in that point, then went to the other end of the court, measured the distance from the wall, placed another small wood piece, put a string between them and followed that string). I hope the job of putting and removing references (as the wooden pieces) could be bypassed in some way

---

<div class="post-metadata">

**Author:** ![anon95813201](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon95813201](https://forum.arduino.cc/u/anon95813201)\
**Post date:** [November 30, 2023, 12:55pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/18 "2023-11-30T12:55:31Z")

</div>

It's not a simple problem.

---

<div class="post-metadata">

**Author:** ![anon39181962](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@anon39181962](https://forum.arduino.cc/u/anon39181962)\
**Post date:** [November 30, 2023, 12:56pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/19 "2023-11-30T12:56:54Z")

</div>

Unfortunately I know but I hope to find a solution with the help of the members of the forum. Otherwise we will do it manually again

---

<div class="post-metadata">

**Author:** ![anon95813201](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon95813201](https://forum.arduino.cc/u/anon95813201)\
**Post date:** [November 30, 2023, 1:00pm UTC](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141/20 "2023-11-30T13:00:03Z")

</div>

Give it a day, forum members are all over the world.

[Next page](https://forum.arduino.cc/t/distance-measuring-particular-ambient-conditions/1195141.md?page=2)
