Skip to main content
Explore ERDILRF

Press ↑↓ to move, Enter to open, Esc to close.

RP2040 UART: Reading an ERDI Rangefinder Module

An RP2040 can receive a rangefinder’s UART stream only after the delivered module’s signal levels, pin orientation and serial format are confirmed. Connect the module TX to the board RX and share a reference ground, but do not energize the signal connection while its electrical limits are unknown. Then drain received bytes independently of display or logging, parse complete model-specific frames, and treat invalid readings and missing reports as different events. This is a bring-up plan, not a claim that any particular board and module have already been tested together.

Start with the electrical contract

The LRF50H record specifies a 9–36 V DC module supply, not a UART signal voltage. Its signal-level specification is absent from the cited source. The record identifies module TX and RX, but the delivery harness and pin orientation still need checking. A supply suitable for the module must not be connected to an RP2040 signal input.

The SPD1200N2 record lists a 3.3–5 V supply and UART-TTL communication; those entries do not establish a numerical TX output swing or RX input limits. Confirm the six-pin ordering, harness and pin-one viewing direction for the delivered revision with ERDI before wiring; do not infer pin order by mirroring a drawing.

For either module, check the actual RP2040 board’s power rails, pin mapping, input limits and chosen UART functions against its board documentation. A translator is appropriate only when its input and output limits and power sequencing match both endpoints. If those limits have not been established, neither direct wiring nor an arbitrary translator is a confirmed solution. Leave the data wires disconnected until the contract is clear.

Powered-off wiring checklist

  1. Identify the exact module, harness, board revision and intended receive pin. Obtain the delivered unit’s approved pin view and signal-voltage limits.
  2. Choose a separate module supply within its documented range, with capacity and protection appropriate to the installation. Keep the module supply separate from logic-level assumptions.
  3. With power removed, identify the shared signal ground. Route module TX to the board’s selected UART RX through any confirmed translation circuit. Connect board TX to module RX only when commands are required and that direction is also electrically confirmed.
  4. Check for accidental supply-to-signal connections, unintended power paths and loose conductors. Confirm any enable signal and its polarity for the delivered unit rather than guessing.
  5. After approval, power the system and inspect the serial signal with suitable equipment before relying on decoded data. Record the setup and use the correct probe reference.

Configure the receiver for the selected model

For LRF50H, the current record gives 460800 baud, eight data bits, no parity and 1 stop bit; the baud rate is adjustable. Its default output description is a four-byte frame at a stated default frequency of 1 kHz. Confirm the actual delivered configuration before setting the RP2040 UART. Assign an eligible board pin to the selected hardware UART, set the confirmed format, and start reception before enabling any operation that produces a stream.

SPD1200N2 is a different protocol: the record states a default of 115200 bps, eight data bits and an eight-byte frame. Confirm parity, stop bits, command behavior and the delivered settings before configuring the host; the available product record does not establish all those choices. Its recorded adaptive frequency has an unresolved lower-bound discrepancy: the source states 2–15 Hz or 4–15 Hz. Do not select one lower bound as a settled specification.

The UART module overview is a useful starting point for comparing interfaces, but a category label cannot replace the delivered unit’s pin, voltage and protocol information. Keep the two model parsers separate even when both use a UART.

Parse a byte stream, not read-call boundaries

A UART read can return part of a frame, one frame, or several frames together. Put received bytes into a bounded queue and let a parser retain incomplete candidates between reads. For LRF50H, the source describes a four-byte default frame beginning with 5C, followed by two little-endian distance bytes and a check byte. Its example distance bytes 02 11 represent 4354 cm. That is a documented format example, not a live measurement.

The record describes the check byte as the opposite of the check byte over the two distance bytes, but that wording alone should not be promoted into an unverified executable checksum rule. Obtain an unambiguous definition and known-good frames for the delivered firmware before accepting frames as validated. Reject a candidate that fails the confirmed check, advance through the buffered stream to seek another possible header, and retain enough trailing bytes to complete a split frame. Since a header byte can also occur inside data, a matching header alone is not proof of alignment.

SPD1200N2 instead uses a two-byte 55 AA header and eight-byte frames. Its record distinguishes request and reply checksum scopes. Do not apply the LRF50H decoder or reuse one checksum scope in both directions. Confirm the complete reply layout, status interpretation and physical unit for the delivered protocol before converting a field into a distance. The record says the returned value is the actual result multiplied by ten, but that statement alone does not establish the underlying unit.

Separate missing, malformed and invalid results

For LRF50H, the source describes 65535 cm as an out-of-range output. Classify that code before conversion or averaging: it is not a usable distance. Keep a valid out-of-range report separate from a malformed candidate, a UART overrun and a period in which no complete report arrives. For SPD1200N2, use only status and invalid-value rules confirmed for the delivered mode; do not borrow the LRF50H sentinel.

A gap alarm is evidence that an expected report did not arrive within a chosen interval, not proof of exactly how many frames were lost. Without a confirmed sequence counter or a known count of request opportunities, a clean-looking stream cannot prove that no whole frames disappeared. When single requests and replies can be reliably associated, retain one outcome per request, including timeout; do not count only successful replies. For an adaptive or unconfirmed cadence, set a provisional timeout from observed traffic and the application’s needs, and record that it is a host rule rather than a module guarantee.

Acceptance record for the RP2040 receive path

  • Record firmware, UART instance and pin, confirmed electrical levels, baud and framing, plus the source and revision used for each setting.
  • Capture raw bytes and timestamps alongside counts of received bytes, accepted frames, invalid readings, check failures, UART errors and buffer overruns. Preserve the original capture when investigating.
  • Feed the parser known-good and deliberately split byte sequences, concatenated frames and a damaged candidate. These are synthetic parser checks, not claims about hardware performance.
  • Under the intended workload, observe the longest receive-service pause and queue occupancy. Exercise logging and display separately so a slow consumer is visible rather than silently blocking reception.
  • Power-cycle or reconnect on the bench and check that the parser returns to alignment. Define in advance how the application marks stale data and what action follows an overrun or timeout.

These checks can reveal loss and recovery problems; they do not guarantee loss-free operation in every installation. If the delivered electrical or protocol contract is incomplete, contact ERDILRF with the model, board, harness details and the exact missing field before connecting the interface.

FAQ

3.3 V or 5 V logic?

Do not infer either signal level from the supply rating. The LRF50H record does not specify a numerical UART level, and the SPD1200N2 supply range does not establish its TX and RX limits. Confirm the delivered module and board limits.

Do I need a level shifter?

Only an electrical comparison can answer that. If the endpoints are incompatible, select a translator whose limits and sequencing fit both directions; if module limits are unknown, obtain them before deciding or connecting.

How do I detect a missed frame?

Count UART overruns, failed candidates and expected-report timeouts. A sequence counter or reliably associated requests can support stronger loss accounting when the delivered protocol provides them. A timeout alone cannot establish an exact missing-frame count.

Models mentioned in this article