Created
March 16, 2017 22:50
-
-
Save ARod/6440d4077ec4c77333dcdf504f34a0ba to your computer and use it in GitHub Desktop.
VL530X Sensor TimingOut after 15 to 20 minutes Output 65536
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <VL53L0X.h> | |
#define RSensorPin 52 | |
#define LSensorPin 50 | |
VL53L0X RSensor; // Right Sensor | |
VL53L0X LSensor; // Left Sensor | |
// Uncomment this line to use long range mode. This | |
// increases the sensitivity of the sensor and extends its | |
// potential range, but increases the likelihood of getting | |
// an inaccurate reading because of reflections from objects | |
// other than the intended target. It works best in dark | |
// conditions. | |
//#define LONG_RANGE | |
// Uncomment ONE of these two lines to get | |
// - higher speed at the cost of lower accuracy OR | |
// - higher accuracy at the cost of lower speed | |
//#define HIGH_SPEED | |
#define HIGH_ACCURACY | |
void setup(){ | |
pinMode(RSensorPin, OUTPUT); // Make Pin Outputs | |
pinMode(LSensorPin, OUTPUT); | |
digitalWrite(RSensorPin, 0); // Pull Lines LOW - Disabling Both Sensors | |
digitalWrite(LSensorPin, 0); | |
delay(500); | |
// Serial Port and I2C | |
Serial.begin(9600); // Start Serial Port for Troubleshooting | |
Wire.begin(); // I2C Serial Port Initialization | |
// Addressing Sensors | |
pinMode(RSensorPin, INPUT); // Getting Right Sensor Ready | |
RSensor.setAddress((uint8_t)41); // Address 41 | |
delay(10); | |
pinMode(LSensorPin, INPUT); // Getting Left Sensor Ready | |
LSensor.setAddress((uint8_t)43); // Address 43 | |
delay(10); | |
// Initializing Sensors | |
RSensor.init(true); | |
LSensor.init(true); | |
// Timeout (Still need to figure what is the timeout all about). | |
RSensor.setTimeout(500); | |
LSensor.setTimeout(500); | |
// Continuous Measurements | |
RSensor.startContinuous(5); // Every 20 ms | |
LSensor.startContinuous(5); // Every 20 ms | |
#if defined LONG_RANGE | |
// lower the return signal rate limit (default is 0.25 MCPS) | |
sensor.setSignalRateLimit(0.1); | |
// increase laser pulse periods (defaults are 14 and 10 PCLKs) | |
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18); | |
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14); | |
#endif | |
#if defined HIGH_SPEED | |
// reduce timing budget to 20 ms (default is about 33 ms) | |
RSensor.setMeasurementTimingBudget(20000); | |
LSensor.setMeasurementTimingBudget(20000); | |
#elif defined HIGH_ACCURACY | |
// increase timing budget to 200 ms | |
RSensor.setMeasurementTimingBudget(200000); | |
LSensor.setMeasurementTimingBudget(200000); | |
#endif | |
} | |
void loop(){ | |
Serial.print(RSensor.readRangeContinuousMillimeters()); | |
Serial.print(','); | |
Serial.print(LSensor.readRangeContinuousMillimeters()); | |
Serial.println(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment