cancel
Showing results for 
Search instead for 
Did you mean: 

The issues of developing VL6180 with Arduino IDE

Hongxuan
Associate

IDE: Arduino IDE2.2.1

Evaluation board: Nucleo-F303RE, VL6180x-statel

 

I found the library from the github GitHub - stm32duino/VL6180X: Arduino library to support the VL6180X Time-of-Flight and gesture-detection sensor, and installed it successfully.

I want to measure distance of object and lux, but there is no example of source code about that.

I program it by myself as bellow:

#define VL6180x_DEFAULT_DEVICE_ADDRESS 0x29
#define VL6180x_SINGLE_DEVICE_DRIVER  1
#define DEV_I2C Wire
#define IIC_SCL PB8
#define IIC_SDA PB9

#define LED_blink   PA5 //D13
#define GPIO_12   PA6  //D12
// Components.
VL6180X sensor(&DEV_I2C, GPIO_12);


/* Setup ---------------------------------------------------------------------*/

void setup() {
  int status;
  // Led.
  pinMode(LED_blink, OUTPUT);

  digitalWrite(LED_blink, LOW);
  delay(100);
  digitalWrite(LED_blink, HIGH);
  // Initialize serial for output.
  Serial.begin(9600);  
//End of workaround

  // Initialize I2C bus.
   DEV_I2C.begin();

  // Configure VL6180X top component.
   sensor.begin();
 
  // Switch off VL6180X top component.
  sensor.VL6180x_Off();

  Serial.print("Start to test...\n");
  sensor.VL6180x_On();
  // Initialize VL6180X.
  status = sensor.Init();
  if(status)
  {
    Serial.println("Init sensor_vl6180x_top failed...");
  }
 
  sensor.StartInterleavedMode();
}
/* Loop ----------------------------------------------------------------------*/

void loop() {
 
  // Read Lux.
  uint32_t lux;  
  sensor.GetLight(&lux);
  Serial.print("Lux[lux]= ");
  Serial.println(lux);
  // Read Range.
  uint32_t range;
  sensor.GetDistance(&range);
  Serial.print("Range[mm]= ");
  Serial.println(range);
 
  delay(1000);
}
it  compiled and uploaded successful, but the I2C can not start, I make sure the hardware connection is ok.
Can you indicate the issues or provide me example of source code?
Thanks a lot.

 

 

 

1 REPLY 1
Douglas MILLER
ST Employee

This forum thread was marked by the moderator as needing a little more investigation, so a Support case was created in your name and will be handled off-line.