搜索代码

Using Two or More VL6180X 20cm Time-of-Flight Proximity Sensors with Arduino

Using Two or More VL6180X 20cm Time-of-Flight Proximity Sensors with Arduino

Using Two or More VL6180X 20cm Time-of-Flight Proximity Sensors with Arduino

In this tutorial, we will explore how to use two or more VL6180X time-of-flight proximity sensors with an Arduino. These sensors are capable of measuring distances up to 20 centimeters, making them ideal for various robotics applications. By the end of this guide, you will understand how to wire the sensors correctly and implement the code needed to read distance measurements from each sensor.

VL6080X Sensor top view

The VL6180X sensors utilize I2C communication, allowing multiple sensors to be connected to the same bus. This tutorial will cover both single and dual sensor setups, with an emphasis on how to manage multiple sensors effectively. If you need further clarification, be sure to check the video (in video at 00:00).

Hardware Explained

The key component of this project is the VL6180X proximity sensor. This compact sensor is designed for short-range distance measurement and operates within a voltage range of 2.6 to 3.6 volts. It utilizes a laser-assisted time-of-flight measurement technique, allowing for accurate readings with minimal power consumption.

Each sensor has several pins, including GPIO for shutdown, SCL and SDA for I2C communication, and a ground pin. When using multiple sensors, it's essential to manage their shutdown pins to avoid conflicts in I2C addresses, as each sensor must have a unique address on the bus.

Datasheet Details

ManufacturerSTMicroelectronics
Part numberVL6180X
Logic/IO voltage2.6 – 3.6 V
Supply voltage2.6 – 3.6 V
Output current (per channel)1.7 mA (typ.)
Peak current (per channel)
PWM frequency guidance
Input logic thresholds
Voltage drop / RDS(on) / saturation
Thermal limits-20 to 70 °C
Package4.8 x 2.8 x 1 mm
Notes / variantsMaximum range 62 cm

  • Ensure proper power supply within the specified voltage range.
  • Use unique I2C addresses for each sensor to avoid communication conflicts.
  • Manage the shutdown pins to power on/off sensors as needed.
  • Utilize pull-up resistors on I2C lines, if necessary, for stable communication.
  • Be mindful of the operating temperature limits to avoid sensor damage.

Wiring Instructions

VL6180_dual_sensor_bb

To wire the VL6180X sensors to an Arduino, start by connecting the power and ground. Connect the sensor's 5V pin to the 5V pin on the Arduino, and the GND pin to the Arduino's ground. Next, connect the SCL pin of the sensor to the Arduino's A5 pin, and the SDA pin to the A4 pin. If you're using two sensors, connect the shutdown pins of the first sensor to 7 and the second sensor to 6.

For multiple sensors, ensure that each sensor's shutdown pins are controlled independently to manage I2C addresses easily. You can connect the first sensor's XSHUT pin to 7 and the second sensor's XSHUT pin to 6. This setup will allow you to initialize each sensor one at a time. Remember to leave a space between the sensors on the breadboard to prevent any short circuits.

Code Examples & Walkthrough

In the code, we begin by including the necessary library for the VL6180X sensor:

#include 

This line imports the Adafruit library, which provides the necessary functions to interact with the sensor.

Next, we define the addresses and shutdown pins for our sensors:

#define LOX1_ADDRESS 0x30
#define LOX2_ADDRESS 0x31
#define SHT_LOX1 7
#define SHT_LOX2 6

Here, we set unique addresses for each sensor and specify the pins used to control their shutdown states.

In the setup() function, we initialize the sensors:

void setup() {
  Serial.begin(115200);
  pinMode(SHT_LOX1, OUTPUT);
  pinMode(SHT_LOX2, OUTPUT);
  setID();
}

This snippet initializes the serial communication and sets the shutdown pins as outputs. The setID() function is called to manage the sensor addresses and activate them accordingly.

Demonstration / What to Expect

During testing, you can expect accurate readings from the sensors within the specified range. When an object is placed within 20 centimeters, the sensor should provide consistent distance measurements (in video at 05:00). If the sensors are not configured correctly, you may experience errors or inaccurate readings.

As you run the code, each sensor's readings will be printed in the serial monitor. Make sure to check the readings against known distances to verify accuracy. If you notice any discrepancies, double-check your wiring and ensure that the sensors are powered correctly.

Video Timestamps

  • 00:00 Start
  • 00:56 Introduction
  • 04:30 VL6080V Datasheet viewed
  • 06:58 Wiring shown
  • 07:32 Wiring for two or more sensors
  • 09:22 Installing library
  • 10:30 Arduino code explained (1 sensor)
  • 12:57 Code for 2 or more sensors
  • 19:35 Demonstration 1 sensor
  • 22:05 Demonstration with 2 sensors

图像

VL6080X Sensor back of PCB
VL6080X Sensor back of PCB
VL6080X Sensor top view
VL6080X Sensor top view
VL6080X Sensor verticle
VL6080X Sensor verticle
VL6180 laser Distance sensor
VL6180 laser Distance sensor
VL6180 laser Distance sensor
VL6180 laser Distance sensor
VL6180_wiring_new
VL6180_wiring_new
VL6180_dual_sensor_bb
VL6180_dual_sensor_bb
362-Chapters in this video
语言: C++
This code has not been parsed yet. Please return to the admin panel to parse it.
450-Lesson 76: Using 2 ore more VL6180X 62cm Laser Distance Sensors with Arduino
语言: C++
This code has not been parsed yet. Please return to the admin panel to parse it.

文件📁

没有可用的文件。