Getting Started with TinyLIDAR Time-of-Flight Sensor on Arduino and Raspberry Pi

TinyLIDAR is an inexpensive and compact board based on STMicro VL53L0X Time-of-Flight (ToF) ranging sensor that allows you to measure distance up to 2 meters using infrared signals, and with up to 60 Hz. Contrary to most other VL53L0X boards, it also includes an STM32L0 micro-controller that takes care of most of the processing, frees up resource on your host board (e.g. Arduino UNO), and should be easier to control thanks to I2C commands.

The project was successfully funded on Indiegogo by close to 600 backers, and the company contacted me to provided a sample of the board, which I have now received, and tested with Arduino (Leonardo), and Raspberry Pi (2).

TinyLIDAR Unboxing

I was expecting a single board, but instead I received a bubble envelop with five small zipped packages.

Click to Enlarge

Opening them up  revealed three TinyLIDAR boards, the corresponding Grove to jumper cables, and a bracket PCB for three TinyLIDAR boards together with headers and screws. So I looks like I received the “3 tinyLiDAR – IGG Special” plus the bracket board that was supposed to be a stretch goal unlocked at $25K (but they only got $23,717). Maybe that’s a good sign for backers, we’ll see.

Click to Enlarge

Due to time constraints, I won’t use the bracket, but only single boards. The brackets can be used with three tinyLIDAR boards using different I2C addresses, and you’ll see an example use with the Follow-me 2 Sketch where the 3 LIDAR boards are mounted on a tilt/pan platform that can track your hand.

Click to Enlarge

The bigger chip on the by is STM32L0 Cortex M0+ microcontroller with the much smaller STMicro VL53L0X laser ToF sensor placed right on top of it on the photo above. There are also a few I/O include the 4-pin I2C Grove connector and through holes, some pogopin for direct UART access, an LED, a reset button, and more, as described in the diagram below.


TinyLIDAR on Arduino

Now, it’s time to play with the board using sample and documentation on a dedicated page.  Refer to this page for the latest versions, as below I’ll link to the versions I used for the review.

To easily evaluate and learn about the platform, the company has made what they call Arduino GUI Terminal sketch to let your control the device from an Arduino board using a serial terminal. https://microelectronicdesign.s3.amazonaws.com/tinyLiDAR_Terminal_GUI_1_1.ino

The company only tested Arduino Uno, but it turns out I don’t have one so I had to use an Arduino Leonardo clone instead, and after initial troubles, and help from my contact at the company (Dinesh), I could use tinyLiDAR_Terminal_GUI_1_24.ino with my boardsince it now supports Arduino Uno, Leonardo, and Mega .If you don’t use Arduino Uno (default), make sure you enable your board accordingly in the code by commenting out the relevant line:


The hardware connections are very easy as you just need to connect the jumper cables to the I2C pins, 5V and GND on the board.

Click to Enlarge

Once this was done I connect a micro USB cable to my computer, and tried to upload the ino sketch file, but it failed to compile. That’s because I forgot to install Arduino I2C Master Library, which can be downloaded here, and you just need to click on Sketch->Include Library->Add .ZIP library, and select the freshly downloaded  I2C_Rev5.zip file to complete the installation. I could then build and upload the program to Arduino Leonardo.

Time to start a serial console using minicom, TeraTerm, Putty or others with 115200 8N1 and no flow control to access the Arduino GUI terminal:


You’ll get a list of command in the terminal, but you may want to read the reference manual to clearly understand each item.

I started with the query command, which worked just fine:


I could also use to read command, but to test accuracy I decided to use a ruler and a small box as shown below.

Click to Enlarge

I tested 5cm and 10 cm:

  • 5cm:

  • 10cm:


Not that good…. But there’s a calibration command as explained in the reference manual:

CD Auto-Calibrate Distance Offset
Perform Offset Distance Calibration on tinyLiDAR.
Before using this calibration command, please set tinyLiDAR to Continuous, High Accuracy mode by issuing
the commands “MC” and “PH”. See example code in Appendix A for details.
ST recommends to use a distance of 100mm to a white target. Therefore, place a white target 100mm away
from tinyLiDAR before running this calibration.
Must specify calibration distance in mm.
The new offset correction distance will be placed in non-volatile memory and used for all subsequent
operations. This calibration takes about 10 seconds to run and the LED will flash slowly during the calibration.
You can reset to our factory defaults by executing the “RESET” command.

So let’s go ahead by placing the board at 10 cm from a white box (OK mine was not exactly white), run MC and PH commands (although it does not look necessary),  before running running CD without parameter to do the actual calibration:


Let’s go back to single step operation (ms) and tinyLIDAR preset (pt), and try the measurements again

  • 5cm:

  • 10cm:


It’s getting better, although the first two steps always seen to be stuck to some previous measurements. I’ve been told it may be due to some buffer in the serial terminal.

Trying some longer distances:

  • 20cm:

  • 30cm:


