Prerequisites
If not already done so already, install Arduino software and make basic connections, as described in page for MRMS ESP32: Arduino, IMU, eFuse, BT, WiFi, CAN Bus (mrm-esp32). This setup is convenient, but it is not mandatory. You can connect some other microcontroller and power supply.
This setup is necessary for the rest of ML-R system. If You want to try just this example, don't copy all the libraries but only directory "mrm-lid1". It provides access to this sensor for ESP32 microcontroller, or for any other Arduino compatible.
Task
We will use this sensor to measure distances. The sensor will be connected to the microcontroller using I2C bus.
Pinout
Connections
Starting from the basic connection, let's add 2 ML-R LIDAR 2m VL53L0X (mrm-lid1). 3.3 V supply can be made using cables with Dupont 0.1" plugs. SCL and SDA use single wires with 0.1" Dupont plugs. We need another single Dupont cable per sensor for shutdown operation.
This setup is for MRMS ESP32: Arduino, IMU, eFuse, BT, WiFi, CAN Bus (mrm-esp32). However, You can use any other microcontroller that supports I2C bus. Just find 3.3 V power supply, locate SDA and SCL pins, and connect them in a similar way as here. Note that You have to use pull-up resistors, the ones that are already built in mrm-esp32.
Connections
Starting from the basic connection, let's add 2 ML-R LIDAR 2m VL53L0X (mrm-lid1). 3.3 V supply can be made using cables with Dupont 0.1" plugs. SCL and SDA use single wires with 0.1" Dupont plugs. We need another single Dupont cable per sensor for shutdown operation.
This setup is for MRMS ESP32: Arduino, IMU, eFuse, BT, WiFi, CAN Bus (mrm-esp32). However, You can use any other microcontroller that supports I2C bus. Just find 3.3 V power supply, locate SDA and SCL pins, and connect them in a similar way as here. Note that You have to use pull-up resistors, the ones that are already built in mrm-esp32.
Program
#include <Wire.h>
#include "mrm-lid1.h"
VL53L0Xs lidars;
void setup()
{
Wire.begin();
Serial.begin(115200);
delay(500);
lidars.add(33, 0x30);
lidars.add(25, 0x31);
lidars.begin();
lidars.test();
}
void loop(){}
void error(String message){
Serial.println(message);
while(1);
}
Here is a simple code.
In the beginning, we include the downloaded library, then define object "lidars". setup() starts I2C and serial connection to PC.
Another 2 instructions in setup(), lidars.add(), start one sensor each. First argument is sensor's shutdown pin. The second one the new I2C address. VL53L0X chips use the shutdown pin to turn off all sensors, then wake up one by one, changing each one's I2C address. In that way many of them can coexist in the same bus.
The last command, lidars.test(), is the place where action is. You should read mrm-lid1.cpp to see how it accesses sensors hardware. Program will continually display 2 distances in mm.
This code is short, but the details are hidden in mrm-lid1 library. Browse its header (mrm-lid1.h) header in order to learn what other functions are available and how to use them.
Limitations
Some pins are not available or are limited in usage. Check this list.
Alternative connection
Dupont žicama spojite LIDARe na mikrokontroler. Minimum su 4 žice SDA, SCL, 3V3 i GND, kad udaljenost mjeri samo jedan LIDAR. U primjeru se koristi pločica
ML-R I2C 3V3 5V Distribution Pins (mrm-distrib-a), njena 3.3V I2C sabirnica.
Skinite https://www.github.com/PribaNosati/MRMS Arduino
kod.