Kosakola ya VL53L0X ya mosika na Arduino
Na boyekoli oyo, tokotalela ndenge ya kosalela VL53L0X laser distance meter na Arduino. Esengeli oyo esaleli ekeseni na ndenge ya komeka bopemi na nzela ya laser, oyo esalaka ekeseni mpo na misala ndenge na ndenge lokola robotiki mpe automatisation. Na suka ya boyekoli oyo, okozala na esaleli oyo ekoki komeka bopemi mpe kolakisa yango na serial monitor.

Mpo na proje oyo, tokosalela bibliothèque ya Adafruit VL53L0X, oyo esalaka ekeseni na ndenge ya kosangisa na senseur. Bibliothèque oyo epesaka misala oyo esengeli mpo na kobanda senseur, kotanga bomekelo, mpe koyamba ba erreurs oyo ekoki kobima. Okoki kotala vidéo mpo na bokambi ya visual na mise en place (na vidéo na 02:15).
Hardware Explication
Ba composants ya liboso ya proje oyo ezali na VL53L0X laser distance meter mpe carte Arduino. VL53L0X ezali senseur ya temps de vol oyo esalelaka laser mpo na komeka bopemi kino na mètres 2 na précision ya likolo. Esalaka na nzela ya protocole I2C, oyo esalaka ekeseni na communication na Arduino.
Carte Arduino ezali lokola microcontrôleur oyo esalaka na ba données oyo ewuti na VL53L0X. Esengaka na senseur mpe ezwaka bomekelo ya bopemi, oyo ekoki kolakisa to kosalela na ba applications mosusu. Câblage ya malamu ezali moko ya makambo ya ntina mingi mpo na kozwa bomekelo ya solo.
Détails ya Datasheet
| Fabricant | STMicroelectronics |
|---|---|
| Numéro ya partie | VL53L0X |
| Tension ya fonctionnement | 2.6 V kino 3.5 V |
| Étendue | 30 mm kino 2000 mm |
| Précision | ±3% ya mbala mingi |
| Interface | I2C |
| Étendue ya température | -40 °C kino +85 °C |
| Consommation ya courant | <1 mA (standby), 20 mA (actif) |
| Paquet | VFLGA-8 |
- Kokamba ete senseur ezali na courant ya malamu (2.6 V kino 3.5 V).
- Kobatela ba adresse I2C ya malamu mpo na kokima ba conflits.
- Kobatela senseur ya peto mpo na bomekelo ya bopemi ya solo.
- Kosalela ba résistances ya pull-up na ba lignes I2C soki esengeli.
- Kokima mwinda ya moi na senseur mpo na kozwa ba résultats ya malamu.
Instructions ya Câblage

Mpo na kosangisa senseur VL53L0X na Arduino, sangisa pin VCC ya senseur na pin 5V na Arduino. Pin GND esengeli kosangisa na terre (GND) ya Arduino. Mpo na communication I2C, sangisa pin SDA ya VL53L0X na pin A4 na Arduino, mpe sangisa pin SCL na pin A5. Soki ozali kosalela modèle mosusu ya Arduino, tala ba assignations ya pin SDA mpe SCL mpo na carte yango.
Na ndakisa, na Arduino Mega, okosangisa SDA na pin 20 mpe SCL na pin 21. Komeka ete ba connexions nyonso ezali ya makasi mpo na kokima ba problèmes ya communication. Soki senseur eyanoli te, tala lisusu câblage mpe komeka ete Arduino ezali na courant ya malamu.
Ba Exemples ya Code & Explication
Na nse, oyo ezali mwa ndambo ya fonction setup oyo ebandisaka senseur VL53L0X:
void setup() {
Serial.begin(9600);
while (! Serial) {
delay(1);
}
Serial.println("Robojax Test");
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
}
Code oyo ebandisaka communication ya série mpe emekaka kobanda senseur VL53L0X. Soki senseur elongwe te, ekokoma message ya erreur mpe ekosukisa programme.
Na sima, oyo ezali mwa ndambo ya fonction loop oyo etangaka bomekelo ya bopemi:
void loop() {
VL53L0X_RangingMeasurementData_t measure;
lox.rangingTest(&measure, false);
if (measure.RangeStatus != 4) {
Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
} else {
Serial.println(" out of range ");
}
delay(100);
}
Bloc oyo etangaka mbala na mbala bomekelo ya bopemi na senseur mpe elakisaka yango na serial monitor. Soki bomekelo ezali na libanda ya étendue, elakisaka yango na ndenge ya malamu.
Démonstration / Nini Okomona
Ntango okosalela programme, okomona bomekelo ya bopemi elakisami na serial monitor. Ba lectures esengeli kobongwana na mbala na mbala na 100 millisecondes. Soki senseur ezali kolakisa na objet, ekolakisa bopemi na millimètres. Soki objet ezali na libanda ya étendue, ekolakisa yango mpe. Komeka senseur na kati ya étendue na yango mpo na ba résultats ya malamu (na vidéo na 10:00).
Ba Timestamps ya Vidéo
- 00:00 - Introduction
- 02:15 - Mise en place ya câblage
- 05:30 - Explication ya code
- 10:00 - Démonstration
/* This example shows how to use continuous mode to take
range measurements with the VL53L0X.
// Original source from Adafruit https://github.com/adafruit/Adafruit_VL53L0X
// Modified by Ahmad Shamshiri for RoboJax.com
// Date modified: Sep 26, 2017
// Nejrabi
* Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in a structured course with all material, wiring diagrams, and libraries
all in one place.
If you found this tutorial helpful, please support me so I can continue creating
content like this.
or make a donation using PayPal http://robojax.com/L/?id=64
* * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been downloaded from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Copyright (c) 2015, Majenko Technologies
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* * Neither the name of Majenko Technologies nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Adafruit_VL53L0X.h"
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
void setup() {
Serial.begin(9600);
// wait until serial port opens for native USB devices
while (! Serial) {
delay(1);
}
Serial.println("Robojax Test");
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
// power
Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}
void loop() {
VL53L0X_RangingMeasurementData_t measure;
Serial.print("Reading a measurement... ");
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
if (measure.RangeStatus != 4) { // phase failures have incorrect data
Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
} else {
Serial.println(" out of range ");
}
delay(100);
}
Nko o na nki.
-
AmazonPurchase VL53L0X from Amazonamzn.to
-
eBayPurchase VL53l0x from eBayebay.us
-
AliExpressPurchase 1 to 10 pcs of VL53L0X from AliExpresss.click.aliexpress.com
Mokili na bisika
-
L'extérieurArduino Library (GitHub)github.com
-
L'extérieurPurchase 1 to 10 pcs of VL53L0X from AliExpresss.click.aliexpress.com
-
L'extérieurPurchase VL53L0X from Amazonamzn.to
-
L'extérieurPurchase VL53l0x from eBayebay.us
-
L'extérieurVL53L0X datasheet (PDF)st.com
-
L'extérieurVL53L0X datasheet (PDF)st.com
Fichiers📁
Fritzing File
-
Adafruit VL6180X Time of Flight Distance SensorFritzing part for the Adafruit VL6180X Time of Flight distance sensor. This sensor measures absolute distance up to 100mm and ambient light, communicating via I2C. Includes the sensor breakout board and pin connections for use in Fritzing projects.
Adafruit VL6180X Time of Flight Distance Sensor-1.fzpz0.02 MB
Mabala a mangwe
-
Polou VL53L0X maktaba
robojax-VL53L0X-polou-arduino-master.zip0.02 MB