<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ERDI Laser Rangefinder Notes]]></title><description><![CDATA[Practical guides for integrating laser rangefinder modules: 905 nm and 1535 nm UART modules, datasheet reading, ESP32, Raspberry Pi, ROS 2 and MAVLink examples,]]></description><link>https://erdi-lrf-notes.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6aed350356f05c629061e290/14c024bb-4b28-4e76-9417-abda23f72868.png</url><title>ERDI Laser Rangefinder Notes</title><link>https://erdi-lrf-notes.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 21 Nov 2026 18:31:36 GMT</lastBuildDate><atom:link href="https://erdi-lrf-notes.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[905 nm or 1535 nm for an OEM build: reading two real datasheets side by side]]></title><description><![CDATA[Compare LRF3000A1 (905 nm) and LRF0306C (1535 nm) row by row: target conditions, beam divergence, power, mass and spot-size arithmetic.]]></description><link>https://erdi-lrf-notes.hashnode.dev/905-nm-or-1535-nm-for-an-oem-build-reading-two-real-datasheets-side-by-side</link><guid isPermaLink="true">https://erdi-lrf-notes.hashnode.dev/905-nm-or-1535-nm-for-an-oem-build-reading-two-real-datasheets-side-by-side</guid><dc:creator><![CDATA[Tommy Yu]]></dc:creator><pubDate>Tue, 17 Nov 2026 21:09:54 GMT</pubDate><content:encoded><![CDATA[<p><em>Series: Laser Rangefinder Integration. Earlier parts covered an <a href="https://erdi-lrf-notes.hashnode.dev/esp32-a-1-5-km-laser-rangefinder-module-serial-reader-and-mqtt-publisher-lr1500e2">ESP32 serial reader</a> and <a href="https://erdi-lrf-notes.hashnode.dev/ros-2-laser-rangefinder-integration-publishing-sensor-msgs-range-from-a-uart-module">ROS 2</a>. This part is about choosing the module before you wire it.</em></p>
<p>The question "should I use 905 nm or 1535 nm?" comes in most weeks. The honest answer from our own engineering notes is that wavelength does not set the range. Pulse energy, receiver sensitivity, aperture, beam divergence, target reflectivity, ambient light and the detection threshold do. So instead of a general argument, this post puts two real ERDI datasheets next to each other and shows which rows actually separate them. I work at ERDI TECH LTD, which makes both. Every number below is from the model documents, checked on 2026-11-18, with the test condition kept next to it.</p>
<h2>The two modules</h2>
<table>
<thead>
<tr>
<th>Row</th>
<th>LRF3000A1 (905 nm)</th>
<th>LRF0306C (1535 nm)</th>
</tr>
</thead>
<tbody><tr>
<td>Stated maximum range</td>
<td>≥ 3,000 m at 70% reflectivity, building target, clear weather, visibility ≥ 4 km</td>
<td>≥ 4,000 m at 60% reflectivity, building target, visibility &gt; 8 km</td>
</tr>
<tr>
<td>Same module, other targets</td>
<td>not given in the table</td>
<td>≥ 3,000 m at 30%, 2.3 × 2.3 m; ≥ 1,500 m at 30%, 0.5 × 1.7 m; ≥ 800 m at 30%, 0.2 × 0.3 m</td>
</tr>
<tr>
<td>Minimum range</td>
<td>1 m</td>
<td>≤ 10 m</td>
</tr>
<tr>
<td>Accuracy</td>
<td>±0.7 m up to 100 m, then ±(0.7 + 0.003·d) m</td>
<td>±1 m</td>
</tr>
<tr>
<td>Rate</td>
<td>3 to 10 Hz (long-range mode 1 to 10 Hz)</td>
<td>1 to 3 Hz</td>
</tr>
<tr>
<td>Beam divergence</td>
<td>≤ 10 mrad typical, receiver field of view about 8 mrad</td>
<td>≤ 0.6 mrad</td>
</tr>
<tr>
<td>Interface and supply</td>
<td>UART, TTL 3.3 V; DC 3.3 to 5 V</td>
<td>UART, TTL 3.3 V; DC 3 to 5 V</td>
</tr>
<tr>
<td>Power</td>
<td>≤ 1.8 W at +25 °C</td>
<td>5 V: ≤ 0.9 W at 1 Hz, &lt; 1.1 W at 3 Hz; peak ≤ 3 W</td>
</tr>
<tr>
<td>Mass</td>
<td>12 ± 0.5 g</td>
<td>≤ 14 ± 1 g</td>
</tr>
<tr>
<td>Protection</td>
<td>IP67</td>
<td>not stated in the datasheet</td>
</tr>
<tr>
<td>Operating temperature</td>
<td>-20 to +60 °C</td>
<td>-40 to +70 °C</td>
</tr>
<tr>
<td>Laser class statement</td>
<td>Class 1 (IEC 60825-1)</td>
<td>Class I (IEC 60825-1)</td>
</tr>
<tr>
<td>Published price, 1 piece</td>
<td>$200</td>
<td>$500 (falls with quantity)</td>
</tr>
</tbody></table>
<p>Three things in that table are easy to miss.</p>
<p><strong>The headline numbers use different conditions.</strong> 3,000 m at 70% reflectivity with 4 km visibility and 3,000 m at 30% reflectivity on a 2.3 m square board with 8 km visibility are not the same claim. If you compare only the first line of each datasheet you are comparing two different experiments. Keep the target size, the reflectivity and the visibility with the number, and rewrite your own requirement in those terms before you shortlist anything.</p>
<p><strong>Beam divergence differs by a factor of about 16.</strong> 10 mrad against 0.6 mrad. That is the row that decides small-target work, and it is not a wavelength property. It is optics.</p>
<p><strong>The class statements are the manufacturer's.</strong> Both documents state a class, and that is a statement about the module. Classification applies to the finished configuration, and wavelength alone does not establish it. A 1535 nm source is attractive for eye safety because the retina is better protected at that wavelength, but corneal limits still apply, and nobody should read "1535 nm" as "safe" without a classification for the product they ship.</p>
<h2>Beam arithmetic: will the spot fit the target?</h2>
<p>The footprint diameter is range times divergence in radians. Here it is as code, with the two modules' numbers:</p>
<pre><code class="language-python">def spot_m(range_m, divergence_mrad):
    """Beam footprint diameter in metres: range x divergence (small-angle)."""
    return range_m * divergence_mrad / 1000.0