It’s basically doing the job. If you need more accuracy, longer range, or faster measurements, you can change the mode:

  • PL: long range mode (up to 2m, 33ms)
  • PS: high speed mode (up to 1.2m, 20ms)
  • PH: high accuracy mode (up to 1.2m, 200ms)
  • PT: tinyLiDAR mode (up to 2m, 18ms)

One interesting feature, especially if you run on batteries, is the autonomous mode where the board is configured to automatically check the distance range every X second, and trigger a pulse when within range, without having to send I2C commands from the host, except the initial one. In the Arduino GUI terminal, you can for example run:


From there, you won’t show anything in the Arduino terminal, so you can either monitor the autonomous pin – as shown in the diagram below – with the host board or a multimeter…

… or instead you may consider soldering GND and serial TX pins on tinyLIDAR board, and access the read-only console use a USB to TTL debug board as shown below.

The terminal needs to be set to 115200 7N1 without flow control, and you’ll should an output similar to the one below when you run the A command above:


Just to be extra clear, at this stage I have two serial terminal in my computer:

  • /dev/ttyACM0 connected to Arduino where I can input commands
  • /dev/ttyUSB0 connected directly to tinyLIDAR where I can see debug output (read-only)

If you want to integrate it into your own program, you’ll have to send commands as shown by the Arduino sketch to read distance:


The code above is for Arduino Uno, so if you use Arduino MEGA or Leonardo you’ll need to change the PORT to PORTD, and SCL and SDA to pin 0 and 1 respectively.

TinyLIDAR on Raspberry Pi 2/3

Arduino is cool, but if your project is better suited to Raspberry Pi board, you can also connect tinyLIDAR to the I2C port of Raspberry Pi 2/3, or any other Raspberry Pi boards. The instructions are explained in details on Instructables, also explaining some of the shortcomings of I2C on Raspberry Pi board (lack of clock stretching support, pull up resistors installed). The steps are very details, even suitable to people having never used a Raspberry Pi, so here I’ll go faster focusing on settings specific to tinyLIDAR use.

First you need to scratch the I2C PCB trace on tinyLIDAR with a cutter to disconnect the pull-up resistors since it’s already done on the Raspberry Pi board. Now we can connect tinyLIDAR to the I2C pins, as well as 3.3V and GND.

I used the same Raspbian Stretch Lite image with SSH enabled (/boot/ssh file present) as I did for ANAVI Light pHAT. Now we need to install pigpio in Raspberry Pi as follows:


You’ll also need o run raspi-config to enable I2C.

The next step is optional, but I still recommend it as at the beginning I had trouble finding tinyLIDAR. That’s the step to detect tinyLIDAR I2C address:


We can see 0x10 I2C address is detected, and that’s our tinyLIDAR board. If you don’t have any addresses detected, re-check your connections.

Now that we have confident the hardware is OK, we can install “RPI TinyLIDAR Terminal GUI”:


and launch it with:


From there, it’s the same as in the Arduino terminal GUI, for example read and query commands:


Again the RPi terminal GUI is just for evaluation, but you can study the Python in order to integrate support for tinyLIDAR into your own Python application.

That’s all for this getting started guide.

The crowdfunding campaign is now over, but you can buy TinyLIDAR board directly on MicroElectronic Design website for $24.95.  You’ll also find the bracket board for $4.95 and a pack of 100 mounting screws on that page. Further details may also be found on the product page.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard

8 Replies to “Getting Started with TinyLIDAR Time-of-Flight Sensor on Arduino and Raspberry Pi”

  1. @malem
    Unfortunately FoV won’t be changing – I asked ST about this, and the reason for the wide FoV is to keep it eye safe – a more concentrated beam would require appropriate warnings and eye protection. Also, wider beam is probably better for its primary use as a prox detector on smart phones (which brings volume way up and prices down for the rest of us).

  2. if you use a pi or any other descent contoller you can better buy a standalone VL53L0X I2C board on ebay for like 4€

  3. Nice work 🙂

    Just like Jeroen, I am questionning the concept of this board that basically add a STM to interface the VL53L0X , that we can otherwise easily connect directly to an Arduino or RPI usingI2C and existing libraries at 1/6 the price …

  4. I’m with Jeroen and Patrick, I’ve used this sensor on a couple projects and I don’t understand adding an I2C interface on top of an I2C interface that the part has; and worse it seems there Firmware is buffering stuff badly; for RPI, ST already provides a complete stack to talk to the sensor; (It is a pain to hack up to use on a microcontroller; but it has been done)

  5. @TonyT

    Yeah I thought as much. Don’t get me wrong it’s great at what it does, I just can’t help but imagine the cool things you could.

    I’m wondering if you could restrict the view of the photo diode using some kind of focus. Accuracy and speed would probably suffer but it might just be good enough.

Leave a Reply

Your email address will not be published. Required fields are marked *

Khadas VIM4 SBC
Khadas VIM4 SBC