Pluto Logo

by Drona Aviation

Profile
Menu
All Projects
X-Ranging
ADD-ON MODULE

X-Ranging

SENSORIntermediate
X2_XRANG

Time-of-Flight (ToF) distance sensor module used for precise distance measurement. Uses laser-based ranging to measure distances with millimeter accuracy, enabling precise altitude hold and obstacle distance measurement.

DIFFICULTYIntermediate
PORTI2C
SIGNALI2C (ToF)

WHAT YOU'LL LEARN

  • Understanding Time-of-Flight distance sensing
  • I2C sensor data reading
  • Precise distance measurement techniques
  • Altitude-aware flight control

DOWNLOADS

PlutoBlocks Code
Coming Soon
HEX Firmware File
GitHub Latest.hex
1

The Challenge

✨

Build a program that uses the ToF sensor for precise distance measurement and altitude-aware drone control.

2

Understanding the Add-On

The X-Ranging module is a Time-of-Flight (ToF) distance sensor that uses laser-based ranging to measure distances with millimeter accuracy. Unlike ultrasonic sensors that use sound waves, ToF sensors emit infrared laser pulses and measure the time it takes for the reflected light to return. This enables highly precise distance measurements, making it ideal for altitude hold, obstacle detection, and terrain following applications.

3

Wiring & Connections

Connect the X-Ranging to the I2C port on the Primus V5/X2 board. The X-Ranging sensor communicates via I2C. Ensure the connector is firmly seated and the sensor lens is unobstructed for accurate readings.

Primus V5/X2 PinPeripheral
GND on I2C portGND on X-Ranging module
VCC on I2C portVCC on X-Ranging module
SDA on I2C portSDA on X-Ranging module
SCL on I2C portSCL on X-Ranging module
4

How It Works

Approach The ToF sensor is initialized over I2C and configured for continuous ranging mode. Distance readings are polled each loop cycle and can be used to control altitude or trigger actions based on proximity thresholds. Code Logic Explained On Start: The I2C bus is initialized and the ToF sensor is configured with its default I2C address. The sensor is set to continuous ranging mode for real-time measurements.Pluto Loop: On each cycle, the sensor is polled for the latest distance reading in millimeters. This value can be used for altitude-based control logic, such as maintaining a set height or triggering actions when an object is within a certain range.On Stop: The sensor is placed in standby mode and I2C communication is properly terminated.

5

Real-World Applications

Precise altitude holding Distance-based obstacle avoidance Terrain mapping and following

6

Try Further

Ready for the next challenge? Try these extensions to deepen your understanding. 1Create a terrain-following drone that maintains constant height above ground. 2Build a precise landing system using ToF for touchdown detection. 3Combine with IR sensor for multi-directional obstacle awareness. Pluto Drone Add-On Projects — Compatible with Pluto 1.2 (Primus V5) & Pluto X (Primus X2) — Drona Aviation

7

PlutoBlocks Code

✨

PlutoBlocks code for this module is coming soon. Stay tuned for updates!

8

PlutoIDE Code (C++)

✨

PlutoIDE C++ code for this module is coming soon. Stay tuned for updates!

9

Real-World Applications

XRanging.init
XRanging.getRange
RcCommand_Set
RcData_Get
Monitor_Println
Set_LED
Receiver_Mode
Precise altitude holding
Distance-based obstacle avoidance
Terrain mapping and following
10

Try Further

Ready for the next challenge? Try these extensions to deepen your understanding.

1
Create a terrain-following drone that maintains constant height above ground.
2
Build a precise landing system using ToF for touchdown detection.
3
Combine with IR sensor for multi-directional obstacle awareness.