<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tommy Yu</title>
    <description>The latest articles on DEV Community by Tommy Yu (@erdilrf_tommy).</description>
    <link>https://dev.to/erdilrf_tommy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4178071%2Fa17540fe-c29c-4c3b-9624-fea8258996e1.png</url>
      <title>DEV Community: Tommy Yu</title>
      <link>https://dev.to/erdilrf_tommy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/erdilrf_tommy"/>
    <language>en</language>
    <item>
      <title>Is this reading real? Validity checks for a 1 kHz rangefinder stream</title>
      <dc:creator>Tommy Yu</dc:creator>
      <pubDate>Thu, 19 Nov 2026 15:30:23 +0000</pubDate>
      <link>https://dev.to/erdilrf_tommy/is-this-reading-real-validity-checks-for-a-1-khz-rangefinder-stream-3a82</link>
      <guid>https://dev.to/erdilrf_tommy/is-this-reading-real-validity-checks-for-a-1-khz-rangefinder-stream-3a82</guid>
      <description>&lt;p&gt;A free-running rangefinder gives you a lot of numbers and no promises. The LRF50H, one of our 905 nm modules, streams 4-byte &lt;code&gt;5C&lt;/code&gt; frames at 1 kHz by default, so a flight controller or a PLC sees a new distance every millisecond. Most of them are fine. A few are not, and the few that are not tend to be the ones that matter.&lt;/p&gt;

