Arduino drives VL6180X optical ranging sensor (OLED display)

Arduino drives VL6180X optical ranging sensor (OLED display)

Introduction

The VL6108X three-in-one optoelectronic module integrates an IR VSEL (vertical-cavity surface-emitting laser) infrared vertical cavity surface-emitting laser light source, proximity sensor, and ambient light sensor (ALS) into the chip. This is a breakthrough technology that measures absolute distance independent of target reflectivity. Rather than estimating distance by measuring the amount of light reflected back from an object (which is greatly affected by color and surface), the VL6180 precisely measures the time it takes for light to reach the nearest object and reflect back to the sensor.
Insert image description here

principle

The VL6180X module implements a proximity sensor using the time-of-flight (ToF) measurement principle; the VL6180X contains a SPAD (Single Photon Avalanche Diode) detector array, which detects the time it takes for a single photon to travel from emission to contact the target and then return to the module, and combines it with the signal amplitude to calculate Actual distance, rather than relying on the reflectivity of an object, this actual distance measurement capability can also produce simple but reliable one-dimensional gesture control.
Insert image description here

Insert image description here

Module parameters

Infrared laser wavelength: 850nm
Communication interface: IIC (400kHz), address 0x29 (7 bits), two programmable GPIOs
Optimal operating temperature: -10~60℃
Ranging performance parameters:
Ranging (closer) range: 0~ 100mm error 13mm Under certain external environmental conditions, such as dark environment, it can exceed 100mm
Temperature drift: 9~15mm Voltage drift: 3~5mm
Conversion time: 15ms
Ambient light sensing performance parameters:
Ambient light range: 1~100kLux 16-bit output
Ambient light gain range: 1~40 (eight levels)
Ambient light sensitivity: 0.36Lux/count (535nm LED @ 1 kLux. Measured @ gain 20)
Angle response: 42 degrees
Linear error: 5% (1~300Lux), 10% (300~7500Lux)
Gain error: 1% (gain 20), 7% (gain 1~10)

Wiring diagram

Arduino VL6180X OLED
5V VCC VCC
GND GND GND
A4 SDA SDA
A5 SCL SCL

code

#include <Wire.h>
#include "MHEtLive_VL6180X.h"

MHEtLive_VL6180X vl = MHEtLive_VL6180X();

#include <Adafruit_SSD1306.h>  //1306的库文件
#define OLED_RESET 13                   //设置复位是13号引脚
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
    
    
  Serial.begin(115200);
 
 display.begin(SSD1306_SWITCHCAPVCC,0x3C); //刷新
  display.clearDisplay(); //清屏
  display.setTextColor(WHITE);   //字体白色
  display.display();  //显示

  // wait for serial port to open on native usb devices
  while (!Serial) {
    
    
    delay(1);
  }
 
  Serial.println("MHEtLive VL6180x test!");
  if (! vl.begin()) {
    
    
    Serial.println("Failed to find sensor");
    while (1);
  }
  Serial.println("Sensor found!");
}

void loop() {
    
    

  
  
  float lux = vl.readLux(VL6180X_ALS_GAIN_5);

  //Serial.print("Lux: "); Serial.println(lux);
  
  uint8_t range = vl.readRange();
  uint8_t status = vl.readRangeStatus();

  if (status == VL6180X_ERROR_NONE) {
    
      
    Serial.print("Range: "); Serial.println(range);
 //*****************************************************
        display.setTextSize(1);       //字体大小为2号
        display.setCursor(35,0); 
        display.print("VL6180");
        display.setCursor(0,12); 
        display.print("Range:");
        display.print(range);
   
//*****************************************************  
  }

result

Serial display:
Insert image description here
OLED display:

Insert image description here

Guess you like

Origin blog.csdn.net/qq_42250136/article/details/135289461