Project Overview
Arduino Uno + VL53L0X + SSD1306 OLED: In this tutorial, you will use an Arduino Uno with a VL53L0X time-of-flight distance sensor and an SSD1306 OLED display to measure distance and show live millimeter readings on the screen.
The VL53L0X uses infrared laser time-of-flight technology to measure distances up to 2 meters with millimeter precision.
- Time: 30 minutes to 1 hour
- Skill level: Beginner
- What you will build: A real-time distance measuring device that displays measurements in millimeters on a small OLED screen.
Parts List
From ShillehTek
- VL53L0X Pre-Soldered Laser Ranging ToF Sensor Module - the time-of-flight distance sensor (up to 2 meters)
-
SSD1306 0.96" I2C OLED Display Module - a compact 128x64 display for showing distance readings
- 120pcs Dupont Jumper Wires - for sharing the I2C bus connections across modules
External
- USB cable - to connect the Arduino to your computer
- Computer with Arduino IDE installed
- Arduino Uno R3 - reads the sensor and drives the OLED
Note: Both the VL53L0X and the SSD1306 OLED use the I2C bus (SCL and SDA), so they share the same two data lines on the Arduino. Their default I2C addresses are different (0x29 for the VL53L0X and 0x3C for the OLED), which means they can operate on the same bus without conflicts.
Step-by-Step Guide
Step 1 - Gather the Components
Goal: Collect all the parts you need for this project.
What to do: You will need an Arduino Uno (or any Arduino board with I2C support), a VL53L0X time-of-flight laser ranging sensor module, an SSD1306 0.96-inch I2C OLED display, and jumper wires for the connections. Both modules communicate over I2C, which keeps the wiring simple with only four connections each.
Expected result: All parts are ready on your workbench.
Step 2 - Wire the Circuit
Goal: Connect the VL53L0X sensor and the OLED display to the Arduino over I2C.
What to do: Both modules use the I2C protocol, so they share the same SCL and SDA lines. Make the following connections:
OLED Display:
- GND to Arduino GND
- VCC to Arduino 5V
- SCL to Arduino SCL (A5 on Uno)
- SDA to Arduino SDA (A4 on Uno)
VL53L0X Sensor:
- GND to Arduino GND
- VCC to Arduino 5V
- SCL to Arduino SCL (A5 on Uno)
- SDA to Arduino SDA (A4 on Uno)
Expected result: Both modules are wired to the Arduino and share the SCL/SDA lines.
Step 3 - Install the Required Libraries
Goal: Add the necessary Arduino libraries for the VL53L0X sensor and the OLED display.
What to do: Open the Arduino IDE and go to Sketch > Include Library > Manage Libraries. Search for and install:
- Adafruit_VL53L0X - for communicating with the VL53L0X sensor
- Adafruit_SSD1306 - for driving the OLED display
- Adafruit_GFX - required graphics library for the SSD1306 driver
Expected result: All three Adafruit libraries are installed.
Step 4 - Upload the Arduino Sketch
Goal: Program the Arduino to read distance from the VL53L0X and display it on the OLED.
What to do: Create a new sketch and paste the following code.
#include <Wire.h>
#include <Adafruit_VL53L0X.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
void setup() {
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 failed"));
for (;;);
}
display.clearDisplay();
display.display();
if (!lox.begin()) {
Serial.println(F("VL53L0X failed"));
while (1);
}
Serial.println(F("VL53L0X ready"));
}
void loop() {
VL53L0X_RangingMeasurementData_t measure;
lox.rangingTest(&measure, false);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("Distance:");
if (measure.RangeStatus != 4) {
display.setTextSize(3);
display.setCursor(0, 30);
display.print(measure.RangeMilliMeter);
display.println(" mm");
Serial.print("Distance: ");
Serial.print(measure.RangeMilliMeter);
Serial.println(" mm");
} else {
display.setTextSize(2);
display.setCursor(0, 30);
display.println("Out of");
display.println("range");
}
display.display();
delay(100);
}
This sketch uses lox.rangingTest() to get distance measurements. When valid (RangeStatus not 4), it shows the distance in mm on the OLED. Otherwise it shows "Out of range".
Select Arduino Uno under Tools > Board, choose the correct COM port, and click Upload.
Expected result: The sketch compiles and uploads without errors.
Step 5 - Test the Distance Display
Goal: Verify that the OLED shows live distance measurements.
What to do: Once uploaded, the OLED should display the distance in mm. Place objects in front of the VL53L0X sensor and move them closer and farther. The VL53L0X measures from about 30 mm up to 1200 mm accurately.
Expected result: The OLED shows distance in mm that updates as you move objects in front of the sensor.
Conclusion
You connected a VL53L0X time-of-flight distance sensor and an SSD1306 OLED display to an Arduino Uno over the shared I2C bus, creating a compact distance meter that displays readings in millimeters in real time.
Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something similar for your product, check out our IoT consulting services.
Credits: Photos and images are credited to RonFrtek on Instructables, which served as the reference for this version.