&lt;p&gt;I am Tommy Yu, an engineer at ERDI TECH LTD, the manufacturer of these modules. This post is about the part after the checksum: how I decide whether a decoded &lt;code&gt;5C&lt;/code&gt; value should be used. The evidence comes from a bench capture our factory recorded on 2026-11-06 for the ArduPilot driver work (ArduPilot/ardupilot#34983). Everything below was checked against the model documents and that capture on 2026-11-18.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the frame gives you
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5C  lo  hi  chk        chk = ~(lo + hi) &amp;amp; 0xFF, little-endian distance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The manual's own example is &lt;code&gt;5C 02 11 EC&lt;/code&gt;. The unit depends on the model, not on the family:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Count is&lt;/th&gt;
&lt;th&gt;Out-of-range marker&lt;/th&gt;
&lt;th&gt;Rated range&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;LRF50H&lt;/td&gt;
&lt;td&gt;centimetres&lt;/td&gt;
&lt;td&gt;65535&lt;/td&gt;
&lt;td&gt;0.05 to 50 m at 90% reflectivity, 0.05 to 15 m at 10%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LRF22VB&lt;/td&gt;
&lt;td&gt;millimetres&lt;/td&gt;
&lt;td&gt;20000&lt;/td&gt;
&lt;td&gt;0.05 to 20 m at 90% reflectivity, 0.05 to 10 m at 10%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So &lt;code&gt;5C 02 11 EC&lt;/code&gt; is 43.54 m on an H module and 4.354 m on a VB module. Reading the wrong row is a factor of ten.&lt;/p&gt;

&lt;p&gt;The checksum is one byte. It catches most line noise, not all of it. A frame that passes was probably received as sent, which is a weaker statement than "the distance is right".&lt;/p&gt;

&lt;h2&gt;
  
  
  Four outcomes, four counters
&lt;/h2&gt;

&lt;p&gt;I keep these separate, because each one points at a different problem:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Skipped bytes.&lt;/strong&gt; The byte was not &lt;code&gt;5C&lt;/code&gt;, or the checksum failed. This is wiring, logic level or noise. In the 2000 frames I replayed it was zero, but that log only holds frames the vendor tool had already accepted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Out-of-range marker.&lt;/strong&gt; The module says it saw nothing usable: 65535 on LRF50H, 20000 on LRF22VB. This is a normal answer, not an error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Beyond the configured maximum.&lt;/strong&gt; The checksum is valid, the value is not the marker, and the distance is bigger than the sensor can measure.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Valid.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Class 3 is the one people forget. The factory's LRF50H log, taken against a wall 1.9 m away, has 2000 frames. 1997 of them read between 189 and 204 cm (median 196 cm). Three read 31496, 36977 and 39688, which is 315, 370 and 397 m, on a module rated for 50 m. None of them is the &lt;code&gt;0xFFFF&lt;/code&gt; marker. The vendor tool accepted all three.&lt;/p&gt;

&lt;p&gt;I cannot tell you why. The log holds decoded values, not raw bytes, so I cannot say whether the module emitted them or whether corrupted frames happened to pass a one-byte checksum. What I can say is what they do to a naive consumer. Two of the three, at log positions 867 and 875, are eight frames apart. If your consumer averages the last nine frames, the second spike lands in a window that already holds the first one. I computed that mean over this log: it reaches 77.6 m while the wall has not moved.&lt;/p&gt;

&lt;p&gt;The rule I use is blunt: anything above the configured maximum is dropped and counted. The ArduPilot driver takes the same view and treats any frame beyond &lt;code&gt;RNGFNDx_MAX&lt;/code&gt; as out-of-range instead of averaging it.&lt;/p&gt;

&lt;p&gt;Do not use the datasheet's best-case range as the gate. LRF50H is specified to 50 m at 90% reflectivity and 15 m at 10%. A dark target at 20 m is a legitimate reading, and a gate set at 15 m would remove it. Set the gate at the largest number your application can legitimately see, such as the 50 m rating.&lt;/p&gt;

&lt;h2&gt;
  
  
  A rolling median on top
&lt;/h2&gt;

&lt;p&gt;A gate removes impossible values. A median removes the possible-but-wrong ones the gate cannot see. I keep the last nine frame slots, including the invalid ones, and only output a value when at least five of those slots are valid. Two consequences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A run of out-of-range markers longer than four frames produces &lt;code&gt;None&lt;/code&gt;, not the last good distance. A stale number is worse than no number.&lt;/li&gt;
&lt;li&gt;Up to four bad frames inside the window do not move the output.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the replay, the median alone also handles those three spikes, because none of them sits in a run longer than four. What it did not do is make the signal quieter. The standard deviation of the valid frames was 2.73 cm and of the filtered output 2.73 cm. The log changes value only 56 times in 2000 lines, and the 189 to 204 cm spread is the module's real scatter at that wall. A median is an outlier filter, not a smoother. If you need smoothing, add it separately and accept its lag; our note on &lt;a href="https://erdilrf.com/knowledge/rangefinder-update-rate-moving-platforms/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=devto-5c-validity-202611" rel="noopener noreferrer"&gt;update rate on moving platforms&lt;/a&gt; covers what a filter costs on a moving vehicle.&lt;/p&gt;

&lt;p&gt;Size the window in time, not in frames. The tool that wrote the log recorded about 91 frames per second for the H module and about 94 for the VB module, and the factory notes say that rate comes from the tool's receive loop, not from the module. Nine slots are 9 ms if your host reads every frame at 1 kHz, and about 99 ms at 91 frames per second.&lt;/p&gt;

&lt;h2&gt;
  
  
  The code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;deque&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;statistics&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;median&lt;/span&gt;

&lt;span class="no"&gt;MODELS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;   &lt;span class="c1"&gt;# metres per count, out-of-range marker, configured max in metres&lt;/span&gt;
    &lt;span class="s2"&gt;"LRF50H"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;65535&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;50.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"LRF22VB"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;20.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Stream&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_valid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;marker&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max_m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;MODELS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;win&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deque&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;maxlen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min_valid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;min_valid&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frames&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;skipped_bytes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;marker&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;beyond_max&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;valid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="s2"&gt;"""Return one (instant_m or None, filtered_m or None) per decoded frame."""&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mh"&gt;0x5C&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"skipped_bytes"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;chk&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="c1"&gt;# drop one byte, look for the next 5C&lt;/span&gt;
                &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"skipped_bytes"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
            &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"frames"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scale&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;marker&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"marker"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max_m&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"beyond_max"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"valid"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;win&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;win&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;median&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min_valid&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The four counters are the useful output. Log them once a second. A rising &lt;code&gt;skipped_bytes&lt;/code&gt; rate is a wiring problem and shows up earlier than a wrong distance does. A rising &lt;code&gt;beyond_max&lt;/code&gt; with a clean &lt;code&gt;skipped_bytes&lt;/code&gt; is the pattern in the factory log.&lt;/p&gt;

&lt;h2&gt;
  
  
  Self-tests I ran
&lt;/h2&gt;

&lt;p&gt;I ran these before pasting, in a Python script with assertions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The manual frame &lt;code&gt;5C 02 11 EC&lt;/code&gt; decodes to 43.54 on LRF50H and 4.354 on LRF22VB.&lt;/li&gt;
&lt;li&gt;Two noise bytes in front of a marker frame, a 31496 frame and a 196 frame give &lt;code&gt;None&lt;/code&gt;, &lt;code&gt;None&lt;/code&gt;, 1.96, with the counters at 3 frames, 2 skipped bytes, 1 marker, 1 beyond-max, 1 valid.&lt;/li&gt;
&lt;li&gt;A frame split across two reads decodes once the second half arrives.&lt;/li&gt;
&lt;li&gt;One 314.96 m spike in nine slots of 1.96 m gives a mean of 36.74 m and a median of 1.96 m.&lt;/li&gt;
&lt;li&gt;The 2000 LRF50H log lines, re-encoded as &lt;code&gt;5C&lt;/code&gt; frames (so the bytes are synthetic), give 1997 valid and 3 beyond-max, at positions 867, 875 and 1210, with valid values between 1.89 and 2.06 m.&lt;/li&gt;
&lt;li&gt;The 3000 LRF22VB lines (1708 to 1710 mm) give 3000 valid and no events at the 20 m gate.&lt;/li&gt;
&lt;li&gt;Nine good frames followed by five markers: the filtered output is 1.96 m on the ninth and &lt;code&gt;None&lt;/code&gt; on the last.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have not run this against a live module or a raw byte capture. The factory log is the best evidence we have, and it is decoded values only. A raw capture and a flight-controller log are still the missing pieces for the claim "tested on hardware".&lt;/p&gt;

&lt;p&gt;At 460800 baud a 4-byte frame is 40 bit times, so the line can carry 11,520 frames per second. 1 kHz uses about 8.7% of it. The parser is not where you will run out of time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to look next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Driver code and protocol notes (MIT): &lt;a href="https://github.com/ErdiTech/erdi-lrf-drivers" rel="noopener noreferrer"&gt;https://github.com/ErdiTech/erdi-lrf-drivers&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;LRF50H model page: &lt;a href="https://erdilrf.com/models/lrf50h/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=devto-5c-validity-202611" rel="noopener noreferrer"&gt;https://erdilrf.com/models/lrf50h/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=devto-5c-validity-202611&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Paste a raw capture into the browser decoder to check frames and checksums: &lt;a href="https://erditech.com/lrf-uart-protocol-decoder/" rel="noopener noreferrer"&gt;https://erditech.com/lrf-uart-protocol-decoder/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have a raw hex capture of 20 or more frames that includes a bad one, send it to &lt;a href="mailto:tommy@erdimail.com"&gt;tommy@erdimail.com&lt;/a&gt; with the model name. I can say more from bytes than from a plot.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I am Tommy Yu, an engineer at ERDI TECH LTD (erdilrf.com), the manufacturer of the modules discussed. Data checked against our model documents and the 2026-11-06 factory bench capture on 2026-11-18.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>embedded</category>
      <category>python</category>
      <category>iot</category>
      <category>robotics</category>
    </item>
    <item>
      <title>Putting a TTL laser rangefinder module on an RS-485 line: logic levels, direction control and one request at a time</title>
      <dc:creator>Tommy Yu</dc:creator>
      <pubDate>Tue, 17 Nov 2026 21:04:42 +0000</pubDate>
      <link>https://dev.to/erdilrf_tommy/putting-a-ttl-laser-rangefinder-module-on-an-rs-485-line-logic-levels-direction-control-and-one-5e66</link>
      <guid>https://dev.to/erdilrf_tommy/putting-a-ttl-laser-rangefinder-module-on-an-rs-485-line-logic-levels-direction-control-and-one-5e66</guid>
      <description>&lt;p&gt;A reader asked me last week whether our laser rangefinder modules come with RS-485. They do not. I work at ERDI TECH LTD, we make the modules, and none of our published rangefinder module records lists RS-485 or RS-232 as the module's interface. The 905 nm modules and the compact 1535 nm ones speak UART at TTL level. The larger 1535 nm modules (LRF0815C and LRF1017C are examples) list RS-422.&lt;/p&gt;

&lt;p&gt;That does not stop you from putting one on a 485 bus. The factory's answer for the LRF0305C was that any TTL-to-RS485 converter board works, and the wiring is the same for the other TTL models. What matters is what happens at the three joints: the logic level on the TTL side, the direction control, and the polling logic on the host. Here is how I would do each, with code I ran against a fake module before pasting it here.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The TTL side of the converter must match the module
&lt;/h2&gt;

&lt;p&gt;"Runs from 5 V" does not tell you the UART level. Read the electrical table for the exact model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LRF0305C: the datasheet says UART (TTL 3.3 V).&lt;/li&gt;
&lt;li&gt;LR1200E4: TXD stays at 3.3 V logic even on a 5 V supply, and RXD must not be driven at 5 V. The absolute maximum input is 3.6 V.&lt;/li&gt;
&lt;li&gt;LR1200E2: the factory says TXD/RXD work with 3.3 V or 5 V logic.&lt;/li&gt;
&lt;li&gt;For several other models the manual does not state the level at all. I would not guess; ask before you wire.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Many cheap RS-485 breakouts use a 5 V transceiver, and the receiver-output pin of such a part swings to roughly 5 V. Wired straight to a 3.3 V module RXD pin, that can exceed the 3.6 V limit above. Pick a converter with a 3.3 V logic side, or put a level shifter between them. This is general electronics, not an ERDI claim, but it is the failure I would check first.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Direction control: let the last bit leave before you release the bus
&lt;/h2&gt;

&lt;p&gt;RS-485 on two wires is half duplex. The host must enable the driver, send, then switch back to receive before the module answers. Two ways to do it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use a converter with automatic direction control. Nothing to write, and the module sees an ordinary UART.&lt;/li&gt;
&lt;li&gt;Drive the DE/RE pin from the host (an RTS line on a USB adapter, or a GPIO).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you drive it yourself, the classic bug is releasing DE when &lt;code&gt;write()&lt;/code&gt; returns. The call returns when the bytes are in the OS buffer, not when the last stop bit is on the wire. The 8-byte frame used by the LR series (&lt;code&gt;55 AA ...&lt;/code&gt;) is 80 bit times: 0.69 ms at 115200 baud, 8.3 ms at 9600. Wait that long, plus a small margin, before you drop DE. That is what &lt;code&gt;time.sleep(self.frame_s + 0.0005)&lt;/code&gt; does in the code below.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Poll with exactly one request in flight
&lt;/h2&gt;

&lt;p&gt;On a point-to-point UART you can get away with "read whatever arrives". On a bus with latency, or a radio link in the middle, you cannot. A late reply from request N can be taken for the reply to request N+1, and the distance is real but belongs to a different moment. Nothing in the log looks broken.&lt;/p&gt;

&lt;p&gt;The simple fix is rule three from our request/response note: keep exactly one request outstanding, flush stale bytes before sending, accept the first valid frame inside the timeout, and treat a timeout as its own fault, separate from a checksum error.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 8-byte frame, with its two checksums
&lt;/h2&gt;

&lt;p&gt;The LR1000E2 to LR2000E4 family, LRF1200A1, LRF3000A1 and the SPD1200N0/N2/N4 use the same 8-byte frame, hexadecimal, 115200 baud by default:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;55 AA  FN  D1 D2 D3 D4  SUM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Single-shot request: &lt;code&gt;55 AA 88 FF FF FF FF 84&lt;/code&gt;. Reply: &lt;code&gt;55 AA 88 STA FF DIS_H DIS_L SUM&lt;/code&gt;. &lt;code&gt;STA = 1&lt;/code&gt; means success; the distance is big-endian and the raw value is metres times ten.&lt;/p&gt;

&lt;p&gt;The part that bites: the two directions use different checksums, and the manual says so.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Host to module: &lt;code&gt;SUM = (FN + D1 + D2 + D3 + D4) &amp;amp; 0xFF&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Module to host: &lt;code&gt;SUM = (0x55 + 0xAA + FN + D1 + D2 + D3 + D4) &amp;amp; 0xFF&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They differ by &lt;code&gt;0x55 + 0xAA = 0xFF&lt;/code&gt;, so a parser that reuses the transmit formula on replies is off by one on every frame. The manuals do not state stop bits or parity for this family; the code below leaves your serial library's 8N1 default, so confirm if your unit disagrees. Also note that LRF1200A1 and LRF3000A1 have an open protocol question on continuous ranging (the request function byte and the reply function byte differ in the manual), so this code sticks to single-shot, which is unaffected.&lt;/p&gt;

&lt;h2&gt;
  
  
  The code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="no"&gt;HDR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xAA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tx_checksum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;            &lt;span class="c1"&gt;# host -&amp;gt; module: sum(function + D1..D4) &amp;amp; 0xFF&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;rx_checksum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;            &lt;span class="c1"&gt;# module -&amp;gt; host: sum(0x55 + 0xAA + function + D1..D4) &amp;amp; 0xFF&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x55&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mh"&gt;0xAA&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;single_shot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xFF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="no"&gt;HDR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;tx_checksum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;parse_reply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Return (distance_m or None, status, bytes_consumed). Resyncs on 55 AA, drops bad frames."""&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mh"&gt;0x55&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mh"&gt;0xAA&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nf"&gt;rx_checksum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;sta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;10.0&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sta&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;
        &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rs485Lrf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;de_pin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;baud&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;115200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout_s&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;de&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;timeout_s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;de_pin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout_s&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frame_s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;baud&lt;/span&gt;          &lt;span class="c1"&gt;# 8 bytes x 10 bits per byte (start + 8 data + stop)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;de&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;de&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;             &lt;span class="c1"&gt;# driver enable on&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frame_s&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.0005&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# wait until the last bit has left the shift register&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;de&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;de&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;            &lt;span class="c1"&gt;# back to receive&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset_input_buffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# exactly one request in flight: drop anything stale&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;single_shot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;monotonic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;timeout_s&lt;/span&gt;
        &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;monotonic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;deadline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parse_reply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sta&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sta&lt;/span&gt;
            &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;                      &lt;span class="c1"&gt;# timeout: different fault from "bad checksum"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I tested it with a fake serial object: the request bytes come out as &lt;code&gt;55 aa 88 ff ff ff ff 84&lt;/code&gt;; a reply built with the receive formula parses (&lt;code&gt;55 aa 88 01 ff 04 d2 5d&lt;/code&gt; decodes to 123.4 m); a reply with one flipped checksum bit is dropped; a reply using the transmit formula is dropped; noise in front of the frame is skipped; &lt;code&gt;STA = 0&lt;/code&gt; returns &lt;code&gt;None&lt;/code&gt;; an empty line times out; and DE goes high and then low around each request.&lt;/p&gt;

&lt;p&gt;On real hardware, hook it up like this: &lt;code&gt;import serial; s = serial.Serial("COM5", 115200, timeout=0.05)&lt;/code&gt;, and pass &lt;code&gt;de_pin=lambda on: setattr(s, "rts", on)&lt;/code&gt; if your adapter's RTS drives DE/RE (check the polarity of your board). I have not tested a specific converter board, so treat the bench check below as part of the job.&lt;/p&gt;

&lt;h2&gt;
  
  
  A short bench check before you trust the bus
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Power the module on the bench with a current-limited supply, and measure the TX idle level before you connect anything.&lt;/li&gt;
&lt;li&gt;Connect ground first, then TX/RX, then power.&lt;/li&gt;
&lt;li&gt;Capture raw bytes at the documented baud rate and check the header and checksum by hand before relying on your parser.&lt;/li&gt;
&lt;li&gt;Only then move to the long cable. Do not fix long-cable errors by lowering the baud rate alone; under motor noise the checksum still fails.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where to look next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Our wiring and protocol notes (MIT-licensed drivers and docs): &lt;a href="https://github.com/ErdiTech/erdi-lrf-drivers" rel="noopener noreferrer"&gt;https://github.com/ErdiTech/erdi-lrf-drivers&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The RS485 / RS232 question on the website: &lt;a href="https://erdilrf.com/rs485-rs232-laser-rangefinder-module/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=devto-rs485-bus-202611" rel="noopener noreferrer"&gt;https://erdilrf.com/rs485-rs232-laser-rangefinder-module/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=devto-rs485-bus-202611&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;UART flow control notes: &lt;a href="https://erdilrf.com/knowledge/rangefinder-uart-flow-control/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=devto-rs485-bus-202611" rel="noopener noreferrer"&gt;https://erdilrf.com/knowledge/rangefinder-uart-flow-control/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=devto-rs485-bus-202611&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your model is not in the list above, send the model name and a raw hex capture of 20 frames to &lt;a href="mailto:tommy@erdimail.com"&gt;tommy@erdimail.com&lt;/a&gt;. A smoothed plot cannot tell me whether the problem is timing or checksum; the raw bytes can.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I am Tommy Yu, an engineer at ERDI TECH LTD (erdilrf.com), which makes the modules discussed. Facts checked against our model documents on 2026-11-18.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>electronics</category>
      <category>embedded</category>
      <category>python</category>
      <category>iot</category>
    </item>
    <item>
      <title>Laser rangefinder vs LiDAR vs ultrasonic for drone altitude hold (2026): what the datasheets say</title>
      <dc:creator>Tommy Yu</dc:creator>
      <pubDate>Fri, 06 Nov 2026 14:35:17 +0000</pubDate>
      <link>https://dev.to/erdilrf_tommy/laser-rangefinder-vs-lidar-vs-ultrasonic-for-drone-altitude-hold-2026-what-the-datasheets-say-541e</link>
      <guid>https://dev.to/erdilrf_tommy/laser-rangefinder-vs-lidar-vs-ultrasonic-for-drone-altitude-hold-2026-what-the-datasheets-say-541e</guid>
      <description>&lt;p&gt;The problem: an ultrasonic sensor under a multirotor gives a ragged hover over grass, so you look for a replacement, and every forum thread calls the answer "LiDAR" while mixing up three different things: a single-point laser rangefinder, a scanning LiDAR and a time-of-flight chip. This post sorts them out. It compares the three on the numbers that matter for altitude hold (minimum range, update rate, beam footprint) and on how each fails over grass, water and in sunlight.&lt;/p&gt;

&lt;p&gt;Spec numbers below come from the makers' public pages, read on &lt;strong&gt;2026-11-07&lt;/strong&gt;: Benewake's product comparison table (en.benewake.com) and ERDI's model pages (erdilrf.com). Where I use a general physical rule instead of a datasheet value, I say so.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three sensor families
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Ultrasonic.&lt;/strong&gt; A transducer sends a chirp and times the echo. Typical hobby modules such as the HC-SR04 publish a 2-400 cm range and a measuring angle of about 15 degrees. The beam is wide and the speed of sound changes with air temperature (roughly 331 m/s at 0 °C plus 0.6 m/s per degree), so readings drift unless you compensate. Prop wash, foam, grass and soft surfaces can all swallow the echo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single-point laser rangefinder.&lt;/strong&gt; A pulsed or modulated infrared emitter and a photodiode. The beam is narrow, so you measure a spot, not a cone. This family covers a huge span: 9 m parts that weigh 1 g, up to modules that reach kilometres. Update rates run from 1 Hz to 10 kHz depending on model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scanning LiDAR.&lt;/strong&gt; A single-point laser on a rotating or oscillating mount that builds a 2D or 3D picture. Right for obstacle avoidance and mapping; heavy and power-hungry for a job that only needs one number pointing down.&lt;/p&gt;

&lt;h2&gt;
  
  
  What altitude hold needs
&lt;/h2&gt;

&lt;p&gt;Three requirements decide the sensor:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A short minimum range.&lt;/strong&gt; On landing you need valid readings from a few centimetres. A sensor with a 4 m blind zone is useless for landing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A high enough update rate.&lt;/strong&gt; The flight controller fuses the rangefinder with barometer and IMU. A few hertz is too slow for the vertical loop on a small multirotor; tens to hundreds of hertz is the comfortable region.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A stable reading over the surfaces you fly above.&lt;/strong&gt; Water, tall grass, dark tarmac and bright sand each break one sensor type or another.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Published numbers, side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sensor&lt;/th&gt;
&lt;th&gt;Range (maker)&lt;/th&gt;
&lt;th&gt;Update rate (maker)&lt;/th&gt;
&lt;th&gt;Weight&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;HC-SR04 class ultrasonic&lt;/td&gt;
&lt;td&gt;2-400 cm&lt;/td&gt;
&lt;td&gt;measurement cycle of tens of ms&lt;/td&gt;
&lt;td&gt;few grams&lt;/td&gt;
&lt;td&gt;wide cone; temperature-sensitive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Benewake TFmini Plus&lt;/td&gt;
&lt;td&gt;0.1-12 m&lt;/td&gt;
&lt;td&gt;1-1,000 Hz&lt;/td&gt;
&lt;td&gt;12 ± 1 g&lt;/td&gt;
&lt;td&gt;IP65&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Benewake TF02-Pro&lt;/td&gt;
&lt;td&gt;0.1-40 m&lt;/td&gt;
&lt;td&gt;1-1,000 Hz&lt;/td&gt;
&lt;td&gt;50 g&lt;/td&gt;
&lt;td&gt;IP65&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Benewake TF03&lt;/td&gt;
&lt;td&gt;0.1-180 m&lt;/td&gt;
&lt;td&gt;1-9,800 Hz&lt;/td&gt;
&lt;td&gt;86 ± 3 g&lt;/td&gt;
&lt;td&gt;IP67&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ERDI &lt;a href="https://erdilrf.com/models/lrf10vb/" rel="noopener noreferrer"&gt;LRF10VB&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;0.05-9 m (90 % reflectivity); 0.05-5 m (10 %)&lt;/td&gt;
&lt;td&gt;50 Hz&lt;/td&gt;
&lt;td&gt;1 g&lt;/td&gt;
&lt;td&gt;940 nm, UART, USD 10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ERDI &lt;a href="https://erdilrf.com/models/lrf22vb/" rel="noopener noreferrer"&gt;LRF22VB&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;0.05-20 m (90 %); 0.05-10 m (10 %)&lt;/td&gt;
&lt;td&gt;200 Hz (selectable)&lt;/td&gt;
&lt;td&gt;1.5 g&lt;/td&gt;
&lt;td&gt;UART / I2C, 3-3.6 V, USD 12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ERDI &lt;a href="https://erdilrf.com/models/lrf50vb/" rel="noopener noreferrer"&gt;LRF50VB&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;0.05-50 m (90 %); 0.05-20 m (10 %)&lt;/td&gt;
&lt;td&gt;100 Hz&lt;/td&gt;
&lt;td&gt;1.3 g&lt;/td&gt;
&lt;td&gt;UART / I2C, USD 70&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ERDI &lt;a href="https://erdilrf.com/models/lrf300h/" rel="noopener noreferrer"&gt;LRF300H&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;0.05-300 m (90 %); 0.05-100 m (10 %)&lt;/td&gt;
&lt;td&gt;1 kHz or 50 Hz (auto)&lt;/td&gt;
&lt;td&gt;20 ± 2 g&lt;/td&gt;
&lt;td&gt;9-36 V, UART / I2C&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ERDI &lt;a href="https://erdilrf.com/models/lr2000e2/" rel="noopener noreferrer"&gt;LR2000E2&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;4-2,000 m (standard range)&lt;/td&gt;
&lt;td&gt;2-10 Hz adaptive&lt;/td&gt;
&lt;td&gt;about 10 g&lt;/td&gt;
&lt;td&gt;4 m minimum; not for altitude hold&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two rows deserve emphasis. The last one is the honest answer to a question I get often: a kilometre-class module with a 4 m minimum and 2-10 Hz refresh is the wrong sensor for altitude hold, however good its range. And the ERDI VB series entries show the useful range for low-altitude work: 0.05 m minimum, 50-200 Hz, around a gram.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which fails where
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Surface / condition&lt;/th&gt;
&lt;th&gt;Ultrasonic&lt;/th&gt;
&lt;th&gt;Short-range laser&lt;/th&gt;
&lt;th&gt;Scanning LiDAR&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Grass, foliage&lt;/td&gt;
&lt;td&gt;soft echo, noisy&lt;/td&gt;
&lt;td&gt;often reads the top of the vegetation&lt;/td&gt;
&lt;td&gt;similar to laser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Water&lt;/td&gt;
&lt;td&gt;usually returns&lt;/td&gt;
&lt;td&gt;weak return at a steep angle; can drop out&lt;/td&gt;
&lt;td&gt;weak return&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dark asphalt / low reflectivity&lt;/td&gt;
&lt;td&gt;fine&lt;/td&gt;
&lt;td&gt;range drops (see the 10 % column above)&lt;/td&gt;
&lt;td&gt;range drops&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strong sunlight&lt;/td&gt;
&lt;td&gt;fine&lt;/td&gt;
&lt;td&gt;background light cuts range&lt;/td&gt;
&lt;td&gt;cuts range&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prop wash / vibration&lt;/td&gt;
&lt;td&gt;echo disturbed&lt;/td&gt;
&lt;td&gt;not affected&lt;/td&gt;
&lt;td&gt;not affected, mount-sensitive&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That last row is why laser beats ultrasonic under a rotorcraft. The beam footprint is also the reason. A laser spot with a divergence of a few milliradians is centimetres wide at 10 m. An ultrasonic cone with a 15-degree angle covers a circle roughly 2.6 m across at 10 m (2 × 10 × tan 7.5°), which includes the landing gear, a fence post and a patch of grass all at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  Footprint in 10 lines of Python
&lt;/h2&gt;

&lt;p&gt;The fastest way to see why laser wins under a rotorcraft is to compute what each sensor is actually looking at. The 3 mrad laser divergence is an illustrative value; use your module's published figure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;footprint_m&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;distance_m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;divergence_rad&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cone_deg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Diameter of the area a sensor looks at, at a given distance.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;cone_deg&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;distance_m&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;radians&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cone_deg&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;distance_m&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;divergence_rad&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;sonar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;footprint_m&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cone_deg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# HC-SR04 class: about 15 degree cone
&lt;/span&gt;    &lt;span class="n"&gt;laser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;footprint_m&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;divergence_rad&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.003&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 3 mrad laser (illustrative value)
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; m   ultrasonic &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;sonar&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;5.2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; m wide   laser &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;laser&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;5.1&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; cm wide&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output of that script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  2 m   ultrasonic  0.53 m wide   laser   0.6 cm wide
 10 m   ultrasonic  2.63 m wide   laser   3.0 cm wide
 50 m   ultrasonic 13.17 m wide   laser  15.0 cm wide
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  A practical recommendation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Landing and low hold (under 10-20 m):&lt;/strong&gt; a single-point laser with a minimum range of a few centimetres and 50 Hz or more. The VB class (LRF10VB, LRF22VB, LRF50VB) fits that profile at 1-1.5 g.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Terrain following at 30-100 m:&lt;/strong&gt; a 100-300 m laser such as the LRF300H, still at 50 Hz to 1 kHz.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Obstacle distance ahead, structure standoff, cable spans:&lt;/strong&gt; a long-range module (hundreds of metres to kilometres) on a separate channel. These read slowly. Use them to decide, not to stabilise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mapping and avoidance in clutter:&lt;/strong&gt; a scanning LiDAR. Do not use it as an altitude sensor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Wiring a rangefinder into ArduPilot or PX4 is a separate step. Neither stack ships a driver for every module, and the usual route is a small companion script that reads the sensor over UART and forwards a MAVLink DISTANCE_SENSOR message. There is a worked example in the &lt;a href="https://github.com/Tommyapi/erdi-lrf-pixhawk-ardupilot" rel="noopener noreferrer"&gt;erdi-lrf-pixhawk-ardupilot repository&lt;/a&gt; and a drone-focused buying guide in &lt;a href="https://github.com/Tommyapi/drone-altimeter-laser-rangefinder-guide" rel="noopener noreferrer"&gt;drone-altimeter-laser-rangefinder-guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Caveats
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;ERDI TECH LTD is the author's company. The Benewake rows are there because the comparison is meaningless without them.&lt;/li&gt;
&lt;li&gt;Ultrasonic values are typical published figures for the HC-SR04 class, not a specific premium part. Premium sonar modules exist with better beam control.&lt;/li&gt;
&lt;li&gt;I have not flight-tested every part listed. These are datasheet comparisons; bench and flight test before you trust any of them with a landing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Datasheets and prices for the ERDI parts are on the model pages linked above, and the drone-specific page is &lt;a href="https://erdilrf.com/lrf/drone-altimeter-laser-rangefinder/" rel="noopener noreferrer"&gt;https://erdilrf.com/lrf/drone-altimeter-laser-rangefinder/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Data checked 2026-11-07. Tommy Yu, ERDI TECH LTD, erdilrf.com&lt;/em&gt;&lt;/p&gt;

</description>
      <category>drones</category>
      <category>robotics</category>
      <category>python</category>
      <category>hardware</category>
    </item>
    <item>
      <title>Best long-range laser rangefinder modules in 2026 (1 km to 3 km): a datasheet comparison</title>
      <dc:creator>Tommy Yu</dc:creator>
      <pubDate>Fri, 06 Nov 2026 14:34:57 +0000</pubDate>
      <link>https://dev.to/erdilrf_tommy/best-long-range-laser-rangefinder-modules-in-2026-1-km-to-3-km-a-datasheet-comparison-4oa2</link>
      <guid>https://dev.to/erdilrf_tommy/best-long-range-laser-rangefinder-modules-in-2026-1-km-to-3-km-a-datasheet-comparison-4oa2</guid>
      <description>&lt;p&gt;The problem: you need a bare serial laser rangefinder that reaches a ridge line, tower or building about 1.2 km away, and every distributor page quotes one big range number and nothing else. Here is the comparison I think that search deserves: a shortlist of modules that reach &lt;strong&gt;1 km or more&lt;/strong&gt;, with the numbers that actually decide the choice (range and the target it was measured on, accuracy at distance, update rate, supply, weight, price) and a small Python script that evaluates each maker's accuracy rule at the distance you care about.&lt;/p&gt;

&lt;p&gt;All ERDI figures come from the product pages on erdilrf.com and the manuals behind them, checked on &lt;strong&gt;2026-11-07&lt;/strong&gt;. Benewake figures come from the public product comparison table at en.benewake.com, read the same day. I only list what the maker publishes, and I say where a number is missing. Treat everything as a shortlist, not a benchmark: makers measure on different targets in different weather.&lt;/p&gt;

&lt;h2&gt;
  
  
  Short answer
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;If you need&lt;/th&gt;
&lt;th&gt;Look at first&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cheapest 1 km class, slow readings&lt;/td&gt;
&lt;td&gt;ERDI LR1000E2 (USD 80)&lt;/td&gt;
&lt;td&gt;4-1,000 m, UART, about 10 g&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.5-2 km on a small bare board&lt;/td&gt;
&lt;td&gt;ERDI LR1500E2 / LR2000E2 (USD 100 / 120)&lt;/td&gt;
&lt;td&gt;same serial protocol across the family&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3 km class&lt;/td&gt;
&lt;td&gt;ERDI LRF3000A1 (USD 200)&lt;/td&gt;
&lt;td&gt;3,000 m or more on a 70 % reflectivity building&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Faster readings at 1 km+&lt;/td&gt;
&lt;td&gt;Benewake TFA1500-L&lt;/td&gt;
&lt;td&gt;60-800 Hz adaptive, 0.5-1,500 m&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Better close-in accuracy at 1.2 km&lt;/td&gt;
&lt;td&gt;ERDI SPD1200S2 (USD 150)&lt;/td&gt;
&lt;td&gt;±0.3 m up to 400 m&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The comparison table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;Maker's range figure&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;th&gt;Rate&lt;/th&gt;
&lt;th&gt;Interface / supply&lt;/th&gt;
&lt;th&gt;Weight&lt;/th&gt;
&lt;th&gt;Price shown&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://erdilrf.com/models/lr1000e2/" rel="noopener noreferrer"&gt;LR1000E2&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;4-1,000 m (standard range)&lt;/td&gt;
&lt;td&gt;±1 m to 400 m; ±(1 + 0.001 D) m beyond&lt;/td&gt;
&lt;td&gt;not on page&lt;/td&gt;
&lt;td&gt;UART-TTL, 3.3-5 V&lt;/td&gt;
&lt;td&gt;10 g or less&lt;/td&gt;
&lt;td&gt;USD 80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://erdilrf.com/models/lr1200e2/" rel="noopener noreferrer"&gt;LR1200E2&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;4-1,200 m (standard range)&lt;/td&gt;
&lt;td&gt;±1 m (6-500 m); ±(0.5 m + 0.001 D) beyond&lt;/td&gt;
&lt;td&gt;not on page&lt;/td&gt;
&lt;td&gt;UART-TTL, 3.3-5 V&lt;/td&gt;
&lt;td&gt;10 g or less&lt;/td&gt;
&lt;td&gt;USD 90&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://erdilrf.com/models/lr1500e2/" rel="noopener noreferrer"&gt;LR1500E2&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;4-1,500 m (standard range)&lt;/td&gt;
&lt;td&gt;same two-step rule as LR1200E2&lt;/td&gt;
&lt;td&gt;not on page&lt;/td&gt;
&lt;td&gt;UART-TTL, 3.3-5 V&lt;/td&gt;
&lt;td&gt;10 g or less&lt;/td&gt;
&lt;td&gt;USD 100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://erdilrf.com/models/lr2000e2/" rel="noopener noreferrer"&gt;LR2000E2&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;4-2,000 m (standard range)&lt;/td&gt;
&lt;td&gt;±1 m to 400 m; 0.4 % of distance to 2,000 m&lt;/td&gt;
&lt;td&gt;2-10 Hz adaptive&lt;/td&gt;
&lt;td&gt;UART-TTL, 3.3-5 V&lt;/td&gt;
&lt;td&gt;about 10 g&lt;/td&gt;
&lt;td&gt;USD 120&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://erdilrf.com/models/lrf3000a1/" rel="noopener noreferrer"&gt;LRF3000A1&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;3,000 m or more (70 % reflectivity building, clear weather, visibility 4 km or more)&lt;/td&gt;
&lt;td&gt;±0.7 m to 100 m; ±(0.7 + 0.003 D) m beyond&lt;/td&gt;
&lt;td&gt;not on page&lt;/td&gt;
&lt;td&gt;UART 3.3 V TTL, 3.3-5 V&lt;/td&gt;
&lt;td&gt;12 ± 0.5 g&lt;/td&gt;
&lt;td&gt;USD 200&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://erdilrf.com/models/spd1200s2/" rel="noopener noreferrer"&gt;SPD1200S2&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;0.2-1,200 m catalogue range&lt;/td&gt;
&lt;td&gt;±0.3 m to 400 m; ±(0.5 m + 0.1 % D) to 1,200 m&lt;/td&gt;
&lt;td&gt;4-15 Hz adaptive&lt;/td&gt;
&lt;td&gt;UART-TTL, 3.3-5 V&lt;/td&gt;
&lt;td&gt;10 g or less&lt;/td&gt;
&lt;td&gt;USD 150&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://erdilrf.com/models/lrf1500h/" rel="noopener noreferrer"&gt;LRF1500H&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;0.05-1,500 m at 90 % reflectivity; 0.05-300 m at 10 %&lt;/td&gt;
&lt;td&gt;not on page&lt;/td&gt;
&lt;td&gt;1 kHz or 50 Hz (automatic)&lt;/td&gt;
&lt;td&gt;UART / I2C, 9-36 V&lt;/td&gt;
&lt;td&gt;20 ± 2 g&lt;/td&gt;
&lt;td&gt;USD 400&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Benewake TFA1200-L&lt;/td&gt;
&lt;td&gt;3-1,200 m&lt;/td&gt;
&lt;td&gt;not on comparison table&lt;/td&gt;
&lt;td&gt;3 Hz&lt;/td&gt;
&lt;td&gt;UART&lt;/td&gt;
&lt;td&gt;11 g&lt;/td&gt;
&lt;td&gt;not listed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Benewake TFA1500-L&lt;/td&gt;
&lt;td&gt;0.5-1,500 m&lt;/td&gt;
&lt;td&gt;see its datasheet&lt;/td&gt;
&lt;td&gt;60-800 Hz adaptive&lt;/td&gt;
&lt;td&gt;UART&lt;/td&gt;
&lt;td&gt;11 g&lt;/td&gt;
&lt;td&gt;not listed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Sources: the ERDI model pages linked above (checked 2026-11-07); the Benewake product comparison table at &lt;a href="https://en.benewake.com/TF03/index.html" rel="noopener noreferrer"&gt;https://en.benewake.com/TF03/index.html&lt;/a&gt; (read 2026-11-07). ERDI prices are the published USD unit prices for 1 to 30 pieces, shipping included. Volume tiers are lower and are on each page.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the table does not show at first glance
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The accuracy rule decides the usable range.&lt;/strong&gt; A flat "±1 m" would be easy to compare. These modules use a distance-dependent rule, and at the far end it dominates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LR2000E2 at 2,000 m: 0.4 % of distance is &lt;strong&gt;±8 m&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;LRF3000A1 at 3,000 m: 0.7 + 0.003 × 3,000 = &lt;strong&gt;±9.7 m&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;SPD1200S2 at 1,200 m: 0.5 + 0.001 × 1,200 = &lt;strong&gt;±1.7 m&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is fine for "is there a structure there, and roughly how far", and not enough for surveying. If you need sub-metre accuracy at several hundred metres, the SPD family's ±0.3 m up to 400 m is the better starting point. If you need reach over accuracy, the 3 km part wins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Standard range" is a best case.&lt;/strong&gt; The E2 pages say outright that actual reach depends on target and environment. The LRF3000A1 figure is tied to a 70 % reflectivity building and visibility of 4 km or more. The LRF1500H page gives two ranges on one line: 1,500 m at 90 % reflectivity but only 300 m at 10 %. Dark rock, wet asphalt and vegetation sit nearer the second number than the first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rate separates the two camps.&lt;/strong&gt; The kilometre-class bare modules (LR series, LRF3000A1, SPD) read a few times per second. The Benewake TFA1500-L adapts between 60 and 800 Hz, and the LRF1500H switches between 50 Hz and 1 kHz depending on signal strength. If you are closing a control loop, that matters more than another 500 m of reach. If you are mapping a ridge line or watching a tower, 5 Hz is plenty.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Supply and interface differ in a way that bites on day one.&lt;/strong&gt; The bare modules run from 3.3-5 V and speak UART. The H series wants 9-36 V and offers UART or I2C. Check the logic level of TXD/RXD against your microcontroller before you connect anything. The LRF3000A1 page says 3.3 V TTL; for the others, confirm in the manual.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the accuracy rules yourself
&lt;/h2&gt;

&lt;p&gt;The datasheet rules are easy to misread, so here is a script that evaluates them. Save it as &lt;code&gt;accuracy_at_distance.py&lt;/code&gt; and run &lt;code&gt;python accuracy_at_distance.py&lt;/code&gt; (standard library only; I ran it before posting).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# accuracy_at_distance.py - published accuracy rules, evaluated at the distance you care about
&lt;/span&gt;&lt;span class="n"&gt;RULES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  &lt;span class="c1"&gt;# model: list of (upper_distance_m, fixed_m, per_metre_fraction), checked 2026-11-07 on erdilrf.com
&lt;/span&gt;    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;LR1000E2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.001&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;LR1500E2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.001&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;LR2000E2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.004&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;LRF3000A1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.003&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SPD1200S2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.001&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;accuracy_m&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fixed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frac&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;RULES&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fixed&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;frac&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; m is beyond the published range&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;RULES&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; +/-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;accuracy_m&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; m&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; n/a&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; m  &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;  |  &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample output from that run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  800 m  LR1000E2 +/-1.8 m  |  LR1500E2 +/-1.3 m  |  LR2000E2 +/-3.2 m  |  LRF3000A1 +/-3.1 m  |  SPD1200S2 +/-1.3 m
 1200 m  LR1000E2 n/a  |  LR1500E2 +/-1.7 m  |  LR2000E2 +/-4.8 m  |  LRF3000A1 +/-4.3 m  |  SPD1200S2 +/-1.7 m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The LR1500E2 rule comes from a page that says its two sources differ on where the second interval ends, so confirm the revision you are shipped.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which one for which job
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Drone terrain-ahead, structure distance, cable-span measurement:&lt;/strong&gt; a 1.2-2 km bare module. Pair it with a separate fast short-range sensor for altitude. A 2-10 Hz sensor is not an altitude-hold sensor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixed monitoring posts, tower or slope distance checks:&lt;/strong&gt; the cheapest model that covers your distance with margin. Buy the next range up; real surfaces are not 90 % white boards.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Robot or AGV obstacle sensing under 300 m:&lt;/strong&gt; the H series (LRF300H, LRF600H) or a short-range VB part, because the high rate is what you need there. &lt;a href="https://erdilrf.com/models/lrf50vb/" rel="noopener noreferrer"&gt;LRF50VB&lt;/a&gt; is 1.3 g and listed at USD 70.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;More than 3 km:&lt;/strong&gt; this is a different product class. The longer-range ERDI parts use 1535 nm lasers and RS-422 at 12 V; they are listed on the &lt;a href="https://erdilrf.com/lrf/1535nm-laser-rangefinder-module/" rel="noopener noreferrer"&gt;1535 nm rangefinder page&lt;/a&gt; and are priced in the hundreds to thousands of dollars.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Reading one over UART
&lt;/h2&gt;

&lt;p&gt;If you pick an LR-series module, the protocol is an 8-byte request and an 8-byte reply: &lt;code&gt;55 AA &amp;lt;function&amp;gt; D1 D2 D3 D4 &amp;lt;checksum&amp;gt;&lt;/code&gt;. Single-shot ranging is &lt;code&gt;55 AA 88 FF FF FF FF 84&lt;/code&gt;. The reply carries the distance as an actual-value-times-ten integer. A complete Python reader with checksum handling is in the &lt;a href="https://github.com/Tommyapi/erdi-lrf-raspberry-pi-python" rel="noopener noreferrer"&gt;ERDI Raspberry Pi example repository&lt;/a&gt;, and the machine-readable model table is in the &lt;a href="https://github.com/Tommyapi/laser-rangefinder-module-database" rel="noopener noreferrer"&gt;laser rangefinder module database&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Caveats
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;ERDI TECH LTD is the author's company. I included a competitor's published numbers because a shortlist that hides them is not worth reading.&lt;/li&gt;
&lt;li&gt;Missing cells mean the number was not on the public page I read. Pull the PDF before you design a board.&lt;/li&gt;
&lt;li&gt;Prices and ranges change; the product pages are the source of truth.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full model list with datasheet links is at &lt;a href="https://erdilrf.com/models/" rel="noopener noreferrer"&gt;https://erdilrf.com/models/&lt;/a&gt;, and the 1-2 km pages are at &lt;a href="https://erdilrf.com/lrf/1km-laser-rangefinder-module/" rel="noopener noreferrer"&gt;https://erdilrf.com/lrf/1km-laser-rangefinder-module/&lt;/a&gt; and &lt;a href="https://erdilrf.com/lrf/2km-laser-rangefinder-module/" rel="noopener noreferrer"&gt;https://erdilrf.com/lrf/2km-laser-rangefinder-module/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Data checked 2026-11-07. Tommy Yu, ERDI TECH LTD, erdilrf.com&lt;/em&gt;&lt;/p&gt;

</description>
      <category>iot</category>
      <category>python</category>
      <category>robotics</category>
      <category>hardware</category>
    </item>
    <item>
      <title>TF03 vs SF11/C vs TFA1500-L vs ERDI LR2000E2: laser rangefinder modules from 100 m to 2 km compared (2026)</title>
      <dc:creator>Tommy Yu</dc:creator>
      <pubDate>Fri, 06 Nov 2026 02:23:38 +0000</pubDate>
      <link>https://dev.to/erdilrf_tommy/tf03-vs-sf11c-vs-tfa1500-l-vs-erdi-lr2000e2-laser-rangefinder-modules-from-100-m-to-2-km-compared-479k</link>
      <guid>https://dev.to/erdilrf_tommy/tf03-vs-sf11c-vs-tfa1500-l-vs-erdi-lr2000e2-laser-rangefinder-modules-from-100-m-to-2-km-compared-479k</guid>
      <description>&lt;p&gt;If you search for a "2 km laser rangefinder module" you quickly find that the name covers very different products. Some are 100 m altimeters. Some are 180 m sensors in an aluminium housing. A few are small bare modules that claim a kilometre or more. This post puts four of them side by side using only the manufacturers' own published numbers, and says plainly where each one wins.&lt;/p&gt;

&lt;p&gt;All competitor figures were read from the manufacturers' public pages on &lt;strong&gt;2026-11-06&lt;/strong&gt;. ERDI figures come from the LR2000E2 manual and the product page. Manufacturers state their ranges under different target and weather conditions, so treat the table as a shortlist tool, not a benchmark.&lt;/p&gt;

&lt;h2&gt;
  
  
  The four modules
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Benewake TF03&lt;/strong&gt; (&lt;a href="https://en.benewake.com/TF03/index.html" rel="noopener noreferrer"&gt;https://en.benewake.com/TF03/index.html&lt;/a&gt;): IP67 industrial sensor in an aluminium housing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LightWare SF11/C, 100 m&lt;/strong&gt; (&lt;a href="https://lightwarelidar.com/shop/sf11-c-100-m2/" rel="noopener noreferrer"&gt;https://lightwarelidar.com/shop/sf11-c-100-m2/&lt;/a&gt;): the long-running drone altimeter. The vendor's page now states "End of life, October 31 2024" and "Out of stock".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benewake TFA1500-L&lt;/strong&gt; (&lt;a href="https://en.benewake.com/tfa1500-kilometer-level-lidar" rel="noopener noreferrer"&gt;https://en.benewake.com/tfa1500-kilometer-level-lidar&lt;/a&gt;): a small bare module with a 1,500 m maximum range.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ERDI LR2000E2&lt;/strong&gt; (&lt;a href="https://erdilrf.com/models/lr2000e2/" rel="noopener noreferrer"&gt;https://erdilrf.com/models/lr2000e2/&lt;/a&gt;): a 905 nm UART module with a 2,000 m standard range.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Side-by-side table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;TF03&lt;/th&gt;
&lt;th&gt;SF11/C (100 m)&lt;/th&gt;
&lt;th&gt;TFA1500-L&lt;/th&gt;
&lt;th&gt;LR2000E2&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Range (maker's figure)&lt;/td&gt;
&lt;td&gt;0.1–180 m&lt;/td&gt;
&lt;td&gt;0.2–100 m (70 % target)&lt;/td&gt;
&lt;td&gt;0.5–1,500 m&lt;/td&gt;
&lt;td&gt;4–2,000 m (standard range)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Update rate&lt;/td&gt;
&lt;td&gt;up to 7 kHz (product page)&lt;/td&gt;
&lt;td&gt;20 readings/s&lt;/td&gt;
&lt;td&gt;800 Hz near, 60 Hz far (adaptive)&lt;/td&gt;
&lt;td&gt;2–10 Hz (adaptive)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy&lt;/td&gt;
&lt;td&gt;see datasheet&lt;/td&gt;
&lt;td&gt;not stated on page&lt;/td&gt;
&lt;td&gt;±0.5 m (≤80 m), ±1.0 m (&amp;gt;80 m)&lt;/td&gt;
&lt;td&gt;±1 m (≤400 m); 0.4 % of distance (400–2,000 m)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Interface&lt;/td&gt;
&lt;td&gt;UART, CAN, RS-232, RS-485&lt;/td&gt;
&lt;td&gt;USB, UART, I2C&lt;/td&gt;
&lt;td&gt;UART 3.3 V TTL, 500,000 bps&lt;/td&gt;
&lt;td&gt;UART-TTL, 115,200 bps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supply&lt;/td&gt;
&lt;td&gt;datasheet&lt;/td&gt;
&lt;td&gt;datasheet&lt;/td&gt;
&lt;td&gt;datasheet&lt;/td&gt;
&lt;td&gt;3.3–5 V&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Power&lt;/td&gt;
&lt;td&gt;≤ 1 W&lt;/td&gt;
&lt;td&gt;datasheet&lt;/td&gt;
&lt;td&gt;≤ 1.8 W&lt;/td&gt;
&lt;td&gt;about 1.2 W&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weight&lt;/td&gt;
&lt;td&gt;86 ± 3 g&lt;/td&gt;
&lt;td&gt;30 g&lt;/td&gt;
&lt;td&gt;11 ± 0.5 g&lt;/td&gt;
&lt;td&gt;about 10 g&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Size (mm)&lt;/td&gt;
&lt;td&gt;44 × 43 × 32&lt;/td&gt;
&lt;td&gt;30 × 56 × 50&lt;/td&gt;
&lt;td&gt;≤ 25 × 26 × 13&lt;/td&gt;
&lt;td&gt;25.65 × 13.05 × 24.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Enclosure&lt;/td&gt;
&lt;td&gt;IP67&lt;/td&gt;
&lt;td&gt;not stated&lt;/td&gt;
&lt;td&gt;no enclosure&lt;/td&gt;
&lt;td&gt;IP67 (inside lens cavity)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Status / price shown&lt;/td&gt;
&lt;td&gt;catalogue item&lt;/td&gt;
&lt;td&gt;end of life; last price USD 199&lt;/td&gt;
&lt;td&gt;catalogue item&lt;/td&gt;
&lt;td&gt;USD 120 per unit (1–30), shipping included&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A blank-looking cell such as "datasheet" means the number was not on the public product page I read and I did not want to guess. Pull the PDF before you design.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the table honestly
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Range versus update rate is the real trade.&lt;/strong&gt; The TFA1500-L and the LR2000E2 are both bare, roughly 10 g modules with serial output. The Benewake part gives you 60 to 800 Hz depending on distance and a 1,500 m maximum. The ERDI part gives you 2 to 10 Hz and a 2,000 m standard range. If your loop needs to track a moving platform at tens of hertz, the faster sensor is the better answer. If you are measuring slowly changing distances to a building, a tower, a slope or a ridge, a 5 Hz reading is plenty and the extra 500 m of reach matters more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The 0.4 % figure is bigger than it looks.&lt;/strong&gt; The LR2000E2 accuracy is ±1 m up to 400 m, then 0.4 % of distance. At 2,000 m that is ±8 m. That is a fine number for "is the target there, roughly how far", and a poor one for survey-grade work. The TFA1500-L page quotes ±1.0 m beyond 80 m. Different sensors, different targets; compare the footnotes before you compare the numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check what range is measured against.&lt;/strong&gt; Whether a range was measured on a 70 % reflective building, a 90 % white board or an unspecified "standard" target changes the answer by a factor of two or more. The LR2000E2 table does not give reflectivity and size for its accuracy figures and states that actual reach depends on target and environment. Treat 2,000 m as the upper bound on a good target, not a typical figure on grass or dark rock.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SF11/C is now a reference point, not a purchase.&lt;/strong&gt; It is useful to include because countless ArduPilot and PX4 tutorials use it. The vendor lists it as end of life. If a tutorial tells you to buy one, you will need a current LightWare model or another sensor instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IP67 on the TF03 buys you a lot.&lt;/strong&gt; The TF03 is a finished sensor with an aluminium body and a band-pass window. The two bare modules are meant to go inside your own housing. If you are fitting the sensor to a vehicle or a pole outdoors without a custom enclosure, the TF03 saves you real engineering time. The LR2000E2 lists IP67 for the inside of the lens cavity, which describes the optical cavity, not a sealed external housing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integration effort
&lt;/h2&gt;

&lt;p&gt;Every module here speaks UART with a binary frame, but the frames differ.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The TF-series frames use their own header and checksum, and ArduPilot and PX4 have native drivers for the common Benewake serial protocols. For TFA1500-L, the vendor page states native PX4 and ArduPilot support.&lt;/li&gt;
&lt;li&gt;The LR2000E2 uses an 8-byte command and reply frame starting &lt;code&gt;55 AA&lt;/code&gt;, with the distance returned in tenths of a metre. There is no built-in flight-controller driver, so you either read it on a companion computer or microcontroller and forward it, or write a small scripting driver. A tested Python reader for the frame format is in a companion post, and an open-source driver set (Python, Arduino, ROS 2) is at &lt;a href="https://github.com/ErdiTech/erdi-lrf-drivers" rel="noopener noreferrer"&gt;https://github.com/ErdiTech/erdi-lrf-drivers&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The SF11/C offers USB, UART and I2C, and has long been supported by ArduPilot and PX4.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If "plugs straight into the flight controller with a stock driver" is a hard requirement, count that as a point for the Benewake and LightWare parts. If you are building a payload with its own microcontroller anyway, the integration gap shrinks to an afternoon.&lt;/p&gt;

&lt;h2&gt;
  
  
  A simple decision guide
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Need to track fast motion, 100–300 m?&lt;/strong&gt; Look at the TF03 class first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Need 1 km+ at low weight and high rate?&lt;/strong&gt; TFA1500-L is a strong candidate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Need 1.5–2 km reach at low cost, and a few readings per second is enough?&lt;/strong&gt; LR2000E2 fits: USD 120 per unit with shipping included, tiers down to USD 50 at 501+ units, 3.3–5 V supply.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Need ready-made flight-controller support and a sealed body?&lt;/strong&gt; TF03, or a current LightWare model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Need 100 m or less?&lt;/strong&gt; Do not pay for kilometre-class optics. A short-range sensor will have better accuracy and rate.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What I would test before committing
&lt;/h2&gt;

&lt;p&gt;Whatever you shortlist, test on a target you will actually see in the field.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log 200 readings on a dark, a mid and a bright target at the working distance. Count the dropouts.&lt;/li&gt;
&lt;li&gt;Run it in direct sun and in light haze. Ambient light immunity and visibility specs are where datasheets and field results part ways.&lt;/li&gt;
&lt;li&gt;Verify power: inrush at power-on and peak draw while ranging, on your real supply.&lt;/li&gt;
&lt;li&gt;Verify the signal logic level against your host before you connect.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Which is the best laser rangefinder module for a drone?&lt;/strong&gt; It depends on mass, rate and range. For landing and terrain following at tens of metres, a small fast sensor is better. For ranging far targets from a slow payload, a long-range module with a low update rate is acceptable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is there a laser rangefinder module with 2 km range under USD 150?&lt;/strong&gt; The ERDI LR2000E2 lists a 2,000 m standard range at USD 120 per unit for 1 to 30 pieces, shipping included, as of 2026-11-06. Accuracy beyond 400 m is 0.4 % of distance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between 905 nm and 1535 nm modules?&lt;/strong&gt; 905 nm modules use inexpensive silicon detectors and are common in small modules. 1535 nm modules are available at higher price points and are listed separately in ERDI's catalogue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do these modules need a flight-controller driver?&lt;/strong&gt; Benewake and LightWare parts have native support in ArduPilot and PX4. The LR2000E2 needs a bridge or a scripting driver.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Data checked 2026-11-06. Tommy Yu, ERDI TECH LTD, erdilrf.com&lt;/em&gt;&lt;/p&gt;

</description>
      <category>hardware</category>
      <category>drones</category>
      <category>robotics</category>
      <category>iot</category>
    </item>
    <item>
      <title>Reading a 2 km laser rangefinder module over UART with Python (LR2000E2, 55 AA protocol)</title>
      <dc:creator>Tommy Yu</dc:creator>
      <pubDate>Fri, 06 Nov 2026 01:55:09 +0000</pubDate>
      <link>https://dev.to/erdilrf_tommy/reading-a-2-km-laser-rangefinder-module-over-uart-with-python-lr2000e2-55-aa-protocol-3jaj</link>
      <guid>https://dev.to/erdilrf_tommy/reading-a-2-km-laser-rangefinder-module-over-uart-with-python-lr2000e2-55-aa-protocol-3jaj</guid>
      <description>&lt;p&gt;A laser rangefinder module is one of the easiest long-range sensors to wire up and one of the easiest to misread. The wiring is four wires. The mistakes happen in the protocol: a frame header you skip, a checksum you do not verify, a unit you assume. This post walks through a small, complete Python reader for the ERDI LR2000E2, a 905 nm UART laser rangefinder module with a published range of 4 to 2,000 m, and shows where the traps are.&lt;/p&gt;

&lt;p&gt;Everything below comes from the LR2000E2 user manual (v1.2, public edition 2026-09-06) and the product page at &lt;a href="https://erdilrf.com/models/lr2000e2/" rel="noopener noreferrer"&gt;https://erdilrf.com/models/lr2000e2/&lt;/a&gt;. Data checked on 2026-11-06.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the module is
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parameter&lt;/th&gt;
&lt;th&gt;LR2000E2 value (manufacturer table)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Wavelength&lt;/td&gt;
&lt;td&gt;905 ± 5 nm&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Range&lt;/td&gt;
&lt;td&gt;4–2,000 m (standard range; actual reach depends on target and environment)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy&lt;/td&gt;
&lt;td&gt;±1 m up to 400 m, then 0.4 % of distance up to 2,000 m&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Measurement rate&lt;/td&gt;
&lt;td&gt;2–10 Hz, adaptive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Interface&lt;/td&gt;
&lt;td&gt;UART-TTL, 115200 baud, 8 data bits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supply&lt;/td&gt;
&lt;td&gt;3.3–5 V&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Operating power&lt;/td&gt;
&lt;td&gt;about 1.2 W&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Start-up time&lt;/td&gt;
&lt;td&gt;200 ms or less&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Size / weight&lt;/td&gt;
&lt;td&gt;25.65 × 13.05 × 24.6 mm, about 10 g&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Laser safety&lt;/td&gt;
&lt;td&gt;Class 1 (manufacturer statement)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Temperature&lt;/td&gt;
&lt;td&gt;−20 to +60 °C&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Published price&lt;/td&gt;
&lt;td&gt;USD 120 per unit (1–30 pcs), shipping included&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two numbers matter for software. The rate is adaptive, so you should not build a 10 Hz control loop around it; treat it as a slow, long-reach sensor. And the "valid measurement rate" in the manual is 98 % or better up to 400 m and 80 % or better from 400 to 2,000 m, which means at long range one reading in five can legitimately be a failure. Your code has to handle failed readings as a normal case, not an exception.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wiring
&lt;/h2&gt;

&lt;p&gt;The manual lists a 6-pin connector:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pin&lt;/th&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;Power −&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;VCC&lt;/td&gt;
&lt;td&gt;Power + (3.3–5 V)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;I/O&lt;/td&gt;
&lt;td&gt;Reserved&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;TXD&lt;/td&gt;
&lt;td&gt;Module → host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;RXD&lt;/td&gt;
&lt;td&gt;Host → module&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;SW-SHOT&lt;/td&gt;
&lt;td&gt;Function enable, active high&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two practical notes. First, the manual states the 3.3–5 V supply range but does not separately specify the logic level of TXD and RXD. If you power the module at 5 V and talk to a 3.3 V-only microcontroller pin, measure TXD with a scope or meter first, or ask the manufacturer for the model-specific statement. A USB-serial adapter that supports 3.3 V levels is the safe starting point. Second, pin 6 is an enable input: the module expects it high to operate, so tie it according to the manual before wondering why nothing answers.&lt;/p&gt;

&lt;p&gt;The inrush current is below 400 mA, so use a supply that can deliver it without sagging. A weak USB hub that browns out at power-on will look like a protocol problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The protocol in one paragraph
&lt;/h2&gt;

&lt;p&gt;Frames are 8 bytes. A command is &lt;code&gt;55 AA &amp;lt;function&amp;gt; D1 D2 D3 D4 &amp;lt;checksum&amp;gt;&lt;/code&gt;, where the checksum is the low byte of the sum of the function code and the four data bytes. The reply is also 8 bytes: &lt;code&gt;55 AA &amp;lt;function&amp;gt; STA FF DIS_H DIS_L &amp;lt;checksum&amp;gt;&lt;/code&gt;. &lt;code&gt;STA = 1&lt;/code&gt; means success; any other value means the measurement failed. The distance is &lt;code&gt;DIS_H * 256 + DIS_L&lt;/code&gt;, and the manual states that all results are output as the actual value × 10, so you divide by 10 to get metres.&lt;/p&gt;

&lt;p&gt;The four documented commands:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Bytes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Single-shot ranging&lt;/td&gt;
&lt;td&gt;&lt;code&gt;55 AA 88 FF FF FF FF 84&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Continuous ranging&lt;/td&gt;
&lt;td&gt;&lt;code&gt;55 AA 89 FF FF FF FF 85&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stop ranging&lt;/td&gt;
&lt;td&gt;&lt;code&gt;55 AA 8E FF FF FF FF 8A&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Angle measurement&lt;/td&gt;
&lt;td&gt;&lt;code&gt;55 AA 8A FF FF FF FF 86&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You can check the checksum column by hand: &lt;code&gt;0x88 + 4 × 0xFF = 0x484&lt;/code&gt;, low byte &lt;code&gt;0x84&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A complete reader
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;serial&lt;/span&gt;  &lt;span class="c1"&gt;# pip install pyserial
&lt;/span&gt;
&lt;span class="n"&gt;HEADER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\x55\xAA&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\xFF\xFF\xFF\xFF&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;HEADER&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;CMD_SINGLE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x88&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;CMD_CONT&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x89&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;CMD_STOP&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x8E&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Reading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;metres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metres&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;metres&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__repr__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Reading(ok=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, metres=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metres&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Reading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;HEADER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Reading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;strict&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Reading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                      &lt;span class="c1"&gt;# STA: 1 = success
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Reading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Reading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;10.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Hunt for 55 AA so a half-received frame never shifts every later field.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;
    &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;deadline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;HEADER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;HEADER&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;single_shot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Reading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset_input_buffer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CMD_SINGLE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;COM5&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;115200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="c1"&gt;# /dev/ttyUSB0 on Linux
&lt;/span&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;single_shot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c1"&gt;# continuous mode
&lt;/span&gt;        &lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CMD_CONT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;t_end&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;t_end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metres&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;7.1&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; m&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;ser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CMD_STOP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few details worth explaining.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;sync()&lt;/code&gt; instead of &lt;code&gt;ser.read(8)&lt;/code&gt;.&lt;/strong&gt; Reading a fixed 8 bytes works until the first dropped byte, after which every frame is misaligned and you decode garbage forever. Searching for &lt;code&gt;55 AA&lt;/code&gt; first costs nothing and removes that failure class. Note the small gap: a data byte pair of &lt;code&gt;55 AA&lt;/code&gt; inside a payload would false-trigger, which is why the strict checksum option exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;strict&lt;/code&gt; defaults to off.&lt;/strong&gt; The manual text describes the reply checksum as the sum from the first header byte to DATA4. Enable &lt;code&gt;strict=True&lt;/code&gt; on your bench first and log what you see; if your unit's replies agree with the formula, leave it on in production. If they do not, you have found a document or firmware difference worth reporting to the supplier before you design anything around it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Failed readings are normal.&lt;/strong&gt; &lt;code&gt;ok=False&lt;/code&gt; is returned for a bad frame and for &lt;code&gt;STA != 1&lt;/code&gt;. Keep the last good value with a timestamp and a staleness limit instead of passing &lt;code&gt;None&lt;/code&gt; downstream.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Units.&lt;/strong&gt; Dividing by 10 is specific to this model family. Other modules from other vendors, and even other ERDI families, report millimetres or centimetres. Never copy a divisor from a sibling model; take it from that model's manual.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing it without a target 2 km away
&lt;/h2&gt;

&lt;p&gt;You do not need a 2 km line of sight to test the software. Point the module at a wall at a known distance such as 5 m or 20 m, measure with a tape, and log 100 single shots. Plot the histogram. You are checking three things: the mean against the tape, the spread against the ±1 m accuracy band, and the fraction of &lt;code&gt;STA != 1&lt;/code&gt; readings. For targets that are well inside the range, the failure fraction should be very small. If it is not, check supply sag and the SW-SHOT line before suspecting the optics.&lt;/p&gt;

&lt;p&gt;For the long-range claim, treat the datasheet range as a statement about a target and conditions, not a promise. The accuracy table does not specify target reflectivity and size, and real reach depends on weather, target colour, angle and sun. A low-reflectivity target at an oblique angle will fall short of 2,000 m. Plan for margin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reusing a tested driver
&lt;/h2&gt;

&lt;p&gt;If you would rather not maintain this yourself, ERDI publishes an open-source driver set for its 905 nm modules (Python, Arduino and ROS 2) at &lt;a href="https://github.com/ErdiTech/erdi-lrf-drivers" rel="noopener noreferrer"&gt;https://github.com/ErdiTech/erdi-lrf-drivers&lt;/a&gt;. Each constant in it is cited to the model's manual, which is the point: the unit divisor, baud rate and frame length are per model, not per family.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is the maximum range of the LR2000E2?&lt;/strong&gt; The manufacturer's table gives 4 to 2,000 m as the standard range, with accuracy of ±1 m up to 400 m and 0.4 % of distance beyond. Actual reach depends on target reflectivity, size and weather.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What baud rate does it use?&lt;/strong&gt; 115200 bps, 8 data bits, frame length 8 bytes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I convert the reading to metres?&lt;/strong&gt; Combine the two data bytes into an integer and divide by 10.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I power it from 5 V?&lt;/strong&gt; The supply range is 3.3 to 5 V. The signal-pin logic level is not stated separately in the manual, so verify before connecting to a 3.3 V-only input.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is it eye-safe?&lt;/strong&gt; The manufacturer states Class 1. Check the model's own document and local regulations for your product.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does it cost?&lt;/strong&gt; USD 120 per unit for 1 to 30 pieces, with shipping included, as published on the product page on 2026-11-06.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Tommy Yu, ERDI TECH LTD, erdilrf.com&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>iot</category>
      <category>hardware</category>
      <category>embedded</category>
    </item>
    <item>
      <title>Spot size and latency: the two rangefinder numbers that decide whether your robot sees the obstacle</title>
      <dc:creator>Tommy Yu</dc:creator>
      <pubDate>Sat, 24 Oct 2026 13:40:49 +0000</pubDate>
      <link>https://dev.to/erdilrf_tommy/spot-size-and-latency-the-two-rangefinder-numbers-that-decide-whether-your-robot-sees-the-obstacle-3pkc</link>
      <guid>https://dev.to/erdilrf_tommy/spot-size-and-latency-the-two-rangefinder-numbers-that-decide-whether-your-robot-sees-the-obstacle-3pkc</guid>
      <description>&lt;p&gt;Two rangefinders can quote the same maximum range and still behave completely differently on the same vehicle. In my experience the difference usually comes down to two numbers that are buried in the datasheet, or missing from it entirely: &lt;strong&gt;spot size at the target&lt;/strong&gt; and &lt;strong&gt;measurement latency&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This note is a practical worksheet for comparing laser rangefinder modules before you bolt one onto a drone, a robot or a gimbal. It is written from the vendor side (disclosure at the end), but the arithmetic is the arithmetic.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Spot size: the number that connects the datasheet to the installation
&lt;/h2&gt;

&lt;p&gt;Beam divergence is the angle at which the beam spreads after it leaves the module. For small angles, the spot diameter at distance &lt;code&gt;R&lt;/code&gt; is approximately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spot_diameter ≈ R × θ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with &lt;code&gt;θ&lt;/code&gt; in radians. Millimetres of milliradians are easier: &lt;code&gt;1 mrad ≈ 1 mm per metre&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;4.5 mrad at 100 m → about 0.45 m across&lt;/li&gt;
&lt;li&gt;10 mrad at 100 m → about 1.0 m across&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is the difference between "illuminating a drone-sized target" and "illuminating the hillside behind it". A wide beam is forgiving to aim and friendly on a moving gimbal; a narrow beam concentrates the return on small targets but demands better pointing stability and a stiffer mount.&lt;/p&gt;

&lt;p&gt;Two practical consequences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Small targets at long range&lt;/strong&gt;: if the spot is wider than the target, most of the emitted energy lands on the background. The receiver still gets a return, but it is the background's return. The reading can look plausible and still be wrong.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alignment tolerances&lt;/strong&gt;: a 1 mrad pointing error moves the spot by 10 cm at 100 m. On a flexing carbon arm, that is not a rounding error.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before trusting a range figure, ask for the divergence, the receiver aperture and the target reflectivity used in the test. If a datasheet gives only "max range", it has told you almost nothing about your installation.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Latency and update rate: the number your control loop actually feels
&lt;/h2&gt;

&lt;p&gt;A 10 Hz update rate is one sample every 100 ms. At 5 m/s, the vehicle has moved &lt;strong&gt;0.5 m&lt;/strong&gt; between two readings. A 1 kHz rate is one sample every millisecond — roughly 1 mm of travel at the same speed.&lt;/p&gt;

&lt;p&gt;That gap is not cosmetic. If the loop closes on stale data, it will overshoot, oscillate, or brake late. The fix is not always "buy the fastest module": it is to match the rate to the motion.&lt;/p&gt;

&lt;p&gt;A rough way to size it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;required_rate ≈ (allowed position error) / (max closing speed)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you can tolerate 20 cm of error while closing at 4 m/s, you need at least 20 Hz &lt;em&gt;and&lt;/em&gt; you need the latency of the whole chain — module, UART, parser, control loop — to be inside that budget. The module datasheet is only the first term.&lt;/p&gt;

&lt;p&gt;Some modules auto-switch: they run fast at short range and drop to a lower rate at long range, where more averaging is needed to get a usable return. That is a reasonable engineering trade, but it means the "update rate" line on the datasheet may be a best case. Ask what the rate is at the range you care about.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. A comparison checklist that survives procurement
&lt;/h2&gt;

&lt;p&gt;When you compare modules, write these down for each candidate:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Divergence (mrad) and the resulting spot at your operating range.&lt;/li&gt;
&lt;li&gt;Update rate at your operating range, not just the headline maximum.&lt;/li&gt;
&lt;li&gt;Latency from measurement to UART frame out, plus the frame size at your baud rate.&lt;/li&gt;
&lt;li&gt;Interface and protocol: UART TTL levels, frame format, checksum, unit of the distance field.&lt;/li&gt;
&lt;li&gt;Behaviour when the return is weak: last-value hold, error flag, or a plausible-looking wrong number.&lt;/li&gt;
&lt;li&gt;What the test target was — reflectivity, size, ambient light.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Point 5 is the one that bites in the field. A module that holds the last good value silently is harder to debug than one that returns an explicit error. Whichever behaviour your module has, make the parser handle it explicitly rather than treating every frame as truth.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Why I wrote this down
&lt;/h2&gt;

&lt;p&gt;We build 905 nm and 1535 nm laser rangefinder modules, and most integration questions we get are not about the laser at all — they are about spot size, timing and protocol framing. Two of our engineering notes go deeper on the geometry and on update-rate selection:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Beam divergence and spot size: &lt;a href="https://erdilrf.com/knowledge/rangefinder-beam-divergence-spot-size/" rel="noopener noreferrer"&gt;https://erdilrf.com/knowledge/rangefinder-beam-divergence-spot-size/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Update rate for moving platforms: &lt;a href="https://erdilrf.com/knowledge/rangefinder-update-rate-moving-platforms/" rel="noopener noreferrer"&gt;https://erdilrf.com/knowledge/rangefinder-update-rate-moving-platforms/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Module list and datasheets: &lt;a href="https://erdilrf.com/models/" rel="noopener noreferrer"&gt;https://erdilrf.com/models/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are comparing modules, the checklist above is the part worth copying into your own spreadsheet. The range number is the least interesting column in it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I work on integration support at ERDI TECH LTD (erdilrf.com), which makes laser rangefinder modules. The arithmetic and the checklist above apply to any module; the links point to our own engineering notes.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>hardware</category>
      <category>robotics</category>
      <category>drones</category>
      <category>engineering</category>
    </item>
    <item>
      <title>Same 4 bytes, 10x different distance: notes from writing a laser rangefinder UART driver</title>
      <dc:creator>Tommy Yu</dc:creator>
      <pubDate>Mon, 12 Oct 2026 03:23:10 +0000</pubDate>
      <link>https://dev.to/erdilrf_tommy/reading-a-905-nm-laser-rangefinder-module-over-uart-arduino-raspberry-pi-and-ros-2-gal</link>
      <guid>https://dev.to/erdilrf_tommy/reading-a-905-nm-laser-rangefinder-module-over-uart-arduino-raspberry-pi-and-ros-2-gal</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure up front: I work for ERDILRF in Chengdu, the company that makes these modules. Every frame, baud rate and unit below is transcribed from our manuals. I'm not publishing any bench measurements here, and there's a section at the end on what hasn't been verified.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Quick quiz. Here's a frame from a laser rangefinder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5C 02 11 EC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What's the distance?&lt;/p&gt;

&lt;p&gt;If you said "depends on the model," you've probably been burned before. On one of our H-series modules it's 43.54 m. On a VB-series module it's 4.354 m. Same four bytes.&lt;/p&gt;

&lt;p&gt;When you wire one of these up for the first time, there are two ways it usually goes wrong. Either the terminal stays completely silent, or you get numbers that look plausible and are off by a factor of ten. The second one is worse, because nothing complains. In my experience both usually come down to protocol details, not wiring.&lt;/p&gt;

&lt;p&gt;Here's what's worth knowing before you write a line of code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two protocol families, two read loops
&lt;/h2&gt;

&lt;p&gt;Our 905 nm catalogue speaks two different UART protocols.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Family A&lt;/strong&gt; uses an 8-byte &lt;code&gt;55 AA&lt;/code&gt; command/response protocol. That covers LR1000E2/E4, LR1200E2/E4, LR1500E2/E4, LR2000E2/E4, LRF1200A1, LRF3000A1, SPD1200N0/N2/N4 and SPD1200D03. You ask, it answers. For the LRF3000A1 example here, the manual specifies 115200 bps by default. Select the baud rate from the exact model's manual and confirm the delivered configuration. SPD1200D03 has an unresolved source conflict: its protocol section states 115200 bps, while its technical table states 15200 bps (factory) / 9600 bps. Confirm the actual batch configuration with ERDI before choosing a host baud rate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Family B&lt;/strong&gt; streams &lt;code&gt;5C&lt;/code&gt; frames on its own, at 460800 bps by default (adjustable), 8 data bits, 1 stop bit, no parity, little-endian. That's LRF50H/100H/200H/300H/600H/1500H plus LRF22VB and LRF50VB. It just keeps talking.&lt;/p&gt;

&lt;p&gt;These two need different read loops, so figure out which one you have first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Family A: the checksum isn't the same in both directions
&lt;/h2&gt;

&lt;p&gt;Single-shot request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;55 AA 88 FF FF FF FF 84
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight m68k"&gt;&lt;code&gt;&lt;span class="nl"&gt;55&lt;/span&gt; &lt;span class="nv"&gt;AA&lt;/span&gt; &lt;span class="mi"&gt;88&lt;/span&gt; &lt;span class="nv"&gt;STA&lt;/span&gt; &lt;span class="nv"&gt;FF&lt;/span&gt; &lt;span class="nv"&gt;DIS_H&lt;/span&gt; &lt;span class="nv"&gt;DIS_L&lt;/span&gt; &lt;span class="nv"&gt;SUM&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;STA = 1&lt;/code&gt; means success. Distance is &lt;code&gt;DIS_H&amp;lt;&amp;lt;8 | DIS_L&lt;/code&gt; (big-endian), and the manual says results are output as the real value x 10, so one count is 0.1 m. Continuous mode uses function code &lt;code&gt;0x89&lt;/code&gt;, stop is &lt;code&gt;0x8E&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here's the part that eats an afternoon:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tx_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# request: Function + D1..D4
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;rx_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# reply: 0x55 + 0xAA + Function + D1..D4
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two differ by exactly &lt;code&gt;0x55 + 0xAA = 0xFF&lt;/code&gt;. Validate replies with the transmit formula and you'll be off by one on almost every frame. It also matches now and then, which is what makes it so confusing. You start suspecting cables, noise, the power supply...&lt;/p&gt;

&lt;p&gt;A hand-checked example (constructed, not captured from hardware):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromhex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;55AA8801FF04D25D&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nf"&gt;rx_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;             &lt;span class="c1"&gt;# 0x35D -&amp;gt; low byte 0x5D
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;                     &lt;span class="c1"&gt;# STA: success
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(((&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# 1234 counts -&amp;gt; 123.4 m
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Family B: units follow the model, not the family
&lt;/h2&gt;

&lt;p&gt;Frame: &lt;code&gt;5C dist_lo dist_hi check&lt;/code&gt;. The check byte is the bitwise inverse of the sum of the bytes between header and check.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;parse_b4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mh"&gt;0x5C&lt;/span&gt;
    &lt;span class="nf"&gt;assert &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# little-endian
&lt;/span&gt;
&lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parse_b4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromhex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;5C0211EC&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;   &lt;span class="c1"&gt;# 4354
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Raw unit&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;5C 02 11 EC&lt;/code&gt; means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;LRF50H/100H/200H/300H/600H/1500H&lt;/td&gt;
&lt;td&gt;cm&lt;/td&gt;
&lt;td&gt;43.54 m&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LRF22VB, LRF50VB&lt;/td&gt;
&lt;td&gt;mm&lt;/td&gt;
&lt;td&gt;4.354 m&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;My strong opinion: &lt;strong&gt;don't auto-detect.&lt;/strong&gt; Make the caller name the model. Clever auto-detection that guesses wrong won't throw. It'll just hand your obstacle-avoidance code a number that's ten times off.&lt;/p&gt;

&lt;p&gt;One more oddity: LRF1500H is the only 5-byte frame (3-byte distance), and the example frame in its manual doesn't pass its own checksum formula. The driver keeps that discrepancy visible instead of quietly "fixing" it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wiring: supply voltage isn't signal level
&lt;/h2&gt;

&lt;p&gt;These are two separate specs. Don't infer one from the other.&lt;/p&gt;

&lt;p&gt;For the LRF3000A1, the manual's 6-pin connector (A1002WV-S-6P) is: 1 GND, 2 power 3.3-5 V DC, 3 NC, 4 TTL_TXD (3.3 V TTL), 5 TTL_RXD (3.3 V TTL), 6 Enable (power on at low level). Cross TX/RX, share ground, and don't leave Enable floating. Follow whatever documentation shipped with your unit.&lt;/p&gt;

&lt;p&gt;Other models are very different. LRF50H takes 9-36 V and LRF22VB takes 3.0-3.6 V. If your manual doesn't state a signal level, get it confirmed in writing before you connect anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Just use the driver
&lt;/h2&gt;

&lt;p&gt;Once the trap list got this long, we wrapped it all up: model table, checksums and unit conversion. It's MIT-licensed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python (Raspberry Pi or a PC with a USB-TTL adapter):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;https://github.com/ErdiTech/erdi-lrf-drivers/releases/download/v0.1.0/erdi_lrf-0.1.0-py3-none-any.whl
erdi-lrf &lt;span class="nt"&gt;--port&lt;/span&gt; /dev/ttyUSB0 &lt;span class="nt"&gt;--model&lt;/span&gt; LRF3000A1 measure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;erdi_lrf&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ErdiLRF&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nc"&gt;ErdiLRF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/dev/ttyUSB0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;LRF3000A1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;lrf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;lrf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measure&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;metres&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; m&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nc"&gt;ErdiLRF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/dev/ttyUSB0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;LRF100H&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;lrf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lrf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metres&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;(out of range)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;out_of_range&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The codecs are pure functions with no serial dependency, so you can unit-test them offline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arduino:&lt;/strong&gt; install &lt;code&gt;ErdiLRF&lt;/code&gt; from the Library Manager (PlatformIO: &lt;code&gt;erdi-tech/ErdiLRF&lt;/code&gt;). There's an older, similarly named &lt;code&gt;ERDILRF_LRF&lt;/code&gt; in the index; that's not this one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;ErdiLRF.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="n"&gt;ErdiLRF&lt;/span&gt; &lt;span class="nf"&gt;lrf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Serial1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ERDI_LRF3000A1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;115200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;Serial1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;erdiDefaultBaud&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ERDI_LRF3000A1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  &lt;span class="c1"&gt;// 115200 default for this LRF3000A1 example; use the exact model manual&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;ErdiMeasurement&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lrf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;ERDI_OK&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metres&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heads-up: SoftwareSerial on an Uno can't do 460800. Family B needs a hardware UART (Mega, ESP32, etc.), or drop the module to a lower documented rate first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ROS 2:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; ros2/erdi_lrf_ros2 ~/ros2_ws/src/
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/ros2_ws &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; colcon build &lt;span class="nt"&gt;--packages-select&lt;/span&gt; erdi_lrf_ros2
&lt;span class="nb"&gt;source install&lt;/span&gt;/setup.bash
ros2 run erdi_lrf_ros2 range_node &lt;span class="nt"&gt;--ros-args&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; port:&lt;span class="o"&gt;=&lt;/span&gt;/dev/ttyUSB0 &lt;span class="nt"&gt;-p&lt;/span&gt; model:&lt;span class="o"&gt;=&lt;/span&gt;LRF3000A1 &lt;span class="nt"&gt;-p&lt;/span&gt; rate:&lt;span class="o"&gt;=&lt;/span&gt;10.0 &lt;span class="nt"&gt;-p&lt;/span&gt; frame_id:&lt;span class="o"&gt;=&lt;/span&gt;lrf_link
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It publishes &lt;code&gt;sensor_msgs/Range&lt;/code&gt;. &lt;code&gt;field_of_view&lt;/code&gt; defaults to 0 because the protocol manuals carry no beam divergence, so set it from your model's datasheet.&lt;/p&gt;

&lt;h2&gt;
  
  
  When the manual argues with itself
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SPD1200D03:&lt;/strong&gt; the protocol section says 115200, the technical table says 15200/9600. The driver makes you pass the baud explicitly and returns no metric distance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LRF1200A1 / LRF3000A1:&lt;/strong&gt; continuous ranging is requested with &lt;code&gt;0x89&lt;/code&gt; but the recorded reply uses &lt;code&gt;0x88&lt;/code&gt;, and the manual declines to authorise a reply parser. Single-shot is fine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LRF50VB:&lt;/strong&gt; the printed serial-number request fails the manual's own checksum function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A driver that guesses here is more dangerous than one that throws. Open a ticket with the vendor instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's not verified
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No measurement results or performance claims. Check your model's datasheet.&lt;/li&gt;
&lt;li&gt;The ROS 2 node has been tested in software replay only, not against a live ROS 2 runtime with hardware.&lt;/li&gt;
&lt;li&gt;Driver tests are built from the frames printed in the manuals. The Python snippets above were checked only against the example frames in this post.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/ErdiTech/erdi-lrf-drivers" rel="noopener noreferrer"&gt;https://github.com/ErdiTech/erdi-lrf-drivers&lt;/a&gt; (MIT)&lt;br&gt;
Arduino library: &lt;a href="https://github.com/ErdiTech/ErdiLRF" rel="noopener noreferrer"&gt;https://github.com/ErdiTech/ErdiLRF&lt;/a&gt;&lt;br&gt;
Technical note (DOI): &lt;a href="https://doi.org/10.5281/zenodo.23297197" rel="noopener noreferrer"&gt;https://doi.org/10.5281/zenodo.23297197&lt;/a&gt;&lt;br&gt;
Model catalogue: &lt;a href="https://erdilrf.com/models/" rel="noopener noreferrer"&gt;https://erdilrf.com/models/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your unit behaves differently from its manual, I'd really like to hear about it in the comments or as an issue.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Vendor disclosure: the author is affiliated with ERDI TECH LTD (ERDILRF). Samples, datasheets and protocol questions: &lt;a href="https://erdilrf.com" rel="noopener noreferrer"&gt;https://erdilrf.com&lt;/a&gt; or &lt;a href="mailto:tommy@erdimail.com"&gt;tommy@erdimail.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>raspberrypi</category>
      <category>ros</category>
      <category>hardware</category>
    </item>
  </channel>
</rss>
