Adafruit VL6180X Time of Flight Micro-LIDAR Distance Sensor Breakout Created by lady ada Last updated on 2020-03-27 11:52:04 AM EDT
Overview The VL6180X is a Time of Flight distance sensor like no other you've used! The sensor contains a very tiny invisible laser source, and a matching sensor. The VL6180X can detect the "time of flight", or how long the light has taken to bounce back to the sensor. Since it uses a very narrow light source, it is good for determining distance of only the surface directly in front of it. Unlike sonars that bounce ultrasonic waves, the 'cone' of sensing is very narrow.
As if that weren't enough, we've also added SparkFun qwiic (https://adafru.it/Fpw) compatible STEMMA QT (https://adafru.it/Ft4) connectors for the I2C bus so you don't even need to solder. Just wire up to your favorite micro with a plug-and-play cable to get 6-DoF data ASAP. For a no-solder experience, just wire up to your favorite micro, like the STM32F405 Feather (https://adafru.it/Iqc) using a STEMMA QT adapter cable. (https://adafru.
The sensor is small and easy to use in any robotics or interactive project. Since it needs 2.8V power and logic we put the little fellow on a breakout board with a regulator and level shifting. You can use it with any 3-5V power or logic microcontroller with no worries. Each order comes with a small piece of header.
Pinouts The VL6180X is a I2C sensor. That means it uses the two I2C data/clock wires available on most microcontrollers, and can share those pins with other sensors as long as they don't have an address collision. For future reference, the I2C address is 0x29 and you can't change it! Power Pins: Vin - this is the power pin. Since the chip uses 2.8 VDC, we have included a voltage regulator on board that will take 3-5VDC and safely convert it down.
© Adafruit Industries https://learn.adafruit.
Assembly Don't forget to remove the protective cover off the sensor, it may be a clear or slightly tinted plastic! Otherwise you will get incorrect readings This page shows the VL53L0X or VL6180X sensor - the procedure is identical! Prepare the header strip: Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down © Adafruit Industries https://learn.adafruit.
Place the Breakout board on top so the shorter ends of the pins line up though all the pads © Adafruit Industries https://learn.adafruit.
Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (https://adafru.it/aTk)). © Adafruit Industries https://learn.adafruit.
OK You're done! Check your work over and continue on to the next steps © Adafruit Industries https://learn.adafruit.
Arduino Code You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, just make sure it has I2C, then port the API code. We strongly recommend using an Arduino to start though! Wiring There's two versions of this sensor, and the pin orders vary slightly so be sure to read the text on the breakout to match the pins to the wiring diagrams. Connect Vin to the power supply, 3-5V is fine.
Install Adafruit_VL6180X To begin reading sensor data, you will need to install Adafruit_VL6180X Library from our github repository (https://adafru.it/sId). It is available from the Arduino library manager so we recommend using that. From the IDE open up the library manager... And type in adafruit vl6180 to locate the library. Click Install We also have a great tutorial on Arduino library installation at: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use (https://adafru.
Thats it! Now open up the serial terminal window at 115200 speed to begin the test. Move your hand up and down to read the sensor data, the range readings are in millimeters and the light sensors in Lux. Note that when nothing is detected, it will print out the error which may vary.
vl.begin() Reading Distance Reading the range/distance is easy, just call readRange() vl.readRange() which will return the range in millimeters. If you get 0 or a value over 200 there's likely an error. Either way, before you trust that reading make sure to ask the sensor if the last reading had an error: uint8_t status = vl.readRangeStatus() The status will be 0 on no error, anything else is an error.
Here's the gain's available: VL6180X_ALS_GAIN_1 - gain of 1x VL6180X_ALS_GAIN_1_25 - gain of 1.25x VL6180X_ALS_GAIN_1_67 - gain of 1.67x VL6180X_ALS_GAIN_2_5 - gain of 2.5x VL6180X_ALS_GAIN_5 - gain of 5x VL6180X_ALS_GAIN_10 - gain of 10x VL6180X_ALS_GAIN_20 - gain of 20x VL6180X_ALS_GAIN_40 - gain of 40x We suggest starting with a gain of 5x and then adjusting up or down as necessary © Adafruit Industries https://learn.adafruit.
Arduino Library Docs Arduino Library Docs (https://adafru.it/Avp) © Adafruit Industries https://learn.adafruit.
Python & CircuitPython It's easy to use the VL6180X sensor with Python and CircuitPython, and the Adafruit CircuitPython VL6180X (https://adafru.it/C66) module. This module allows you to easily write Python code that reads the light and proximity readings from the sensor. You can use this sensor with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library (https://adafru.it/BSN).
Board 3V to sensor VIN Board GND to sensor GND Board SCL to sensor SCL Board SDA to sensor SDA Python Computer Wiring Since there's dozens of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported (https://adafru.it/BSN).
Pi 3V3 to sensor VIN Pi GND to sensor GND Pi SCL to sensor SCL Pi SDA to sensor SDA CircuitPython Installation of VL6180X Library Next you'll need to install the Adafruit CircuitPython VL6180X (https://adafru.it/C66) library on your CircuitPython board. First make sure you are running the latest version of Adafruit CircuitPython (https://adafru.it/Amd) for your board.
import board import busio import adafruit_vl6180x i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_vl6180x.VL6180X(i2c) Now you're ready to read the range and other values from the sensor. You can do so with a few properties and functions: range Property - This property returns the range as read from the sensor in millimeters. range_status Property - This property returns any error or issues that was encountered while reading the range.
Here's a complete example that will read the range and lux (using 1x gain) each second and print it out. Save this as code.py on your board and open the REPL to see the output. Full Example Code # Demo of reading the range and lux from the VL6180x distance sensor and # printing it every second. # Author: Tony DiCola import time import board import busio import adafruit_vl6180x # Create I2C bus. i2c = busio.I2C(board.SCL, board.SDA) # Create sensor instance. sensor = adafruit_vl6180x.
Python Docs Python Docs (https://adafru.it/C7w) © Adafruit Industries https://learn.adafruit.
Downloads Files & Datasheets Datasheet for the VL6180X (https://adafru.it/sIa) ST product page (https://adafru.it/sIb) with more details including API downloads Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) STEMMA revision Fritzing object in Adafruit Fritzing library (https://adafru.it/JRD) EagleCAD PCB files in GitHub (https://adafru.it/sIc) Schematic & Fabrication Print STEMMA revision: Original: © Adafruit Industries https://learn.adafruit.
STEMMA revision: Use M2.5 or #2-56 screws to mount Original: © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2020-03-27 03:52:04 PM UTC Page 27 of 27