TOF Distance Sensor Tool

GitHub ↗
This browser can't access serial ports. The tool uses the Web Serial API, available in Chrome, Edge and Opera on desktop. Please open this page in one of those browsers (it also requires HTTPS, which this site already uses).

Live measurement read-only registers 00–07

---
distance, mm  (register 01)
Distance cm
---
Signal rate
---
Ambient rate
---
Sigma (mm)
---
SPAD count
---
Detection output
---
Ranging status  (register 00)
Update rate = how often this tool requests values over serial. It is not the sensor's measurement speed — that is set by Sampling time (register B0) — and the serial baud rate limits how fast requests can go.

Configuration registers 80–BD

Validity checks (register B4)
* I/O mode takes effect after sensor restart.
Write applies the values immediately, but they are lost after a restart or power-off — press Save to memory to keep them permanently.

Serial log

Entering serial mode

If the sensor is in Digital or PWM mode:
  1. Disconnect the sensor power supply.
  2. Short the SIG pin to GND.
  3. Reconnect power and wait at least 50 ms.
  4. Remove the short from SIG.
The sensor is now in serial mode at 9600 baud with ID 00. After a restart it returns to the mode saved in its registers.

Wiring (half-duplex UART)

USB-UART TX RX GND TOF sensor SIG VIN GND VCC 2.8–5.5 V (power supply +) TX + RX tied together 2.4k–10k pull-up common ground (adapter, sensor and power supply) No response back? See "Not working?" — a small series resistor in the TX wire can help.
  1. Tie the USB-UART adapter's RX and TX together, connect to SIG.
  2. Add a 2.4k–10k pull-up from SIG to the supply voltage (≥ 2.8 V).
  3. Connect VIN (2.8–5.5 V) and GND.

What the settings do

I/O mode reg 80
What the SIG pin outputs: Serial (this tool), Digital 0/1 (detection state, LOW/HIGH), or PWM (servo-style 20 ms period, 1–2 ms pulse mapped between min and max distance; an invalid measurement gives 2 ms). Applied only after a restart.
Serial ID reg 81
The address this sensor answers to in serial mode — lets several sensors share one line.
Serial baud rate reg 82
Speed of serial communication, 9600–250000. Higher = faster live readings, but needs a stronger (lower value) pull-up resistor. Applied after restart — reconnect with the new host baud.
Sampling time reg B0
How long one measurement takes, 5–50 ms. Shorter = faster and noisier readings; below 10 ms operation is not guaranteed. Full 1200 mm range needs 50 ms.
Validity checks reg B4
Which internal checks a measurement must pass to count as valid: wraparound and phase (optical sanity checks), signal minimum/threshold (enough light returned), sigma (noise below limit), and distance min/max (inside the window set below). All checks always run and show in the Ranging status panel; only the enabled ones affect validity.
Signal threshold reg B5
Minimum returned photon count for a valid distance — raise it to reject weak, unreliable echoes.
Sigma threshold reg B6
Maximum allowed standard deviation (noise) in mm — lower it to reject jittery measurements.
Min / Max distance reg B7 / B8
Valid distance window in mm. Used only when the corresponding distance checks are enabled above.
Detection mode reg BA
What the detection output means: 0 = measurement is valid, 1 = distance above the lower threshold, 2 = distance between the lower and upper thresholds.
Detection output reg BB
Normal or inverted logic for the detection output (also drives the SIG pin in Digital mode).
Detection thresholds reg BC / BD
Lower and upper distance limits in mm used by detection modes 1 and 2.

Troubleshooting

1. No response to any command
Make sure the sensor is actually in serial mode (see "How to enter serial mode?") — after entering it, the sensor answers at 9600 baud with ID 00 until restarted. Check the host baud rate and Sensor ID at the top match that.
2. Test the adapter alone (loopback)
Disconnect the sensor, jumper the adapter's TX directly to RX, connect and press Line test. It should report all echoes intact. If nothing comes back, the problem is the adapter, its driver, or the selected port — not the sensor or wiring.
3. Commands echo back but the sensor never answers
Turn on show echoes in the Serial log. If you see your own commands as echoes but no reply line after them: the sensor is not in serial mode, the ID is wrong, or the adapter's push-pull TX is overpowering the sensor's open-drain output. In that case put a 1k–2.2k resistor in the TX wire (RX stays directly on SIG) so the sensor can pull the line low.
4. Garbage / corrupted characters
Usually a missing or too-weak pull-up (use 2.4k–10k to ≥ 2.8 V), a baud rate mismatch, or a missing common ground between adapter, sensor and power supply.
5. It worked, then stopped after a restart
On restart the sensor loads its saved configuration: it may have returned to Digital/PWM mode, a different baud rate, or a different ID. Re-enter serial mode, or reconnect using the saved baud/ID.
6. Live view shows "invalid"
That is the sensor talking fine but rejecting the measurement — check the Ranging status panel to see which validity check fails, and loosen it in the configuration (e.g. Max distance, default 500 mm, or Signal threshold).