Secure Remote Mains Switch, part two (January 2025)
Secure Remote Mains Switch, part two (January 2025)
VL6180X
Electronic
Laser modules
Rangefinder
Using Electronic Modules with Jim Rowe
Quason VL6180X
- Laser rangefinder
- Light level sensor
This module should be of particular interest if you want
to build robotic devices. It uses infrared (IR) light to accurately
sense the proximity of objects from 0mm to well over 100mm. It’s based
on a technology known as FlightSense, patented by ST Microelectronics.
T
he Quason VL6180X range-
sensing module comes on a tiny
17.8 × 20.3mm PCB with a handful of
SMD components on it. As you can
see from the photos, it includes three
SOT-23-3 devices and one 12-lead
SMD IC, itself only 4.8 × 2.8 × 1mm.
The secret is all inside that innocent-
looking 12-lead IC in the centre of the
PCB. There’s a lot more in that tiny
package than you might expect. It’s
a complete optical ranging system
with a tiny IR (infrared) laser, two
optical sensors (one for IR, the other
for ambient light sensing), plus a microcontroller unit (MCU) with internal memory.
This IC is the heart of the VL6180X
sensing module – the rest of the components are there just to support it.
Inside the VL6180X
It’s made by European semiconductor manufacturer ST Microelectronics and uses its patented FlightSense
technology.
Unlike optical sensors that attempt
to detect distance by measuring the
proportion of light sent to an object
that is reflected back from it, ST’s technology accurately measures the time
the light takes to travel to the nearest
object and reflect back to its sensor,
which ST calls the ‘time of flight’. In
short, it’s a kind of light-based radar
or ‘LIDAR’.
Fig.1 shows what’s inside the
VL6180X and should help in understanding how it works. Near the bottom
is the MCU with its ROM (read-only
memory) and RAM (random-access
memory) below it, while above it is
Practical Electronics | January | 2025
the ambient light sensing section. The
IR laser driver section is shown in the
centre, with the range detection section just above the MCU.
To make a ranging measurement,
the MCU first sends a command pulse
to the IR laser driver to send out a
short IR light pulse at a wavelength
of 850nm. Then, it measures the time
until the ranging detection section
reports that a reflected IR pulse has
been received.
The MCU can then calculate the current distance to the object that reflected
the IR pulse, by taking into account
the speed of light in air and the time
taken for the out-and-back journey.
The speed of light in air is close to
299,702,458m/s (metres per second),
which equates to 299.702m per mi-
crosecond or 0.2997m per nanosecond. So light takes close to 3.336ns to
travel one metre or 0.3336ns to travel
100mm. If the out-and-back journey
of the light takes, say, 0.6672ns, the
total path length is 200mm, so the
distance between the sensor and the
object must be 100mm.
The key to this method of determining distance is precise measurements
of very short time delays. To measure
over a range of 1-100mm with 1mm
resolution, the chip must have a timer
capable of measuring the difference
between emission and reception from
just 7ps (picoseconds) to 667ps with
7ps resolution or better. One picosecond is one trillionth (10−12) of a second!
These capabilities are thanks to
modern semiconductor manufacturing
Fig.1: the block diagram for
the VL6180X rangefinder
IC. The internals appear
quite simple, with a
separate section for the
light sensing, IR emitter
and ranging. However,
very precise timing
is required to make
calculations down to the
millimetre resolution, so
the actual circuitry is more
complicated than you
might think.
39
Electronic modules
Here the module is shown at nearly
three times actual size for clarity.
techniques that can make tiny transistors with predictable properties.
In addition to this ‘time of flight’
range measurement, the VL6180X
can also measure the ambient light
level using the sensor and ambient
light sensing (ALS) section shown at
the top of Fig.1. This appears to be a
‘bonus’ feature as it does not factor
into the distance measurements
It can measure light levels between
0.002 lux and 20,971 lux, with what
is described as a ‘photopic’ response.
That means it responds to light wavelengths in the visible range of 400700nm (with a peak at around 550nm)
as seen by the human eye at ‘well-lit’
lighting levels.
The MCU in the VL6180X can take
these measurements either once or repetitively and can also interleave range
and ALS measurements. It accepts commands and makes the measurement
data available via the I2C port (pins 5
Fig.2: the top of the VL6180X IC
features three tiny holes that are
critical for its functionality. These
apertures are required for sensing
and emission, with the largest being
only 0.58mm in diameter. There is
also an even smaller ‘vent’ hole.
It’s important to note that the light
sensor has a very narrow ‘cone’ and
measures objects up to 150-200mm
away.
40
and 6) at lower right in Fig.1.
You are probably wondering how
all these impressive things can be
done by the very small and innocent-
looking chip visible in the centre of
the module PCB. Although they are
not easy to see with the naked eye,
there are actually three apertures on
the top of the device, located on its
centre line as shown in Fig.2 (which
shows the top of the VL6180X at six
times its actual size).
The largest aperture (0.58mm diameter) near the centre is for the ALS
sensor, while the smaller 0.5mm diameter one near the far end is for
the IR ranging laser emissions. The
even smaller 0.3mm diameter aperture near the ALS at the pin 1 end
is for the IR ranging return sensor.
A fourth and very tiny ‘vent’ hole
is at lower centre, midway between
pins 3 and 4.
The VL6180X is designed to operate from a supply of 2.8V ±0.2V,
with an average operating current of
1.7mA in ranging mode or 300µA in
ALS mode. The current it draws in
standby mode is less than 1µA. And
the I2C interface can operate at up to
400kHz, with a 7-bit address of 0x29
(41 decimal).
The full module
Fig.3 shows the complete circuit
of the Quason module, with the all-
important VL6180X device (IC1) visible at lower left. At top centre is
REG1, an XC6206 LDO voltage regulator used to step down the 5V input
supply (at pin 7 of CON1) to the 2.8V
Useful links
• www.aliexpress.com
• www.st.com/content/st_com/
en.html
• www.arduinolibraries.info/
libraries/vl6180-x
• github.com/adafruit/Adafruit_
VL6180X
needed by IC1. The 2.8V from REG1 is
also made available at pin 6 of CON1,
for possible use by external circuitry.
Both the GPIO0 and GPIO1 pins of
IC1 are pulled up to 2.8V via 47kW
resistors. The GPIO1 pin is then taken
directly to pin 4 of CON1, while the
GPIO0 pin is connected to pin 3 of
CON1 via diode D1. This allows IC1
to be held in standby mode by pulling pin 3 of CON1 to ground. That
is why this pin of CON1 is labelled
“SHDN” (for “shutdown”).
Mosfets Q1 and Q2, connected between the SCL and SDA pins of IC1
and the corresponding pins 2 and 1
of CON1, provide logic-level conversion. This way, the 2.8V signal
swings at pins 5 and 6 of IC1 are
converted into 5V swings at pins 2
and 1 of CON1, and vice versa. This
allows the module to be connected
to external circuitry running from a
5V supply, like an Arduino or similar MCU.
The way this kind of ‘passive’ level
shifter works is quite clever. Q1 & Q2
are N-channel devices, so they switch
on when their gate voltage (“G”) is
significantly higher than the source
voltage (“S”). At idle, the source is
Fig.3: the circuit diagram for the Quason module which utilises the VL6180X
IC. Q1 and Q2 are used for logic-level conversion.
Practical Electronics | January | 2025
VL6180X Laser Rangefinder
pulled to +2.8V via one 10kW resistor, while the drain is pulled to +5V
via another. With the gate and source
both at +2.8V, the Mosfet is off, so no
current flows.
If IC1 pulls its end low, the gatesource voltage becomes +2.8V, so
the Mosfet switches on and the corresponding pin on CON1 also goes
low. Alternatively, if the pin on CON1
is externally pulled low (eg, by an
MCU), the Mosfet is initially off.
Still, its parasitic ‘body diode’ (visible in Fig.3) allows the corresponding pin on IC1 to be pulled down to
about +0.7V.
The gate-source voltage of that
Mosfet is then 2.8V − 0.7V = 2.1V,
high enough for the Mosfet to switch
on, pulling the pin on IC1 down to
0V. So when one side goes low, the
other does too, but if both sides are
allowed to be pulled high by the pullup resistors, they remain high at different voltage levels.
Connecting it to an Arduino
As you can see from Fig.4, connecting the module to an Arduino
Uno or compatible is very straightforward. The module’s VIN pin connects to the Arduino’s 5V pin, its
GND pin connects to one of the Arduino’s GND pins, and its SCL and
SDA pins connect to the same pins
on the Arduino.
You will also need an Arduino li-
Fig.4: the Quason
module can be easily
connected to an
Arduino Uno (or
similar), with just four
leads.
brary to get the two communicating,
plus a sketch to use the library to make
measurements. A couple of these libraries are listed on the Arduino website at www.arduinolibraries.info/
libraries/vl6180-x – in both cases,
they provide links to the library ZIP
files on GitHub.
When you download and unzip
either of these libraries, they generously provide example sketches to
get you going.
I downloaded one of these libraries, added it to my list of libraries in
the Arduino IDE and then loaded one
of its example sketches.
It was only a few minutes before I
could wave my hand up and down
above the VL6180X and see its distance varying in the ranging data on
the Arduino IDE’s Serial Monitor. It
was as simple as that!
So it’s pleasingly easy to get the
Quason VL6180X IR range sensing
module going with an Arduino. This,
plus its low cost, suggests that it
would be very suitable for DIY robotics. You might even be able to use
a couple of the modules to make a
digital Theremin!
Where to get it
As you can see from this enlarged photo, the Quason VL6180X is miniature,
measuring just 17.8 x 20.3mm.
Practical Electronics | January | 2025
We obtained the module in the
photos from the Quason Official
Store, one of the vendors on Ali
Express (see www.aliexpress.com/
item/1005001572022389.html), for
£2 including shipping. But there are
several other vendors on AliExpress
offering it for similar prices, such as
SuperModule Store, DIY-Victor Store
and HARYE Store.
It is also available from numerous
eBay suppliers starting at around £4,
including shipping. You could also
look on Amazon, which is rapidly becoming another eBay now that they
have listings from third-party sellers.
We found a similar (but not identical) module in the online shop
https://coolcomponents.co.uk for
£8.99, which will presumably be
quicker to obtain than those coming
from overseas.
PE
41