Hi all,
I'm still stuck on my VL53L1X project, which should be nearly done.
I've come really far, but facing issues on the final stage.
I want the VL53L1X to shutdown when not necessary and interrupt when detecting something in range.
No hardware should be involved to wake up the sensor
Somehow, I can't get it to work.
First of all I'm not really sure about the wiring, since the datasheet is quite difficult to read (for me).
I noticed connecting NC1 and XSHUT is putting the sensor to sleep, but I'm not sure how to wake it up again.
Also, there is a INT (which is interrupt, I guess), connected to Digital pin 3
https://www.st.com/resource/en/data_brief/vl53l1x-satel.pdf
Is there anyone who is willing to help me out on this final stage
Here is my code so far.
/* THEBULB. THE SO-LOO-TION SENSOR */
#include <Wire.h>
#include <LowPower.h>
#include <VL53L1X.h>
VL53L1X sensor;
void setup()
{
Serial.begin(115200);
Wire.begin();
Wire.setClock(100000); // 400000 originally
/* for (int i = 0; i < 20; i++){
pinMode(i, OUTPUT);
}
*/
pinMode(7, OUTPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(3, OUTPUT);
sensor.setTimeout(500);
if (!sensor.init())
{
Serial.println("Let op: de sensor wordt momenteel niet gedetecteerd. Controleer aansluitingen. ");
while (1);
}
sensor.setDistanceMode(VL53L1X::Long);
sensor.setMeasurementTimingBudget(50000); //50000
sensor.startContinuous(100);
}
void loop()
{
Serial.print(sensor.read());
digitalWrite(3, HIGH);
digitalWrite(12, HIGH);
if (sensor.readRangeContinuousMillimeters () <=1000 ) { //schakelafstand wordt hier ingevoerd. Onder deze waarde is de schakeling actief.
//HERE THE SENSOR SHOULD WAKE UP
digitalWrite (7, HIGH);
digitalWrite (13, HIGH);
}else { //hoger dan de schakelafstand.
digitalWrite (7, LOW);
digitalWrite(13, LOW);
LowPower.powerDown(SLEEP_FOREVER , ADC_OFF, BOD_OFF);
//HERE THE SENSOR SHOULD GO TO SLEEP (IT IS DETECTING ABOVE 1000mm)
}
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT");}
Serial.println();
}