def fits(target_w_m, target_h_m, range_m, divergence_mrad):
    s = spot_m(range_m, divergence_mrad)
    return s, s &lt;= min(target_w_m, target_h_m)

print(spot_m(1000, 10), spot_m(3000, 10))                       # 10.0 30.0
print(spot_m(800, 0.6), spot_m(1500, 0.6), spot_m(3000, 0.6))   # 0.48 0.9 1.8
print(fits(0.2, 0.3, 800, 0.6))      # (0.48, False)
print(fits(2.3, 2.3, 3000, 0.6))     # (1.8, True)
</code></pre>
<p>I ran this before pasting it. At 1,000 m the 10 mrad beam is already 10 m across, so on anything smaller than a building face the background shares the footprint. The 0.6 mrad beam is 0.9 m across at 1,500 m, which covers the 0.5 m side of the person-sized board only partly. At 800 m it is 0.48 m, wider than the 0.2 m side of the smallest listed target. The datasheet still quotes 800 m for that board, which tells you the figure assumes a partially filled spot. That matters when you decide how much margin to leave.</p>
<p>Why the target size changes the number so much: for a target that fills the beam, the returned power falls roughly with the square of the range. For a target smaller than the footprint it falls roughly with the fourth power. Doubling the range costs a factor of about 4 in the first case and about 16 in the second. This is general lidar-equation behaviour, not an ERDI measurement, but it explains the ladder of 4,000, 3,000, 1,500 and 800 m on the 1535 nm datasheet as the target shrinks.</p>
<h2>So which one?</h2>
<p>The order I would work in:</p>
<ol>
<li>Write the target you must measure as size, reflectivity and the worst visibility you accept. If it is a building face or a hillside, divergence matters less and the cheaper module may be enough. If it is a pole, a person or a vehicle at distance, divergence and the small-target row decide.</li>
<li>Check the minimum range against your mounting. 1 m against 10 m is a mechanical decision before it is an optical one.</li>
<li>Check the update rate against the platform. 1 to 3 Hz is fine for a survey point and slow for anything that moves.</li>
<li>Check the rail. 5 V at 0.9 W with a 3 W peak is a different supply problem from 1.8 W steady. Read the average-versus-peak note before you size the regulator.</li>
<li>Only then look at the safety case and the price.</li>
</ol>
<p>Neither module wins outright. The 905 nm one is cheaper and faster; the 1535 nm one has a far narrower beam and a wider temperature range. What we do not claim: a laser class for your finished product, "eye safe" without qualification, or a single range number without its target and visibility.</p>
<h2>Links</h2>
<ul>
<li>Full comparison page: <a href="https://erdilrf.com/905nm-vs-1535nm-laser-rangefinder-module/?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=hashnode-905-vs-1535-202611">https://erdilrf.com/905nm-vs-1535nm-laser-rangefinder-module/?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=hashnode-905-vs-1535-202611</a></li>
<li>Beam divergence and spot size: <a href="https://erdilrf.com/knowledge/rangefinder-beam-divergence-spot-size/?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=hashnode-905-vs-1535-202611">https://erdilrf.com/knowledge/rangefinder-beam-divergence-spot-size/?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=hashnode-905-vs-1535-202611</a></li>
<li>Model pages: <a href="https://erdilrf.com/models/lrf3000a1/">https://erdilrf.com/models/lrf3000a1/</a> and <a href="https://erdilrf.com/models/lrf0306c/">https://erdilrf.com/models/lrf0306c/</a></li>
<li>Open-source drivers and protocol notes: <a href="https://github.com/ErdiTech/erdi-lrf-drivers">https://github.com/ErdiTech/erdi-lrf-drivers</a></li>
</ul>
<p><em>I am Tommy Yu, an engineer at ERDI TECH LTD (erdilrf.com), the manufacturer of the modules discussed. Data checked against the model documents on 2026-11-18. Contact: <a href="mailto:tommy@erdimail.com">tommy@erdimail.com</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[ROS 2 laser rangefinder integration: publishing sensor_msgs/Range from a UART module]]></title><description><![CDATA[Install a ROS 2 driver or write a 60-line node that publishes sensor_msgs/Range from a UART laser rangefinder, with REP-117 handling.]]></description><link>https://erdi-lrf-notes.hashnode.dev/ros-2-laser-rangefinder-integration-publishing-sensor-msgs-range-from-a-uart-module</link><guid isPermaLink="true">https://erdi-lrf-notes.hashnode.dev/ros-2-laser-rangefinder-integration-publishing-sensor-msgs-range-from-a-uart-module</guid><category><![CDATA[robotics]]></category><category><![CDATA[lidar]]></category><category><![CDATA[Python]]></category><category><![CDATA[embedded]]></category><dc:creator><![CDATA[Tommy Yu]]></dc:creator><pubDate>Fri, 06 Nov 2026 14:38:17 GMT</pubDate><content:encoded><![CDATA[<p><em>Series: Laser Rangefinder Integration. Part 1: <a href="https://erdi-lrf-notes.hashnode.dev/esp32-a-1-5-km-laser-rangefinder-module-serial-reader-and-mqtt-publisher-lr1500e2">ESP32 + a 1.5 km laser rangefinder module, serial reader and MQTT publisher</a>. Part 2 (this post): ROS 2.</em></p>
<p>Most single-point laser rangefinder modules speak a vendor UART protocol, not ROS. To use one on a robot, an AGV or a drone companion computer, you want a node that publishes <code>sensor_msgs/msg/Range</code> so that the rest of the stack (a costmap layer, <code>robot_localization</code>, a MAVLink bridge, your own logic) can consume it without knowing anything about serial bytes.</p>
<p>This guide does that for ERDI's 905 nm UART modules (LR1000E2 to LR2000E2, LRF1200A1, LRF3000A1, SPD1200 series, H and VB series). You get two routes: a ready-made package, and a 60-line node you can read and change. Module facts were read from the model pages at erdilrf.com on <strong>2026-11-07</strong>.</p>
<h2>What you are integrating</h2>
<p>A long-range ERDI module such as the <a href="https://erdilrf.com/models/lr2000e2/">LR2000E2</a> gives you:</p>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Value (manufacturer table)</th>
</tr>
</thead>
<tbody><tr>
<td>Range</td>
<td>4-2,000 m (standard range; reach depends on target and environment)</td>
</tr>
<tr>
<td>Accuracy</td>
<td>±1 m to 400 m; 0.4 % of distance beyond</td>
</tr>
<tr>
<td>Rate</td>
<td>2-10 Hz, adaptive</td>
</tr>
<tr>
<td>Interface</td>
<td>UART-TTL, 115200 bps, 3.3-5 V supply</td>
</tr>
<tr>
<td>Beam divergence</td>
<td>below 6 mrad (published upper bound)</td>
</tr>
</tbody></table>
<p>For ROS this means three things. The message needs <code>min_range</code> of 4 m and <code>max_range</code> of 2,000 m. <code>field_of_view</code> should be the beam divergence, 0.006 rad, because the beam is a narrow cone, not the wide field of view of an ultrasonic sensor. And the publish rate is at most 10 Hz, so do not wire the topic into a high-rate control loop.</p>
<h2>Route 1: the existing package</h2>
<p>The <a href="https://github.com/Tommyapi/erdi_lrf_ros2">erdi_lrf_ros2</a> package supports both published ERDI serial protocol families and publishes <code>Range</code> with sensor-data QoS. Its only runtime dependency is <code>pyserial</code>.</p>
<pre><code class="language-bash">cd ~/ros2_ws/src
git clone https://github.com/Tommyapi/erdi_lrf_ros2.git
cd ~/ros2_ws
rosdep install --from-paths src --ignore-src -y
colcon build --packages-select erdi_lrf_ros2
source install/setup.bash
sudo usermod -aG dialout $USER     # log out and in once

ros2 launch erdi_lrf_ros2 erdi_lrf.launch.py port:=/dev/ttyUSB0 model:=LR2000E2 rate:=5.0
ros2 topic echo /range
</code></pre>
<p>The <code>model</code> parameter picks the protocol, baud rate and units, because they differ between families. Do not copy a divisor between models. If you need worked launch files, an RViz2 <code>Range</code> display, a median and slew-rate filter node and a two-sensor namespace setup, see <a href="https://github.com/Tommyapi/erdi-lrf-ros2-examples">erdi-lrf-ros2-examples</a>. Its README states that the nodes have not been run in a ROS 2 environment by the maintainers, so treat it as a starting point and bench-test.</p>
<h2>Route 2: a minimal node you can read</h2>
<p>The LR-series protocol is small: an 8-byte request <code>55 AA &lt;function&gt; D1 D2 D3 D4 &lt;checksum&gt;</code> and an 8-byte reply <code>55 AA &lt;function&gt; STA FF DIS_H DIS_L &lt;checksum&gt;</code>. Single-shot ranging is <code>55 AA 88 FF FF FF FF 84</code>. <code>STA = 1</code> means success, and the distance is <code>(DIS_H * 256 + DIS_L) / 10</code> metres. That is all you need.</p>
<pre><code class="language-python">import math, time
import rclpy, serial
from rclpy.node import Node
from rclpy.qos import qos_profile_sensor_data
from sensor_msgs.msg import Range

