Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy 3.2 and VL53L0X

  1. #1
    Junior Member
    Join Date
    Jan 2020
    Posts
    2

    Teensy 3.2 and VL53L0X

    Hello everybody!

    I am new to the forum and a newbie to the Teensy world in general, so sorry if I am not too precise or if I say something obvious. I am currently trying to read the measurements of a VL53L0X sensor on a Flow Deck expansion by Bitcraze by the means of a Teensy 3.2. I have no problem with the optic flow sensor, but whenever I try to use the VL53L0X I can't even initialize it. I was originally using the Wire.h library, but I have then discovered it is not compatible with Teensy 3.2. I tried to use the i2c_t3 library (which should be compatible), but now every time I launch my code my pc freezes.
    To test if it wasn't a wiring problem, I have also tried to do the exact same thing with an Arduino Mega 2560 using the Wire.h library and it works perfectly. So I am pretty sure it is a library problem... Maybe the i2c_t3 isn't what I am searching for or I am using it wrong. Do you guys have any suggestions?

    This is my code:
    #include <i2c_t3.h>
    //#include <Wire.h>
    #include <VL53L0X.h>

    VL53L0X sensor;


    void setup()
    {
    Serial.begin(9600);
    Wire.begin();
    Serial.print("B");
    sensor.setTimeout(500);
    sensor.setTimeout(500);
    if (!sensor.init())
    {
    Serial.println("Failed to detect and initialize sensor!");
    while (1) {}
    }

    Serial.print("C");
    // Start continuous back-to-back mode (take readings as
    // fast as possible). To use continuous timed mode
    // instead, provide a desired inter-measurement period in
    // ms (e.g. sensor.startContinuous(100)).
    sensor.startContinuous();

    }

    int incomingByte = 0;
    boolean stop = true;

    void loop()
    {
    if(stop == true){
    Serial.print(sensor.readRangeContinuousMillimeters ());
    if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

    Serial.println();
    if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    if(incomingByte == 'k'){
    stop = false;
    Serial.print("Program stopped.");
    }
    }
    }
    }

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,215
    Which VL53L0X library are you using?

    Pete

  3. #3
    Junior Member
    Join Date
    Jan 2020
    Posts
    2
    Hi Pete!

    I am using the VL53L0X library from Pololu. I have also tried the Adafruit_VL53L0X library wihout any success.

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,215
    I can't get your code to compile with the Pololu library. But it does compile if I change the first three lines to this:
    Code:
    //#include <i2c_t3.h>
    #include <Wire.h>
    #include <VL53L0X.h>
    Try it and let me know what happens.


    every time I launch my code my pc freezes
    Can you give more detail of this? I don't see how the Teensy code can freeze your PC.

    Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •