Skip to content

Time of Flight Distance Sensor Wireling Tutorial

TinyCircuits Time-of-Flight Wireling product photo

This Wireling features a VL53L0X Infrared Time-of-Flight sensor, most often used for distance detection between 2cm and 2m!

Technical Details

VL53L0X Time-of-Flight Sensor Specs

  • Fully integrated miniature module
    • 940 nm laser VCSEL
    • VCSEL driver
    • Ranging sensor with advanced embedded micro controller
  • Fast, accurate distance ranging
    • Measures absolute range up to 2m
    • Reported range is independent of the target reflectance
    • Advanced embedded optical cross-talk compensation to simplify cover glass selection
  • Eye safe
  • I²C
    • Compatible with 400 kHz (FAST mode)
    • Address: 0x52

TinyDuino Power Requirements

  • Voltage: 3.0V - 5.5V 
  • Current:
    • Hardware Standby: 5uA
    • Software Standby: 6uA
    • Timed Ranging Inter Measurement: 16uA
    • Active Ranging Average Consumption: 19mA

Pins Used

  • A5/SCL - I²C Serial Clock line
  • A4/SDA - I²C Serial Data line


  • 10mm x 10mm (.393 inches x .393 inches)
  • Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 3.70mm (0.15 inches)
  • Weight: 1 gram (.04 ounces)


To interface with any TinyCircuits Arduino board, you will need the Arduino IDE and a Micro USB Cable

There are multiple processor/adapter combinations that can be used with Wirelings. Use the following table to find the combination that works for you.

Processor Adapter
*TinyDuino and USB TinyShield Wireling Adapter TinyShield
*TinyZero Wireling Adapter TinyShield
*TinyScreen+ Wireling Adapter TinyShield
WirelingZero N/A
*RobotZero N/A
Arduino Wireling Arduino Shield
Raspberry Pi Wireling Pi Hat

* These processors have a 32-pin connector and can have multiple Wireling Adapter TinyShields stacked to increase the number of Wireling ports up to a maximum of 32 total Wireling ports.

In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE).

You will also need the Time of Flight Wireling and the included example Arduino sketch.

Wireling Code
Port 0 Time of Flight Example Sketch

Hardware Assembly

Depending on the development system you choose, you will need to put together a TinyDuino stack using the 32-pin tan connectors, or you will just need to plug in your Wireling to Port 0 using a Wireling Cable. (You can change this port in the included Arduino Sketch using the selectPort() function)

NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.

Software Setup

The library needed for the Time-of-Flight Sensor is included in the Arduino sketch zip file included under Materials. Download the zipped folder and open the sketch in the Arduino IDE.

Make the correct Tools selections for your development board. If unsure, you can double check this help page that mentions the Tools selections needed for any TinyCircuits processor.

Upload Program

The VL53L0X is very accurate up to 2m. Past 2m, results will not be accurate to the mm, but will maintain high accuracy.

 * Time of Flight Distance Sensor Wireling Example
 * This example shows how to use continuous mode to take, and print
 * range measurements with the VL53L0X Wireling. It is based on
 * vl53l0x_ContinuousRanging_Example.c from the VL53L0X API.
 * The range readings are in units of mm.
 * Hardware by: TinyCircuits
 * Modified by: Laveréna Wienclaw for TinyCircuits 
 * Last Modified: 12/18/19

#include <Wire.h>       // For I2C communication
#include "VL53L0X.h"    // For interfacing with the Time-of-Flight Distance sensor
#include <Wireling.h>   // For interfacing with Wirelings

VL53L0X distanceSensor; // Name of sensor 
const int tofPort = 0;  // Port # of sensor (Found on Wireling Adapter Board)

const int averageCount = 1;
int average[averageCount];
int averagePos = 0;

#if defined(ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB

void setup() {
  delay(200);              // Sensor Startup time
  SerialMonitorInterface.begin(115200); // Set Baud Rate
  Wire.begin();            // Begin I2C communication

  // Enable power & select port
  // Select the port of the distance sensor (this number corresponds 
  // with port #'s on the Wireling adapter board)

  // Initialize the distance sensor and set a timeout

  // Start continuous back-to-back mode (take readings as
  // fast as possible).  To use continuous timed mode
  // instead, provide a desired inter-measurement period in
  // ms (e.g. sensor.startContinuous(100))

void loop() {
  // Calculate the average position of the distance sensor
  unsigned long averageRead = 0;
  average[averagePos] = distanceSensor.readRangeContinuousMillimeters();
  if (averagePos >= averageCount)averagePos = 0;
  for (int i = 0; i < averageCount; i++) {
    averageRead += (unsigned long)average[i];
  averageRead /= (unsigned long)averageCount;

  // Print the average position to the TinyScreen and the Serial Monitor

Time-of-Flight Distance Wireling serial output

Results will print out in mm, open up the Serial Monitor to see the values. Ranges max out at 8190mm - this can be seen when pointing the distance sensor toward something far away.


Contact Us

If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

Thanks for making with us!