HEADER = b"\x55\xAA"
CMD_SINGLE = bytes.fromhex("55AA88FFFFFFFF84")

def parse(frame):
    if len(frame) != 8 or frame[:2] != HEADER or frame[3] != 1:
        return None                      # failed or malformed reply
    return ((frame[5] &lt;&lt; 8) | frame[6]) / 10.0

def to_range_value(m, lo, hi):           # REP-117 conventions
    if m is None: return math.nan        # invalid measurement
    if m &lt; lo:    return -math.inf       # closer than min_range
    if m &gt; hi:    return math.inf        # beyond max_range
    return m

class LrfNode(Node):
    def __init__(self):
        super().__init__("erdi_lrf")
        self.declare_parameter("port", "/dev/ttyUSB0")
        self.declare_parameter("rate", 5.0)
        self.ser = serial.Serial(self.get_parameter("port").value, 115200, timeout=0.3)
        self.pub = self.create_publisher(Range, "range", qos_profile_sensor_data)
        self.create_timer(1.0 / self.get_parameter("rate").value, self.tick)

    def read_frame(self):
        deadline, buf = time.time() + 0.5, b""
        while time.time() &lt; deadline:
            b = self.ser.read(1)
            if not b: continue
            buf = (buf + b)[-2:]
            if buf == HEADER:
                rest = self.ser.read(6)
                return HEADER + rest if len(rest) == 6 else b""
        return b""

    def tick(self):
        self.ser.reset_input_buffer()
        self.ser.write(CMD_SINGLE)
        m = parse(self.read_frame())
        msg = Range()
        msg.header.stamp = self.get_clock().now().to_msg()
        msg.header.frame_id = "lrf_link"
        msg.radiation_type = Range.INFRARED
        msg.field_of_view = 0.006
        msg.min_range, msg.max_range = 4.0, 2000.0
        msg.range = to_range_value(m, msg.min_range, msg.max_range)
        self.pub.publish(msg)

