Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

instructables

Project Lighthouse - 360° Mini Arduino LiDAR

by Daniel Hingston

Update 13/02/21: Since the initial release I have updated step-by-step of the build, as well as footage of the
the LiDAR code to improve the performance! Please see testing! The Instructables guide should then give you all
Step 8 of this Instructable for a video and the updated les. the details you need to reproduce the project yourself.
The video also shows a lot more test examples, and tries to
explain more detail of how the LiDAR performs. Thank you
very much for your feedback and comments so far, it has
been interesting to read them ~
https://www.youtube.com/embed/uYU534Wn4lA

In this Instructable we're going to build a budget


spinning LiDAR sensor, powered by Arduino. It cost less
than £30 to build ($40) and has a diameter of only 30mm
Safety: There are some sources of risk, from the use of hot
(1.18"). It uses two sensors, diametrically opposed to
3D printers and soldering irons, but otherwise low voltages
each other, to double the scanning rate, and is suitable
are used throughout, and the VL53L0X sensors do not
for mounting on top of a small robot. All parts are 3D
produce a laser which is harmful to the eye. Parental
printed and are suitable for small 3D printers too.
supervision is encouraged if appropriate, but please be
exercise care and use eye protection when needed.
Please have a watch of the video summary to see a

Step 1: What You Will Need

LiDAR 'Lighthouse'

Project Lighthouse - 360° Mini Arduino LiDAR: Page 1


2x VL53L0X TOF Distance Sensors
MT3608 DC-DC Boost Converter
MX1508 DC Motor Driver
8-Way Molex PCB Connector (Female)
N20 6V Motor (Micro Metal Gearmotor) - 60 RPM
6-Wire Capsule Slip Ring
M2.5x12 Screw + M2.5 Nut

Test Base Station 'Lighthouse Keeper'

Arduino Uno
USB Cable
5V 1A Wall Plug
8-Way Molex PCB Connector (Male)
7x Header Pins
4x M3x12 Screws + 4x M3 Nuts

Consumables

Lead-free Solder
Heatshrink (not necessary but desirable - can use electrical tape instead)
Electrical Insulative Tape
Glue (CA superglue would be suitable)
PLA Filament for the 3D Printer

Software

A PC, running;
Arduino IDE
Processing - a graphical library, we'll use it to show the sensor output on the PC
CAD software, e.g. Autodesk Inventor - if you wish to modify the 3D printed parts
Slicing Software - as you use to set up les for your 3D printer

Tools

3D Printer
Screwdriver
Soldering Iron, Wire Strippers, Side Cutters
Craft Knife, File

Project Lighthouse - 360° Mini Arduino LiDAR: Page 2


Step 2: Design

Plastics (and 3D printing) are what makes this project possible! The plastic we use is PLA (polyactic acide, a starch-derived
plastic commonly used for 3D printing lament). FDM (fused deposition modelling, the fancy way to describe the
lament type printing used in most amateur 3D printers) is an amazingly low-cost way to be able to create high quality
and low cost components, without which we couldn't do this! Making these components another way would be
undeniably slower, trickier, and more expensive. The 3D printer I use is an Anet A6, a low cost machine, but more than
capable of projects like this one.

The Design
The key drivers in my design were:

Low cost - the total price of the components should be as low as possible.
Minimal size - a focus on maintaining the smallest dimensions possible.
Performance - a near 360° coverage and fast scanning rate.

Basic and widely-available components are used throughout, and cost is minised by the omission of any form of encoder.
This would be use to measure the rotational angle of the scanning head. Instead, a pillar is within the scanning arc of the
sensors; from this the rotational angle of the head can be calculated by recording when the sensor detects the presence
of the pillar, and then calculating the rotational speed and hence angular interval between distance measurements.

A 'slip ring' is a component that allows an electrical connection to be made through a spinning interface, and we use a 6-
wire capsule slip ring to take the connections from the two sensors down into the body of the LiDAR tower. By relocating
the slip ring to above the spinning head, and then using the pillar to route the wires down into the tower, a very simple
layout is created, which utilises a small number of components.

Why a LiDAR?
I've wanted to make a spinning distance sensor for a few years since I worked on some basic wheeled robots. I didn't
have the ability to design one then, but I've toyed with the design more and more in the last few months, and decided to
at last make it happen!

Previously I've used basic xed ultrasonic (HC-SR04) and IR (Sharp series) sensors for distance sensing, but never a
spinning sensor before. The commercially available spinning LiDAR sensors are quite expensive for me, so I wanted to try
and develop a basic one for a very minimal cost. If successful, I planned to use this sensor for navigation of small robots,
as well as room mapping.The VL53L0X sensors I chose to use have a wavelength of 940nm, invisible to the human eye
Project Lighthouse - 360° Mini Arduino LiDAR: Page 3
but a smartphone camera will show a bright ash!

There are some very good YouTube videos on similar projects that I found inspiring, in particular this video by
Electronoobs.

3D View!
It may take a moment to load, but I included this Tinkercad 3D view so you can look at the model yourself:

https://www.tinkercad.com/embed/74WRqAtGZHi?editbtn=1

Step 3: 3D Files and 3D Printing

Project Lighthouse - 360° Mini Arduino LiDAR: Page 4


The Files 3D Printing
You can download all of the CAD les from the Grabcad There are only 4 printed parts in the Lighthouse tower,
Library I've created here. This contains .stl les, ready for which should be printed in the orientations shown.
you to export to your slicing software and be printed! Quality should be maximised as far as possible, I used
There are also the project les in .step format. These will 0.1mm layer height and a very slow print speed.
be what you need if you want to use your own CAD
software to modify the design in any way, or just to Clean up the parts using the side cutters, le, craft knife
adjust the ts and tolerances to suit your components or and test t the key components to make sure that
printing quality. everything ts comfortably. You'll nd that most
components are a little loose, this is deliberate - I use
If you'd like to modify the design, you'll need to use thin pieces of masking or electrical tape to create a nice
some CAD software. If you're not familiar with that, it's a push t - it's easier to make ts tighter than to make
really useful skill to learn as a maker that will no doubt them looser!
be useful for lots of future projects! I use both the free
version of Autodesk Inventor, which is really easy to In the rst photo you can see the RPi V2 camera I used to
learn as a beginner and is very user friendly, and also the record the timelapses of the printing for the video, as well
educational version of Creo Parametric which is another as the lamp that helped illuminate the prints for the
similar program - there are others too. photos.

Project Lighthouse - 360° Mini Arduino LiDAR: Page 5


Step 4: Electrical Schematic and Soldering

Schematic them out of the inside of the cap. This is certainly the
Please have a look at the attached schematic to see how hardest part of the build so at least you get it over and
this side of the project is done. It's relatively done with rst...
straightforward - it is split into the 'lighthouse' and
'lighthouse keeper', in other words the tower and the Slip Ring
base station. An 8-way connector provides an interface Now trim the wires of the slip ring as shown, and solder
for power and data between the two. onto the exposed wires from the cap. Take a multimeter
and identify which coloured wire matches which wire
Sensor wires through the conduit ending, I then attached a little piece of masking tape
The 'cap' part contains a narrow channel down the long noting which colour cable each wire related to. This will
stem, which is designed to t six thin wires as shown. be handy when you come to making the other
These were a real challenge to t - I modi ed the 3D le connections later.
that's attached to this Instructable to widen the hole
that the cables come out from to make it easier for you (I Lastly get the slip ring glued into the cap, and hold it in
had to widen mine with a Dremel!). I found it easiest to place until the glue is set. The lower half of the slip ring
push the bunch of six together down the channel, and with its cables should rotate round easily.
then use a bent paperclip with a hooked end to sh

Project Lighthouse - 360° Mini Arduino LiDAR: Page 6


Step 5: Tower Assembly

Project Lighthouse - 360° Mini Arduino LiDAR: Page 7


Motor the pictures, you should be able to do this with a neat
Solder on a pair of short wires as shown onto the motor little length of wire for each.
contacts, and t it into the motor holder within the
'carriage' printed part. I needed to wrap the outside of Molex PCB Connector
the motor casing in a few turns of masking tape to take To make it easier to route, use some pieces of tape to
up some spare room and ensure it was a tight and gather up the cables that come from the cap. The Molex
wiggle-less t. PCB connector you bought should have lots of little pins
like those shown in the pictures, and you'll need to
Motor Driver Board solder our wires to those for each of the six data lines,
Slot the MX1508 driver board into place and check the plus the +5V and GND lines. Make sure you leave
t. You may need to add a little masking/electrical tape enough length that the cables reach more than a few cm
up the sides of the board to hold it tightly in the slot that (+ 1") from the edge of the connector aperture where
is designed for it. Remove it from the carriage again, and the Molex connector will sit - otherwise they will be too
cut the motor wires to length and solder in place onto short and too di cult to work with. Too long though and
the 'Motor A' contacts. You can now also solder on two you won't be able to t the spare cable inside the casing
lengths of wire (not less than 10cm/3") to the IN1 and when you try and close it later!
IN2 contacts, that will be used to control the motor
driver. Slot the board into its place as shown in the Note that you'll need to have two wires going to the +5V
photo. pin (one from the cap bundle of wires, and one from the
boost converter) and two to the GND pin also. Little
Boost Converter Board pieces of masking tape again can help you remember
Next up is the MT3608 DC-DC Boost Converter! Before which pin relates to what wire to make sure you t the
installing in the carriage, attach (solder) the VIN+ and pins into the Molex connector housing in the right order.
VIN- contacts to the wires of a USB cable to a 5V USB wall You should feel a small 'click' when you push each
supply, and adjust the output voltage (by the little soldered pin into the housing, and this will retain it
screw) to make 6V. Unsolder those leads again, and securely. Finally push the connector housing back into
return the bare board to the carriage. Again check the t the carriage, to sit ush with the edge.
of this into the slot that is designed for it, and add tape
to take up spare room if necessary. Now attach lengths
of wire to the VIN+ and VIN- contacts, and from the
VOUT+ and VOUT- contacts make a connection to the +
and - contacts of the motor driver board. As shown in

Project Lighthouse - 360° Mini Arduino LiDAR: Page 8


Step 6: Sensor Head & Tower Assembly

Project Lighthouse - 360° Mini Arduino LiDAR: Page 9


VL53L0X Wiring place. If not, add a little electrical tape along the edge of
Solder short lengths of wire as pictured to each VL53L0X the board to increase the tightness of the t. Push both
board, with the leads on the opposite side than the VL53L0Xs into place, and then gently pack the
sensor itself. You want to connect the wires to VIN, GND, protruding wires down into the void between the two
SDL, SCA, and X (that wire not pictured). boards.

Each VL53L0X has 5 wires connected, so 10 total - Tower Assembly


however the slip ring interface that these must pass Now you're ready to assembly the tower! It's a little
through only has 6 wires! How does this work? ddly as the tower is so compact, (an extra arm is
recommended if you have one) but if you watch the
The answer is that the VL53L0Xs share VIN (5V), GND, video (in the rst step of this Instructable), you'll see the
SDA, and SCL. Twin these wires together between the technique needed. The process is also shown by the nal
two boards, and then solder each one of these to one of four images above - it's a case of sliding the carriage into
the slip ring wires (cut appropriately short as shown). the tower, whilst aligning the sensor housing and cap.
The 'X' wire from each VL53L0X must each be connected Don't screw the M2.5 screw in the tower in too forcefully,
to a unique slip ring wire. as you'll distort the carriage piece within the tower's
walls, and this will place strain on the motor shaft and
Assembling the Sensor Head cause misalignment.
Test the ts of the VL53L0Xs into their holders inside the
printed head part. This should be tight to hold them in

Project Lighthouse - 360° Mini Arduino LiDAR: Page 10


Step 7: Base Station - the 'Lighthouse Keeper'

The LiDAR is designed to be mounted onto any kind of PC connection, but it is important to join the GND pin of
small robot, but for testing I designed this small base the Arduino to the input Ground line from the wall plug.
station. It houses an Arduino Uno, and the interface to a
5V wall supply, as well as an 8-way male Molex Solder up the other lines to the Molex connector, and
connector to interface to the 'Lighthouse'. It represents shroud in insulation tape like shown. Make sure you
the power supply and control interface of a generic have double-checked for shorting, and make sure your
robot, and for testing allowed me to develop the LiDAR's pins on the base station connector match the pins on
code and test the function. the lighthouse tower!

It is printed in two parts, a base, and a lid, which are The connector plugs into the female connection of the
joined with 4x M3x12 bolts and nuts. The Arduino is tower as shown, which then sits snugly on top of the
friction- tted into the base. I use a 1m-long USB cable to base station. We're ready for programming now, so
provide power from a 5V 1A wall plug. Cut this wire please read on.
open, and select the red 5V and black Ground lines as
shown. The Arduino will draw its power over the USB to

Project Lighthouse - 360° Mini Arduino LiDAR: Page 11


Step 8: Programming

Project Lighthouse - 360° Mini Arduino LiDAR: Page 12


Update 13/02/21: Since the initial release I've spent some and use/modify them yourself. Please ask in the
more time improving the code. The new, updated les are comments if you have any questions!
those attached to this step, so please download and use
these. I also made the video, below, to explain what has Upload the Arduino program to the Arduino in the base
changed since the rst release, and to show you more station. With the Arduino connected to your computer,
testing examples! initiliase the Processing software. 'Run' the processing
program attached, and it will initialise a black
rectangular full-screen window with a small white circle
in the centre. The small circle represents the diameter of
the sensor itself, while the larger circle represents the
https://www.youtube.com/embed/pXrdX9ed9Vg
maximum range of the sensor as set/limited by the
Arduino code.

The motor will begin to run, and will complete


The full Arduino program is attached to this section of
approximately 10 rotations. This is a calibration stage in
the Instructable. Please download this and make sure
which it measures the rotational speed of the motor, and
you also install the "Adafruit_VL53L0X.h" library.
calculates how many readings it will take per revolution.
This information is later used to ascribe a particular
Also attached is a Processing program. Processing is an
angle to each distance measurement taken, in
open-source graphical library, and we're going to use
increments.
this to visually display the LiDAR output on a computer
screen. It takes the Arduino data returned to the PC via
After the calibration is complete, small dots will begin to
Serial communication, and presents this as a graphical
appear on the screen, showing where the LiDAR is
plot that shows the data being returned.
sensing objects in its vicinity. Read the next step for
more testing information!
Both programs are annotated to explain the function of
all aspects of them so you can more easily understand
Download

https://www.instructables.com/ORIG/F6E/SWNK/KL2AZOJY/F6ESWNKKL2AZOJY.ino

Download

https://www.instructables.com/ORIG/FXH/893Q/KL2AZOCR/FXH893QKL2AZOCR.pde

Step 9: Static Testing

To test the LiDAR's function, I used a large cardboard how well the sensor was performing - it was quite
box as shown to create a controlled environment for pleasing results. You can also see at the bottom of the
taking the readings. This meant that the expected images where there is a cone-shaped segment (about
picture that the LiDAR would see would be very simple, 40°) which is the portion of the view that is obscured by
and make the results easy to interpret, compared to the LiDAR tower's pillar.
looking at a whole room for instance!
Compared to a basic xed sensor for instance, it was
By placing small objects like the smaller ( lament reel) exciting to be able to record this level of detail - whilst
box shown into the eld of view of the sensor, we can pretty basic it is still a big step up and I am really keen to
see in the test results how it was successfully able to try testing it as part of a small wheeled robot next, but
detect the position of the object. I have overlaid images that'll have to be another project ...
of the box on top of the corresponding test results to see

Project Lighthouse - 360° Mini Arduino LiDAR: Page 13


Step 10: Conclusions

Update 13/02/21:I updated this section following the code update (see Step 8!)

Overall this has been very interesting project to build, and it's gratifying that the initial results are quite promising.
There's a lot more that could be developed with it, but it's exciting that it's already capable of simple mapping of its
environment.

There are some things that I'd like to do a bit better if I were to design another sensor:

1. Look at ways to reduce the time interval required to read the sensors. In the initial release it took more
than 100ms to do a read cycle. Following the code update (see Step 8), I managed to reduce this to 57ms,
allowing much more data to be recorded per rotation. I think the VL53L0X is now the main limiting factor,
not the code, the Arduino or the rest of the Project Lighthouse hardware, as the sensor is limited to 20ms
as a fastest possible read time, and this project uses two of them. The only way I can think of accelerating
this further is possibly by having both sensors controlled independently by separate Arduinos (Pro
Minis?) that then pass their data to a central controller, this way they could record their data in parallel,
rather than each sensor one after the other ...
2. More complex data-recording. I think a more complete picture of the surroundings could be built up by
adding a small time delay between the recordings of each successive rotation - this would have the e ect
of o setting each rotation's data-set by a few degrees. After a number of rotations this could have the
e ect of building up much denser data than the small number of angles that I currently record data for.
3. I am aware that currently the code doesn't account for the rotation that occurs between the reading of

Project Lighthouse - 360° Mini Arduino LiDAR: Page 14


the 1st and 2nd ToF sensors - this was a deliberate simpli cation, but would be an interesting aspect to
try and account for in the code.

So thank you very much for reading, and if you're interested in making one yourself I hope it gives you a fun and
rewarding project.

Well written!
From the www:
"The VL53L0X is a new generation Time-of-Flight (ToF) laser-ranging module housed in the
smallest package on the market today, providing accurate distance measurement whatever the
target reflectances unlike conventional technologies. It can measure absolute distances up to 2m,
setting a new benchmark in ranging performance levels, opening the door to various new
applications."
The wavelength of the laser is invisible to our eyes. The 2 meter range makes it useful for a slow
robot or a high speed controller. It may be difficult to respond in enough time to avoid a collision
with something only two meters away at high speed. What do you think?
Hi there, thank you very much for your kind words, I'm glad you enjoyed it.

I agree with you 100%, not only is the range quite limited but because of the wide spread of the
laser light (I believe it's a 19 degree cone or something similar) it's not good at all for precise
readings at anything above 50cm or so. I'd be interested in looking at a more focussed sensor for
a V2 of this project, or maybe trying to lens the light.

Processing time wise, I'm planning on releasing soon an update to the code of this project, trying
to cut down the time required for each reading so that it can take more readings per revolution, or
just rotate faster - either would be a good improvement. I think there's plenty of things in the
program itself that can be done better, but after that I'd like to try using a microcontroller with a
much higher clock speed than the Uno to see if I can process the sensor data much faster that
way.
Indeed a very intriguing & impressive project, with matching high quality write-up work

Hi Sanjeev, thank you very much! Nice to hear from you

This is pretty cool stuff. If you switch to the Teensy 4.0 instead of an Arduino UNO, you'll be
dealing with the fastest microcontroller dev board on the market right now...and it can be
programmed with the Arduino IDE and costs less than an Arduino UNO R3!

Project Lighthouse - 360° Mini Arduino LiDAR: Page 15


I haven't found any reason to use anything else for prototyping...ever...since I've started using
Teensys. They're the easiest to program and integrate, fastest, have a load of peripherals, and
anything smaller or cheaper makes big sacrifices on one of those parameters.
Hi Bob, thank you for your comment I'm glad you enjoyed it. Thank you vey much for the Teensy
suggestion - strangely enough I'd actually been looking into that at the same time you
commented! Definitely definitely worth exploring, so thank you.

I'm planning on updating the Instructable in a month or so with an update to the code - I am
working on using the same hardware (including the Uno) and reducing the time required for a
distance measurement (my first program can definitely be improved a lot) and adding a little more
sophistication to how it performs the scan. After that looking at something with a much faster
clock speed sounds great, definitely want to get my hands on a Teensy 4.0 soon ...
Hello Daniel,

It's a phenomenal project that you have undertaken and of a writing quality that I don't see often;)

I use two HC-SR04 for my detection project on my scooter (rear part). The goal is to alert me to
the presence of vehicles nearby (on an angle of 180 degrees).

The problem is the capture distance is not optimal and the rain is a bad element (I don't ride
really often in rain).

Do you consider that the use of VL53L0X TOF Distance Sensors can be used on my scooter and
replace HC-SR04?
- effective distance?
- external elements which can affect the sensors?
- dust?
- rain?

Cheers!
Mario
Hi Mario! Thank you very much for your comments, really glad you enjoyed the Instructable.

Sounds interesting the use of the sensors on your scooter, clever idea. I think the VL53L0X could
definitely be better than the HC-SR04. The HC-SR04 are definitely affected strongly by dust etc.
The VL53L0X can also be much smaller, which would make it easier to install I'm sure. As the
VL53L0X is using light rather than sound, you could probably install it behind a glass/perspex
window to protect it, but you'll have to test that I'm not 100% sure.

In terms of range the accuracy of the VL53l0X was great up until about 50-75cm, but beyond that
it did start to vary, so I think you'll have to get one and test it!

So I don't think the VL53L0X will give you better range, but it might be better for dust etc,
although definitely need to test everything a lot. Good luck with the project and I look forward to
seeing it on Instructables one day if you do a write-up.
Wow man you have a very well designed and an awesome tutorial that easy for anyone to
understand and do it themselves but I have a question is there a way to use or send that cereal
through Bluetooth or something so I could use it on my phantom drone and have it sent
wirelessly maybe I'm not sure but do you think you could create a mobile version of this?
Hi there! Thank you very much for your comments, I'm glad you like it. I'd like to explore sending
the data via Bluetooth - my next project is going to be mounting this on top of a small 2 wheeled
Project Lighthouse - 360° Mini Arduino LiDAR: Page 16
rover and exploring a room, so it would be nice to be able to send the data back via Bluetooth for
monitoring. Mounting it on a drone sounds ambitious, I don't know if the scanning rate of this
design would be enough for that application. It should be easy to make it mobile though, it just
needs a 5V power supply (with sufficient current for the motor - 1A is more than necessary), and
data connections for an Arduino or another microcontroller.
Awesome project and phenomenal write up.

Thank you very much! I'm glad you enjoyed reading it.

Project Lighthouse - 360° Mini Arduino LiDAR: Page 17

You might also like