Accéder au contenu principal
Publicités

Measure distance using VL53L0X ToF LASER Range sensor + Arduino + OLED (mm/cm/in)

A video tutorial if needed

 

                  Hi, this tutorial is about distance measuring using the GY-VL53L0X ToF sensor, with Arduino Uno board, we’ll go through a test then a little project using an OLED screen and a pushbutton to measure in different units (Metrics, Imperial).

 So the sensor uses the ToF (Time of Flight) technique, it sends a LASER beam to the target and as long as it’s in the range, the LASER reflects back and get detected by the sensor, the duration between emitting and receiving is measured, the velocity is already known (approx = c, speed of light, and if there’s a mistake, a calibration is always possible), then we can calculate the distance, Distance = Velocity * Time.

time-of-flight-principle.png
Source https://www.terabee.com/time-of-flight-principle/

One of the advantages of the ToF method, is that it can achieve higher ranges, of course depending on the module used, here as usual we’re using 2-3$ ones, but it’s a very precise module thanks to the fine LASER used, not like the Ultrasound modules, or IR ones, that spreads a wide wave, and can mislead the readings, but they have their own useful applications though.

Range and accuracy

The module’s range depends on the surface colour and the mode, there are two modes: default one (we’re using) and the long range one, in the default mode it can handle up to 1200mm (1,2m ; 40 in).

table.png
Source https://www.adafruit.com/product/3317

Parts

So for this project, alongside some jump wires we’ll be using

The module is actually very small, around (1.5cm by 1cm) very useful for small applications like ToF10120

Wirings

Wiring 1
Wiring for direct test, we use the i²c interface so SDA/SCL with A4/A5

 

Wiring 2
Introducing an OLED screen and a push button to be able to switch between units

Libraries

  • VL53L0X library: Download here Adafruit VL53L0X library
  • OLED libraries: –  Download here  Adafruit OLED SSD1306 library                                                               –  Download here Adafruit GFX Library

 

Codes

  • The first code I tried is a library example, you’ll find one that uses the OLED too
  • The second code that uses the OLED and button you can download it here

 

Tests

First test with Serial monitor

Test_1
Distance measured and shown in mm

 

Test_2
If the target is out of range

Second test using OLED + push button

The strange part here, is that I couldn’t write some sentences in the OLED screen, like as Out of range, I just wrote OoR, I wanted to add « distance » while measuring but couldn’t too, the whole OLED goes black, also there are some strange spotson the bottom right, if someone can explain please welcome. Otherwise here are the results:

test_4.jpg
Out of Range case
Test_5
Displaying in mm
Test_6
Press the button to switch to cm
Test_7
Press again to switch to inches, and again to go back to mm

You can of course add or remove units as you want, it’s simple. Check the video tutorial if you need help, or want to see the demo.

Publicités

Yassine Tout afficher

Electronics, Automation engineering student... I try to share my little experience with other electronics amateur.

Répondre

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Google

Vous commentez à l'aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s

%d blogueurs aiment cette page :