def main():
    rclpy.init(); n = LrfNode()
    try: rclpy.spin(n)
    finally: n.destroy_node(); rclpy.shutdown()

if __name__ == "__main__": main()
</code></pre>
<p>I ran the parse and REP-117 mapping functions on the bench against the manual's example frame: <code>55 AA 88 01 FF 00 64 00</code> decodes to 10.0 m, a reply with <code>STA = 0</code> decodes to a failed reading, and 2.0 m, 2,500 m and a failed reading map to <code>-inf</code>, <code>+inf</code> and <code>nan</code>. I did not run the ROS 2 wrapper itself in this write-up, so launch it on your own robot with a known-distance wall first.</p>
<h2>Why REP-117 matters here</h2>
<p>REP-117 says what a <code>Range</code> message should contain when there is no valid distance: <code>-inf</code> when the object is closer than <code>min_range</code>, <code>+inf</code> when nothing is detected within <code>max_range</code>, and <code>nan</code> for an invalid measurement. A long-range module at 400-2,000 m has a published valid-measurement rate of 80 % or better, so about one reading in five can fail at long range. If your node publishes <code>0.0</code> or the last value on failure, a costmap or a filter downstream will treat it as an obstacle at the sensor. Publish <code>nan</code> and let consumers decide.</p>
<h2>Frame, TF and rate</h2>
<ul>
<li>Define a TF frame for the sensor (<code>lrf_link</code>) and put the sensor frame's x-axis along the beam, as <code>Range</code> expects. A static transform from <code>base_link</code> is enough.</li>
<li>Keep the timer at or below the module's rate. Polling at 20 Hz a module that produces 5-10 Hz just yields timeouts.</li>
<li>If you subscribe from Python or C++, use the sensor-data QoS profile (best effort) to match the publisher.</li>
<li>For obstacle avoidance at metres per second, use a fast short-range sensor (the VB series reads at 50-200 Hz) and keep the long-range module for distance-to-structure tasks.</li>
</ul>
<h2>Getting to a flight controller</h2>
<p>Publishing <code>Range</code> does not make a module an ArduPilot or PX4 rangefinder. For that, forward the distance as a MAVLink <code>DISTANCE_SENSOR</code> message from a companion computer; see <a href="https://github.com/Tommyapi/erdi-lrf-pixhawk-ardupilot">erdi-lrf-pixhawk-ardupilot</a>.</p>
<h2>Buying and datasheets</h2>
<p>Each module's manual, parameter table and price are on its page: <a href="https://erdilrf.com/models/">https://erdilrf.com/models/</a>. The 1-2 km pages are <a href="https://erdilrf.com/lrf/1km-laser-rangefinder-module/">https://erdilrf.com/lrf/1km-laser-rangefinder-module/</a> and <a href="https://erdilrf.com/lrf/2km-laser-rangefinder-module/">https://erdilrf.com/lrf/2km-laser-rangefinder-module/</a>.</p>
<p><em>Data checked 2026-11-07. Tommy Yu, ERDI TECH LTD, erdilrf.com</em></p>
]]></content:encoded></item><item><title><![CDATA[ESP32 + a 1.5 km laser rangefinder module: serial reader and MQTT publisher (LR1500E2)]]></title><description><![CDATA[If you want a distance sensor that reaches past 1 km and talks to a microcontroller over a plain UART, a bare laser rangefinder module is the right class…]]></description><link>https://erdi-lrf-notes.hashnode.dev/esp32-a-1-5-km-laser-rangefinder-module-serial-reader-and-mqtt-publisher-lr1500e2</link><guid isPermaLink="true">https://erdi-lrf-notes.hashnode.dev/esp32-a-1-5-km-laser-rangefinder-module-serial-reader-and-mqtt-publisher-lr1500e2</guid><category><![CDATA[esp32iot]]></category><category><![CDATA[arduino]]></category><category><![CDATA[embedded]]></category><dc:creator><![CDATA[Tommy Yu]]></dc:creator><pubDate>Fri, 06 Nov 2026 02:28:34 GMT</pubDate><content:encoded><![CDATA[<p>If you want a distance sensor that reaches past 1 km and talks to a microcontroller over a plain UART, a bare laser rangefinder module is the right class of part. This post shows a complete ESP32 sketch for the ERDI LR1500E2, a 905 nm module with a published range of 4 to 1,500 m, that reads the sensor, rejects bad frames, and publishes the distance to an MQTT broker.</p>
<p>Specs and protocol details are from the LR1500E2 manual and the product page (<a href="https://erdilrf.com/models/lr1500e2/">https://erdilrf.com/models/lr1500e2/</a>), checked on 2026-11-06.</p>
<h2>The module in numbers</h2>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
</tr>
</thead>
<tbody><tr>
<td>Wavelength</td>
<td>905 ± 5 nm</td>
</tr>
<tr>
<td>Range</td>
<td>4–1,500 m (the manual also lists a 1,800 m maximum at night)</td>
</tr>
<tr>
<td>Rate</td>
<td>2–10 Hz, adaptive</td>
</tr>
<tr>
<td>Interface</td>
<td>UART-TTL, 115200 bps, 8 bits</td>
</tr>
<tr>
<td>Supply</td>
<td>3.3–5 V</td>
</tr>
<tr>
<td>Power</td>
<td>about 1 W operating, about 0.4 W at short range, about 0.2 W standby, under 1 mW sleep</td>
</tr>
<tr>
<td>Start-up</td>
<td>200 ms or less</td>
</tr>
<tr>
<td>Size / weight</td>
<td>25.65 × 13.2 × 24.6 mm, 10 g or less</td>
</tr>
<tr>
<td>Laser</td>
<td>Class 1 (manufacturer statement), divergence under 6 mrad</td>
</tr>
<tr>
<td>Operating temperature</td>
<td>−20 to +55 °C</td>
</tr>
<tr>
<td>Price</td>
<td>USD 100 per unit for 1–30 pieces, shipping included</td>
</tr>
</tbody></table>
<p>One thing to read carefully: the accuracy table in the archived factory pack and the current public manual differ on where the second accuracy interval ends. Both give ±1 m from 6 m to 500 m and ±(0.5 m + 0.001 × distance) beyond; one revision stops that interval at 1,000 m, the other runs it to 1,500 m. Confirm which revision shipped with your unit.</p>
<h2>Wiring to an ESP32</h2>
<p>Use a hardware UART, not software serial. On a classic ESP32 dev board, UART2 defaults to GPIO16 (RX) and GPIO17 (TX).</p>
<table>
<thead>
<tr>
<th>Module pin</th>
<th>Connect to</th>
</tr>
</thead>
<tbody><tr>
<td>GND</td>
<td>GND</td>
</tr>
<tr>
<td>VCC</td>
<td>5 V pin of the board, or a separate 3.3–5 V supply</td>
</tr>
<tr>
<td>TXD</td>
<td>GPIO16 (ESP32 RX2)</td>
</tr>
<tr>
<td>RXD</td>
<td>GPIO17 (ESP32 TX2)</td>
</tr>
<tr>
<td>SW-SHOT (enable)</td>
<td>as the manual specifies; active high</td>
</tr>
</tbody></table>
<p>Two cautions. The ESP32 is a 3.3 V device and its pins are not 5 V tolerant. The manual gives the module's supply range but does not separately state the TXD/RXD logic level, so confirm the output swing with a meter before connecting TXD to the ESP32 if you power the module from 5 V. Second, the module's start-up inrush is below 400 mA in the LR2000E2 manual; give the module a supply that does not share a weak regulator with the Wi-Fi radio, whose transmit bursts can pull the rail down and cause resets that look like sensor faults.</p>
<h2>The frame</h2>
<p>Commands and replies are 8 bytes starting <code>55 AA</code>.</p>
<ul>
<li>Single-shot: <code>55 AA 88 FF FF FF FF 84</code></li>
<li>Continuous: <code>55 AA 89 FF FF FF FF 85</code></li>
<li>Stop: <code>55 AA 8E FF FF FF FF 8A</code></li>
</ul>
<p>Reply: <code>55 AA 88 STA FF DIS_H DIS_L SUM</code>. <code>STA = 1</code> means success. Distance in metres is <code>((DIS_H &lt;&lt; 8) | DIS_L) / 10</code>, because results are output as the actual value × 10.</p>
<h2>The sketch</h2>
<pre><code class="language-cpp">#include &lt;WiFi.h&gt;
#include &lt;PubSubClient.h&gt;

const char* WIFI_SSID = "your-ssid";
const char* WIFI_PASS = "your-pass";
const char* MQTT_HOST = "192.168.1.10";
const char* TOPIC     = "site/lrf/distance_m";

HardwareSerial LRF(2);                       // UART2: RX=16, TX=17
WiFiClient wifi;
PubSubClient mqtt(wifi);

static const uint8_t CMD_SINGLE[8] = {0x55,0xAA,0x88,0xFF,0xFF,0xFF,0xFF,0x84};

// Read one 8-byte frame, resynchronising on the 55 AA header.
bool readFrame(uint8_t *f, uint32_t timeoutMs) {
  uint32_t t0 = millis();
  uint8_t prev = 0;
  while (millis() - t0 &lt; timeoutMs) {
    if (!LRF.available()) { delay(1); continue; }
    uint8_t b = LRF.read();
    if (prev == 0x55 &amp;&amp; b == 0xAA) {
      f[0] = 0x55; f[1] = 0xAA;
      size_t n = LRF.readBytes(f + 2, 6);    // honours Serial timeout
      return n == 6;
    }
    prev = b;
  }
  return false;
}

// Returns true and fills metres on a valid reading.
bool measure(float &amp;metres) {
  while (LRF.available()) LRF.read();        // drop stale bytes
  LRF.write(CMD_SINGLE, 8);
  uint8_t f[8];
  if (!readFrame(f, 1500)) return false;
  if (f[3] != 1) return false;               // STA != 1 -&gt; failed measurement
  uint16_t raw = ((uint16_t)f[5] &lt;&lt; 8) | f[6];
  metres = raw / 10.0f;
  return true;
}

void connectNet() {
  if (WiFi.status() != WL_CONNECTED) {
    WiFi.begin(WIFI_SSID, WIFI_PASS);
    uint32_t t0 = millis();
    while (WiFi.status() != WL_CONNECTED &amp;&amp; millis() - t0 &lt; 15000) delay(250);
  }
  if (WiFi.status() == WL_CONNECTED &amp;&amp; !mqtt.connected()) {
    mqtt.connect("lrf-esp32");
  }
}

void setup() {
  Serial.begin(115200);
  LRF.begin(115200, SERIAL_8N1, 16, 17);
  LRF.setTimeout(200);
  mqtt.setServer(MQTT_HOST, 1883);
}

void loop() {
  connectNet();
  float m;
  if (measure(m)) {
    Serial.printf("%.1f m\n", m);
    char msg[16];
    snprintf(msg, sizeof(msg), "%.1f", m);
    if (mqtt.connected()) mqtt.publish(TOPIC, msg);
  } else {
    Serial.println("no valid echo");
    if (mqtt.connected()) mqtt.publish("site/lrf/status", "no_echo");
  }
  mqtt.loop();
  delay(500);                                 // module rate is 2-10 Hz adaptive
}
</code></pre>
<h3>Why it is written this way</h3>
<p><strong>Resync on the header.</strong> Reading exactly 8 bytes after every command is fine until a byte is dropped or a late reply from the previous command arrives. Hunting for <code>55 AA</code> and then reading six more bytes makes the reader self-healing. Clearing the input buffer before each command removes stale replies.</p>
<p><strong>A failed reading is not an error.</strong> At long range the module legitimately fails some fraction of the time, and the manufacturer's accuracy-rate figure is 98 % or better. Publishing a <code>no_echo</code> status instead of the last distance keeps downstream dashboards honest. If you prefer to hold the last good value, add a timestamp and a staleness limit.</p>
<p><strong>The delay matches the rate.</strong> The module's measurement rate is adaptive between 2 and 10 Hz. Calling single-shot twice a second is well inside that. If you need faster updates, switch to continuous ranging (<code>55 AA 89 FF FF FF FF 85</code>) and parse the stream, but keep the resync logic.</p>
<p><strong>Power management.</strong> The manual lists sleep power under 1 mW and about 0.2 W standby. For battery nodes, the sensible pattern is wake, wait out the 200 ms start-up, take a handful of readings, take the median, publish, sleep. Confirm in the manual how the enable and sleep states are entered before you wire a GPIO to the enable line.</p>
<h2>Making the reading trustworthy</h2>
<p>A distance number from a 1.5 km module is only useful if you know what it was aimed at. Three habits help.</p>
<ol>
<li><strong>Log reflectivity context.</strong> Note the target type (building, rock, vegetation) in your metadata. The same module reads further on a white wall than on dark foliage.</li>
<li><strong>Use the median of five.</strong> A single reading can be a stray return from a branch or a wire. Five readings with a median costs about a second and removes outliers.</li>
<li><strong>Bench-check against a tape.</strong> Measure a wall at 10 m and 50 m once. Compare mean and spread to the manual's ±1 m band. If you see an offset, record it and apply a calibration constant rather than hoping.</li>
</ol>
<h2>Using the published drivers instead</h2>
<p>An open-source driver set for the ERDI 905 nm modules (Python, Arduino and ROS 2) is at <a href="https://github.com/ErdiTech/erdi-lrf-drivers">https://github.com/ErdiTech/erdi-lrf-drivers</a>, with every constant cited to the model manual. If you are not on this exact module, use the driver for your model rather than editing the constants here, because the unit and frame layout are per model.</p>
<h2>FAQ</h2>
<p><strong>What range does the LR1500E2 have?</strong> 4 to 1,500 m standard range, with a 1,800 m maximum at night listed in the manual. Accuracy is ±1 m from 6 to 500 m.</p>
<p><strong>What is the baud rate and unit?</strong> 115200 bps, 8 data bits; results are the real distance times 10, so divide by 10.</p>
<p><strong>Does it work with 3.3 V microcontrollers?</strong> The supply range is 3.3–5 V. The signal-pin logic level is not separately stated in the manual, so check it before connecting to 3.3 V-only pins.</p>
<p><strong>How much does it cost?</strong> USD 100 per unit for 1 to 30 pieces, shipping included, on 2026-11-06; volume tiers go down to USD 40 at 501 pieces and above.</p>
<p><em>Tommy Yu, ERDI TECH LTD, erdilrf.com</em></p>
]]></content:encoded></item></channel></rss>