Coder Social home page Coder Social logo

vl53l0x's Introduction

VL53L0X

Arduino library to support the VL53L0X Time-of-Flight and gesture-detection sensor

API

This sensor uses I2C to communicate. And I2C instance is required to access to the sensor.

The API provides simple distance measure, single swipe gesture detection, directional (left/right) swipe gesture detection and single tap gesture detection.

Examples

There are 3 examples with the VL53L0X library.

  • DISCO_IOT_DataLogTerminal: This example code is to show how to get proximity values of the onboard VL53L0X sensor

  • DISCO_IOT_Gesture_Swipe1: This example code is to show how to combine the proximity value of the onboard VL53L0X sensor together with the gesture library in order to detect a simple swipe gesture without considering the direction.

  • DISCO_IOT_Gesture_Tap1: This example code is to show how to combine the proximity value of the onboard VL53L0X sensor together with the gesture library in order to detect a simple tap gesture.

Dependencies

The VL53L0X library requires the following STM32duino library:

Note

The maximum detection distance is influenced by the color of the target and the indoor or outdoor situation due to absence or presence of external infrared. The detection range can be comprise between ~40cm and ~120cm. (see chapter 5 of the VL53L0X datasheet). If you need an higher accuracy (up to +200cm), you should implement your own function. The library should work also with standard Arduino boards. In this case you just need to adjust the code in the sketch in order to use the correct Wire instance and the correct pin number for XSHUT and GPIO1 pins.

Documentation

You can find the source files at
https://github.com/stm32duino/VL53L0X

The VL53L0X datasheet is available at
http://www.st.com/content/st_com/en/products/imaging-and-photonics-solutions/proximity-sensors/vl53l0x.html

vl53l0x's People

Contributors

cparata avatar fpistm avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vl53l0x's Issues

Array of VL53L0X Objects

Hi,

I'm trying to create an array of these sensors that can be scaled in size, however with my current code the InitSensor method is always failing.

The array is created here

 #define NUM_SENSORS 3   
#define WIRE_INTERFACE Wire  
int XHUT_PINS[NUM_SENSORS]={33,35, 37};   
int GPIO_PINS[NUM_SENSORS]={34,36, 38};   
byte I2C_addresses[NUM_SENSORS] = {0x10,0x11, 0x12};   
VL53L0X* range_sensor_aray[NUM_SENSORS]; 

Then initialised here

for(int i=0;i<NUM_SENSORS;i++){
    range_sensor_aray[i] = new VL53L0X(&WIRE_INTERFACE ,XHUT_PINS[i],GPIO_PINS[i]);
    range_sensor_aray[i]->VL53L0X_Off(); 
  }

  for(int i=0;i<NUM_SENSORS;i++){
    status = range_sensor_aray[i]->InitSensor(I2C_addresses[i]); 
    #ifdef DEBUG 
      if(status) DEBUG_SERIAL.println("Init of Sensor " + String(i) + " Failed"); 
    #endif  
    range_sensor_aray[i]->VL53L0X_Off();  
  }

  for(int i=0;i<NUM_SENSORS;i++){
     range_sensor_aray[i]->VL53L0X_On(); 
    
  }

I'm not sure if it's my code, or the class its self that is causing this issue.

InitSensor() returns error when using VL53L0x_DEFAULT_DEVICE_ADDRESS

Library version: 2.0.0
IDE: PlatformIO or ArduinoIDE, both show the same error
BSP: PIO Nordic nRF52 Arduino STM32Duino

Bug: InitSensor(0x52); always returns error VL53L0X_ERROR_INVALID_PARAMS

Code to show error:

	int status = tof_sensor.InitSensor(0x52);
	if (status)
	{
		Serial.println("Failed to detect and initialize sensor!");
	}

Cause:
Problem is in the code of InitSensor() in vl53l0x_class.cpp:

      if(NewAddr!=VL53L0x_DEFAULT_DEVICE_ADDRESS)
      {
         status=SetDeviceAddress(NewAddr);
         if(status)
         {
            printf("Failed to change I2C address!\n\r");
            return status;
         }
      }
      else
      {
         printf("Invalid new address!\n\r");
         return VL53L0X_ERROR_INVALID_PARAMS;
      }

Will always return an VL53L0X_ERROR_INVALID_PARAMS if InitSensor(0x52) is called.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.