Minimalist LiDAR

LiDAR assembled.png

A long weekend is the perfect chance to release the InneR GeeK, so this time around I built a one degree of freedom LiDAR, using a breakout board of the compact GY-530 Time-of-flight ranging sensor, which is absolutely minuscule.

Let’s start with the “ingredients”:

  • Arduino Nano (or any other, really)
  • SSD1306 OLED screen
  • VL53LOX breakout board
  • Servo (micro servo such as the sg90 is perfect)
  • 3d-printed parts (you can pick-up the STL files at the Minimalist-LiDAR Thingiverse repository)

The cabling is straightforward. You connect:

  • The OLED screen and the VL53LOX board’s GND, SCL and SDA pins (I2C) to the Arduino’s I2C pins;
  • The servo signal cable (yellow) to a digital pin (used D5);
  • The GND and 5V of the servo, OLED and VL53LOX to a 5 Volt external power source;
  • The GND of the Arduino to the GND of the external power source (if you miss this step the servo won’t budge or will move erratically).

Using the VL53LOX is straightforward. You initialize it with a few lines:

#include "Adafruit_VL53L0X.h"
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
VL53L0X_RangingMeasurementData_t reading;

And you take a reading using:

lox.rangingTest(&reading, false);

To access the measured value, use:

measurement = reading.RangeMilliMeter;

The hard part of the project was shrinking the code down so that it would fit the Arduino Nano’s small memory. Here are some tricks I used to reduce the code size and get it to upload and run properly:

  • Started using the <Adafruit_SSD1306.h> library to draw on the OLED screen but had to replaced it with the <U8g2lib.h> to save space;
  • Used #define for constants
  • Used byte instead of int
  • Used float instead of double
  • Calculated screen position to servo angle relations offline and loaded the results into arrays
  • Exhaled before compiling (sort of 🙂 )

Captura de Tela 2018-05-16 às 00.09.00It finally worked, but if you want to replicate this I suggest you use an ES32 or some other board with more memory.

You can download the code at the Github repository for the project

Feel free to comment, suggest, tip or provide any other kind of feedback. That’s what sharing is all about!

Leave a Comment

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.