Go Down

Topic: SIMPLE QUESTION: Using shutdown of VL53L1X (Read 302 times) previous topic - next topic

kasperzegel

Hi all,

I have a basic question.
For my setup I use atMega328P, RF transmitter and a VL53L1X.
Since the setup is running on a battery I want to use the less power as possible.

Since the VL53L1X has a shutdown mode(?), which I believe is as a standby mode?
I would really like to use this, but I'm not sure how to connect it right, since it is really hard to test if it is actually working.

Here I have the datasheet https://www.st.com/resource/en/datasheet/vl53l1x.pdf

IF.... there is a better way to use a standby I would be really glad with help, since I'm not very good at programming.
I would think like a way of; if measurement changes more then 100mm then turn standby off for instance

I've added code here.
Code: [Select]
/*
This example shows how to take simple range measurements with the VL53L1X. The
range readings are in units of mm.
*/

#include <Wire.h>
#include <VL53L1X.h>

VL53L1X sensor;

void setup()
{
  Serial.begin(115200);
  Wire.begin();
  Wire.setClock(400000); // use 400 kHz I2C
  pinMode(LED_BUILTIN,OUTPUT);

  sensor.setTimeout(500);
  if (!sensor.init())
  {
    Serial.println("Failed to detect and initialize sensor!");
    while (1);
  }
 
  // Use long distance mode and allow up to 50000 us (50 ms) for a measurement.
  // You can change these settings to adjust the performance of the sensor, but
  // the minimum timing budget is 20 ms for short distance mode and 33 ms for
  // medium and long distance modes. See the VL53L1X datasheet for more
  // information on range and timing limits.
  sensor.setDistanceMode(VL53L1X::Long);
  sensor.setMeasurementTimingBudget(50000);

  // Start continuous readings at a rate of one measurement every 50 ms (the
  // inter-measurement period). This period should be at least as long as the
  // timing budget.
  sensor.startContinuous(50);
}

void loop()
{

  Serial.print(sensor.read());
 /* digitalWrite(LED_BUILTIN, HIGH);
  delay (1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000); */
  if (sensor.readRangeContinuousMillimeters () <=1000) {
    digitalWrite (LED_BUILTIN, HIGH);
    } else {
    digitalWrite (LED_BUILTIN, LOW);
    }

  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT");}
  Serial.println();
}

Klaus_K

Since the VL53L1X has a shutdown mode(?), which I believe is as a standby mode?
I would really like to use this, but I'm not sure how to connect it right, since it is really hard to test if it is actually working.
Figure 3 in the datasheet shows you how to connect the sensor including the hardware shutdown signal.
If you can measure the current of your circuit this should be easy to find out. The standby current is a lot smaller than the active current. Also when the standby signal is enabled the sensor will stop working.

Here I have the datasheet https://www.st.com/resource/en/datasheet/vl53l1x.pdf
Thank you.

IF.... there is a better way to use a standby I would be really glad with help, since I'm not very good at programming.
I would think like a way of; if measurement changes more then 100mm then turn standby off for instance
You can just write a LOW to the pin you select for the XSHUT and the sensor will go into standby mode. You will need to set it back to HIGH or INPUT (the pull-up resistor will create the high signal in this case) when you want to use the sensor.
Many come to this forum to get better at programming. You are not alone.

Have a look at the examples that come with the libraries and the IDE. For instance

File -> Examples -> 02.Digital -> BlinkWithoutDelay

will teach you how to not use delay. The delay function is one of the first things you should learn to avoid. :) It just stops execution and wastes processor cycles. It is OK for very simple examples but often complicates extending sketches without breaking something.

kasperzegel

Hi Klaus,

Thank you for your quick response. Okay, so there's no 'auto-standby'. But please have a look at page 8 on the datasheet, just to be sure. On the block diagram there is a S(oft)W(are) Standby and a H(ard)W(are) Standby, so i'm not sure...

I'm wondering, and need to test this, when I shutdown, the sensor will not give any input to the AtMega328.


So there should be always an other input to wake him up. I was hoping I was able something like:
When there is no input change of at least 5cm for a period of 30s, go to sleep and wait till you notice a bigger change.

So in my situation this will not be useful, however I'm hoping the device will work for a long period on a battery.

Just to explain my situation, perhaps you have great input. I'm creating a human presence detector for a toilet, which will work on a battery and send input through RF. The RF has a standby mode, so when there is no input, it will consume less power.
I'm aiming for a battery lifetime of at least 3 months. For now I'm using a 9V battery.

I noticed from the datasheet there is quite a difference in power consumption when using the standby mode or not..








Klaus_K

On the block diagram there is a S(oft)W(are) Standby and a H(ard)W(are) Standby, so i'm not sure...
I had another look at the datasheet. It looks like you can do both. You can ether control it from the MCU using the XSHUT pin or tell the sensor to wake you up when certain conditions are meet.

So there should be always an other input to wake him up. I was hoping I was able something like:
When there is no input change of at least 5cm for a period of 30s, go to sleep and wait till you notice a bigger change.
You will need to play with the options. Have a look at the statement in the datasheet.

Quote from: VL53L1X Datasheet page 9
The user can set distance thresholds (below, above, inside, or outside the user-defined thresholds). An interrupt is raised only when threshold conditions are met.
I suspect what you want will not be possible directly. You basically want to change the base point dynamically. But you can set static values when you get an interrupt. This should be enough for your application. Could you post a link to the library you are using?

I'm aiming for a battery lifetime of at least 3 months. For now I'm using a 9V battery.
Do you need the 9V for something in your system? Converting power is energy lost.

I noticed from the datasheet there is quite a difference in power consumption when using the standby mode or not..
Yes, the difference is high. Tweaking the timing will be the key to get lower average power / longer battery life.

Go Up