# Best sensor to use for lineal distance

**URL:** <https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427>\
**Category:** Uncategorized\
**Created:** [18 September 2021 01:17 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427 "2021-09-18T01:17:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gavin177069](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gavin177069](https://forum.core-electronics.com.au/u/Gavin177069)\
**Post date:** [18 September 2021 01:17 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/1 "2021-09-18T01:17:07Z")

</div>

Hey all,

i am new to the world of Arduino and having heaps of fun with it. But it’s time to put it to work. I want to make a lineal metre counter like the old school wheel counter but want to do it with sensors and not need to physically touch the surface I’m measuring.

My objective is - count the total lineal meters of timber i feed through a machine, count the number of individual lengths and the time from when the first length enters to when the last board exits.

I would love some suggestions on the best way to do this and the best sensors to use. the proximity of the timber to the sensor would be as close as 5mm and as far as 250mm.

TIA.

---

<div class="post-metadata">

**Author:** ![Liam120347](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/liam120347/32/5003_2.png) [@Liam120347](https://forum.core-electronics.com.au/u/Liam120347)\
**Post date:** [18 September 2021 05:09 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/2 "2021-09-18T05:09:40Z")

</div>

Hey Gavin,

Glad to hear!  
Are you able to mod the machine a little bit? I’d say adding a [rotary encoder](https://core-electronics.com.au/rotary-encoder-1024-p-r-quadrature.html)(this is just an example, I’d measure up the machine and pick one to suit - RPM of the shaft and diameter) would the easiest way to going about figuring out the length of the timber and to detect the presence [a laser TOF sensor](https://core-electronics.com.au/piicodev-distance-sensor-vl53l1x.html) or [ultrasonic distance sensor.](https://core-electronics.com.au/hc-sr04-ultrasonic-module-distance-measuring-sensor.html)

A lil bit of a tangent although relevant: With many projects there will be many ways to do it and some will be easier or more accurate than others…first point fixation and sunken cost fallacy come into play a lot as well - Zack Freedman has a couple great videos on this topic

- [Here's What's Preventing You From Finishing Projects - YouTube](https://youtu.be/L1j93RnIxEo)
- [How to Finish Your Weekend Projects in One Weekend - YouTube](https://youtu.be/72a85tWOJVY)

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [18 September 2021 05:44 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/3 "2021-09-18T05:44:54Z")

</div>

Hi Gavin

> [@Gavin177069](#):
>
> with sensors and not need to physically touch the surface I’m measuring.

This could get a bit tricky.  
What size are we looking at. Large sawmill type thing or small hobby workshop style. What sort of accuracy are you looking at. Possibly the easiest if there are rollers involved would be count roller revolutions and calculate but that would assume no roller slippage.

Without having a roller on or something attached to the timber this could be a bit more tricky that seems at first sight. I think to measure acoustically or even optically to the end of the timber this end would have to be a respectable size.

Maybe a tape measure and pen and paper???  
Cheers Bob

---

<div class="post-metadata">

**Author:** ![Gavin177069](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gavin177069](https://forum.core-electronics.com.au/u/Gavin177069)\
**Post date:** [18 September 2021 06:17 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/4 "2021-09-18T06:17:43Z")

</div>

Hi Liam. Thanks for the reply.

I was hoping not to mod the machine but it to be more of a simple add on.  
A rotary encoder was my first thought but the feed rollers run continuously and are difficult to get to obviously for safety reasons.

I asked the same question in a FB group and an ultrasonic sensor was a suggestion I received there.

This would involve me calculating the roller feed rate and having the sensor trigger at the start and end of each board. The duration of the triggered sensor calculated with the feed rate I.e. mm/sec would give me the length.

Cheers for the links. I’ll take a look at them.

---

<div class="post-metadata">

**Author:** ![Gavin177069](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gavin177069](https://forum.core-electronics.com.au/u/Gavin177069)\
**Post date:** [18 September 2021 06:30 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/5 "2021-09-18T06:30:59Z")

</div>

Hi Robert.

Thanks for your suggestion. I just replied to Liam who also suggested using the rollers but is a bit difficult with there location atc.  
We aren’t talking a big mill but not as small as a hobby scale. I make bespoke furniture and decore pieces. Accuracy at this point of the milling process regarding length isn’t that critical and just wanted to add this into my work flow to track time and quality on a rougher scale. More so for my own curiosity and time management.

Haha. A pen and paper yes and that’s how I do it now but there is no fun in that. The thing I’m loving about this Arduino scheme is it’s at the opposite end of my skill set but still allows me to use my creativity and be inventive.

---

<div class="post-metadata">

**Author:** ![Liam120347](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/liam120347/32/5003_2.png) [@Liam120347](https://forum.core-electronics.com.au/u/Liam120347)\
**Post date:** [18 September 2021 06:39 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/6 "2021-09-18T06:39:16Z")

</div>

Hey Gavin,

Yeah definitely a good call not wanting to mod your machine aha.  
If the machine has a constant feed rate you might be able to take one from the books of 3D printing.

When you set it up a printer you’ll get a bit of material and feed it through, then you’ll take a measurement after say 3 seconds or so and see how far it has moved (This processes is called ‘-step calibration’ and uses a distance instead of speed but same difference). Log that on the Arduino and you’ll have a feed rate(speed) then using a break beam sensor or something (The TOF sensor above could do this as well) from this you will be able to calculate the length of each piece.  
To adjust it you could hard code it directly into the microcontroller (Arduino) or have a screen and adjustment knob to set.

A good brainstorm might lead you to some other ideas that could work better

---

<div class="post-metadata">

**Author:** ![Gavin177069](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gavin177069](https://forum.core-electronics.com.au/u/Gavin177069)\
**Post date:** [18 September 2021 06:59 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/7 "2021-09-18T06:59:47Z")

</div>

hey Liam,

that sound like a plan!

Would ultrasonic be better than IR due to dust?

that’s kinda what i was thinking along the same lines as a 3D printer or CNC stepper calibration. i am thinking i could use a ESP 32 and bluetooth it to my tablet to retrieve the data so could add calibration settings to that. i always have a tablet at hand in my workshop for reading drawings etc.

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [18 September 2021 07:24 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/8 "2021-09-18T07:24:19Z")

</div>

Hi Gavin  
Liam is right. If you know the speed all you need to do is detect the ends of the timber and calculate the length.

This rather defeats your original statement re nothing touching the timber. If you are going down the feed roller path and they are a bit hard to get to you may as well have a wheel contacting the timber. There may be a chance you can set the feed rollers to known speeds then you would not have to measure it as long as the settings are reliable enough

> [@Gavin177069](#):
>
> i could use a ESP 32 and bluetooth it to my tablet to retrieve the data so could add calibration settings to that

Advice (for what it is worth). Get the first (measuring) part working first then you can tackle the exotic bits later. If you don’t attack this in a structured manner you will find yourself going in ever diminishing circles. We all know where that ends up don’t we…  
Cheers Bob

---

<div class="post-metadata">

**Author:** ![Gavin177069](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gavin177069](https://forum.core-electronics.com.au/u/Gavin177069)\
**Post date:** [18 September 2021 07:31 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/9 "2021-09-18T07:31:42Z")

</div>

Hi Bob,

yeah i dont really want anything running in the timber for a few reasons.

this has given me a few ideas i would like to expore and i agree… KISS principal.  
i am all to familiar with over complicating things.

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [18 September 2021 07:36 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/10 "2021-09-18T07:36:40Z")

</div>

AHHHHH, another believer in good old KISS.  
Cheers Bob

---

<div class="post-metadata">

**Author:** ![Rob110829](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/rob110829/32/3151_2.png) [@Rob110829](https://forum.core-electronics.com.au/u/Rob110829)\
**Post date:** [18 September 2021 10:40 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/11 "2021-09-18T10:40:45Z")

</div>

What technology does an optical mouse use? It doesn’t have to touch the desk although admittedly it has to be so close as to hardly matter. But maybe that tech can be adapted and used a few mm above the surface.

EDIT: I just tried, my mouse still works 2-3mm away.

---

<div class="post-metadata">

**Author:** ![James](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/james/32/4400_2.png) [@James](https://forum.core-electronics.com.au/u/James)\
**Post date:** [23 September 2021 06:12 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/12 "2021-09-23T06:12:44Z")

</div>

Hi Rob and all,

Found this sensor and think it could be useful, It’s basically a mouse sensor but longer range:

> **[Pimoroni Near Optical Flow SPI Breakout (PAA5100JE)](https://core-electronics.com.au/pimoroni-near-optical-flow-spi-breakout-paa5100je.html)**
>
> Detect motion of close-up surfaces with this Breakout Garden compatible optical navigation breakout - great for floor tracking for ground-dwelling robots!

Have a read and see if this is helpful  
-James

P.S. Just found out it has a longer range brother:

> **[Pimoroni PMW3901 Optical Flow Sensor Breakout](https://core-electronics.com.au/pimoroni-pmw3901-optical-flow-sensor-breakout.html)**
>
> This fancy optical flow sensor detects the motion of surfaces in front of it, from ~80mm to infinity! It's great for DIY drone builds, and it's compatible with Pimoroni's new Breakout Garden HAT with SPI.

Only catch is that it’s gotta be at least 80mm away

---

<div class="post-metadata">

**Author:** ![Rob110829](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/rob110829/32/3151_2.png) [@Rob110829](https://forum.core-electronics.com.au/u/Rob110829)\
**Post date:** [23 September 2021 07:41 UTC](https://forum.core-electronics.com.au/t/best-sensor-to-use-for-lineal-distance/11427/13 "2021-09-23T07:41:08Z")

</div>

Ha ha, just saw this and I came back to this thread to post about it, you beat me to it 😀

Will be interesting to see if it does the job.

Rob
