in this series of three lectures we are going to learn how we can use this vl53r0x tiny laser
distance sensor this can be used to measure distance with accuracy of two millimeter up to
two meters depending on the location and condition and you can utilize it and use it for example to
decide if an obstacle or something gets closer you can stop your robotic arm smart car or any
other devices for an application that you have this sensor is offered in different modules
something like this or something like this one and also something like this one in blue module
we're going to use it and measure the distance and display the distance on the serial monitor so you
can use it directly with Arduino or we can display it on the lcd 1602 and display 2004 larger one and
also we are going to show you how you can use it on the tm1637 uh four digits seven segment display
the module is offered with h pin here
or with six pen
or even four pins but for our application we are going to use only four pins because this can
measure the distance and you can take action based on the distance that you discover and
your robot could react error depends from the right here as you can see vcc ground scl and
sda these are the main pin that we are using do not connect pin and this is the second ground
this is external shutdown and this is the interrupt and here we have only vn they
have mentioned that here is vcc pay attention vn vcc scl sda clock and data are in the same order
so you can just swap it at any time if you have different modules and here the same
way vcc ground scl and sda and then we have interrupt and x chart and this module also
we have vcc ground scl sda and they call it gpio here and x chart if you use any of
these to measure the distance we just need four pins clock and data and the rest we will not use
on the module they have also voltage regulator so you can use it with 5 volts for with all of
this with this and with this one we have voltage regulator so you don't have to worry you can
connect it directly to 5 volts make sure to remove this shield here the small plastic
otherwise it will disturb the calculation maybe it adds reflection
this is a data sheet VL53L0X
and here are the some of the specs the maximum range is twitter
this is the actual chip that is attached on the module that you see
the sensor size is 4.4 by 2.4 by 1 millimeter very tiny base of the this classification
it's safe for eye diagram of the actual sensor that is on the module and as you can see
it is it is emitting 940 nanometers rays and these are depends on the module but we are not using all
of those and some of them have been used on the module and here is the explanation of these pins
as you can see x shot is for shutdown if you want to shut this down that put this pin
to low and then the rest we are just using sda scl ground and supply voltage here is one pin
entrapment in case if you're using interrupt in some of the modules we see this pin as int or gpio
I’ll provide you the link in case if you need further information from this data sheet
now this is the code for the v53l0x this is the library as a zip file I
have provided download it on your computer and then click on sketch include library
and add zip library point it to wherever you have downloaded and this is an example
of a library select it and click open once you click open go to file
examples scroll down at the bottom alphabetically go to vl530x and this is the file the continuous
that I have opened and I’ve modified it so this is the header file part of the library
and this is the class name this class and we create an instance of that we call it sensor
with the setup we initialize a serial monitor with 9600 baht we initialize the wire dot begin
which is for you for I square c communication sensor.init that is initializing this sensor
that you have created an object so this initializes that and also it sets the timeout
reading takes more than 500 millisecond it will give you information on the screen sensor
dot start continuous will start the continuous measurement inside the loop we use that object
sensor dot read range continuous millimeter this up to here this will read the distance
in millimeter and we store it in a variable called distance and then serial print we print
this text because it's inside double quotation and the distance which we have is a millimeter
we print it here and after that we print the text mm the millimeter this is the one that you see it
and if the sensor timeout occurred then we print this on the screen after all this 3
line we print a new line and there is 100 millisecond delay between the each reading
this is the wiring diagram for vl53l0x this chip with this pink module from the left
vcc is connected using green wire to 5 volts from ground I use blue wire to connect it
to the ground and then clock or scl have been connected to this last pin
a5 and sda the data pin have been connected to a4
if you're using this blue module exactly the same depends on the color or
at the exact location or if you're using this one which has four pins extra pins the
location of the pins are exactly the same as you can see it here and if you're getting this black
module the labels are on the other side make sure to pay attention to the chip and to this
diode and the locations are exactly the same as you see here in this picture
vcc of the module have been connected using the green wire to 5 volts ground
is connected using blue wire to the ground
and then we have scl or clock have been connected using this purple wire to a5
sda is connected using this gray wire to a4 we're using Arduino uno
and then then scls a5 and sdas a4 an Arduino mega sda 20 and then a scl 21 and
the two other prints are left and the wiring is exactly the same
for this module pay attention vcc is on the other side I’m just inserting
it will just work or for this module pay attention to the vcc vccs on this site and
it should be on the other side so for the three the connection is exactly the same
let me now demonstrate the vr53l0x as you can see it shows the distance here and it's running
I have a ruler here and this is the chip this portion let me put the Arduino box
at 10 centimeter or 100 millimeter and put this exactly at the edge in here
and as you can see we are reading 104 103
with a little deviation
but two or three millimeters deviation
other than that it works fine with that module let me just replace it with different module
on this one
as you can see now it's just timeout I have to reset this every time I change it
now it shows if I put this reflective side you will not be able to read properly as you can see
it shows 110 about one centimeter deviation but if I move it in the same location
suddenly you will see you're getting proper value and if I move this 30 centimeter it shows
and now I’m pointing this to the wall it shows 1 meter 119 centimeter now
but if I point it to the ceiling which is beyond the range you see it one nine zero
and this was how to use this vl53r0x laser distance meter thank you for watching