FLIR Lepton Hookup Guide
Introduction
When our team found out that we’d be testing a Long Wave Infrared (LWIR) camera, there were two words that we couldn’t stop saying: Predator Vision. That’s right, we were finally going to be able to see the invisible world of heat, which would aid us greatly if we ever found ourselves hunting a team of special operatives in a remote jungle… or, you know, trying not to scald ourselves on a hot cup of tea.
As it happens, the FLIR Lepton is an excellent little module for the price and Pure Engineering has done a bang up job spinning the breakout board and documentation.
There are, however, a few minor “gotchas” in the setup process and so we figured it was best if we shared what we learned in playing with this thing. But first… A bit of theory...
Suggested Videos
Required Materials
To follow along with this tutorial, you will need the following hardware and software. You may not need everything though depending on what you have and your setup. Add the hardware to your cart, read through the guide, and adjust the cart as necessary.
Hardware
Today we’ll be setting up the Raspberry Pi example code as provided by Pure Engineering and featured in our product videos. At a minimum, we’ll be needing a Raspberry Pi... and not much else, actually. Just a handful of jumper wires as well as a monitor, keyboard, accompanying cables for your Raspberry Pi, and the FLIR Lepton camera of your choice.
Below is a wishlist of the suggested parts:
Software
The example code has been tested on a Raspberry Pi model B, but it should work fine on any model so long as you have Raspbian installed.
You will also need to install the QT dev tools and example. Check out the Software later in the tutorial for more information.
Suggested Reading
If you aren’t familiar with the following concepts, we recommend checking out these tutorials before continuing. This tutorial will assume you have a little bit of Raspberry Pi knowledge. If the Pi is new to you, have no fear. You can visit our Installing Raspbian and DOOM tutorial, if you need a primer. Also helpful is our Raspberry Pi GPIO tutorial. The Lepton uses SPI communication to send its video stream and it uses an I2C-like Communication protocol as the control interface. If you are unfamiliar with either of those communication methods, please visit the corresponding tutorials.
Serial Peripheral Interface (SPI)
Setting up Raspbian (and DOOM!)
Theory
Electromagnetic radiation is all around (and within, and throughout) us and is comprised of everything from gamma radiation on the high frequency end to radio waves on the low frequency end. While most imaging sensors detect radiation in the visible spectrum (wavelengths from 380 to 700 nanometers), long wave infrared sensors detect radiation from 900 to 14,000 nanometers. This is known as the infrared spectrum, and it accounts for most of the thermal radiation emitted by objects near room temperature.
The sensor inside the FLiR Lepton is a microbolometer array. Microbolometers are made up of materials which change resistance as they’re heated up by infrared radiation. By measuring this resistance, you can determine the temperature of the object that emitted the radiation and create a false-color image that encodes that data.
Thermal imaging of this type is often used in building inspection (to detect insulation leaks), automotive inspection (to monitor cooling performance), and medical diagnosis. Also, because of its ability to produce an image without visible light, thermal imaging is ideal for night vision cameras.
When it comes to robotics, thermal cameras are especially useful heat detectors because the image that they produce (by virtue of being, well, an image) can be processed using the same techniques and software as visible light images. Imagine using something like OpenCV to track, not just color centroids, but heat centroids! That’s right, you could be building heat-seeking robots right in your own home!
In fact, what are we waiting for? Let me give you the tour...
Hardware Overview
Listed below are some of the characteristics of the FLIR Lepton's specs. The cells highlighted in blue indicate the slight differences between the two versions of the FLIR Lepton camera module.
FLIR Lepton | FLIR Lepton v2.5 w/ Radiometry | |
---|---|---|
Resolution (h x v) | 80 pixels x 60 pixels | 80 pixels x 60 pixels |
Spectral Range | 8µm to 14µm | 8µm to 14µm |
Horizontal Field of View | 51° | 50° |
Thermal Sensitivity | < 50mK | < 50mK |
Frame Rate | < 9Hz | < 9Hz |
Control Interface | I2C | I2C |
Video Interface | SPI | SPI |
Promised Time to Image | < 0.5 sec | < 1.2 sec (~0.5 sec in real world testing) |
Integral Shutter | ✓ | |
Radiometry | 14-bit pixel value | 14-bit pixel value, Kelvin |
Operating Power | ~150 mW | ~150 mW |
Hardware Hookup
Circuit Diagram
Connect the FLIR breakout to the Raspberry Pi GPIO according to the diagram below. If you need a refresher on how the GPIO pins are oriented, visit our Raspberry Pi GPIO tutorial. Make sure that your Lepton module is securely snapped into the socket on the breakout board.
There are several methods of connecting and mounting your system together. If you used a breadboard and LCD touchscreen with the Pi, your setup should look similar to the image below.
Congratulations, that’s the hardware part done. Now onto the software configuration!
Software
As I mentioned earlier, you’ll want to have the Raspbian OS installed on your Raspberry Pi. Boot it up, and open the Terminal program. Our first matter of business will be enabling the Pi’s SPI and I2C interfaces. Luckily, Raspbian makes this easy to do by including a utility called raspi-config. To run the utility just type:
language:bash
sudo raspi-config
You should be presented with the following screen as shown below. Click on the "Advanced Options" menu.
Select SPI and follow the instructions on the following screens. After you've completed the SPI steps, do the same thing for I2C. When you exit raspi-config, it will ask if you want to reboot. Go ahead and do it so that the changes we just made will stick.
QT Application
Pure Engineering’s example code is a QT application so we’ll need to get that dependency installed before we can compile it. Don’t worry, it’s easy to do. Make sure that the Pi has an Internet connection, and run the following command to install the QT dev tools:
language:bash
sudo apt-get install qt4-dev-tools
Which will look something like this...
Raspberry Pi Video
Once installation is complete, go to the Pure Engineering GitHub repo to download the examples.
If you’re familiar with git, you can do this from the command line. For most people, it’s just as easy to browse to the above link, and click “Download ZIP”. You can download the file to whatever directory you like, then cd
to that directory in Terminal, and unzip it using the following command:
language:bash
unzip LeptonModule-master.zip
Now cd
into the unzipped folder "LeptonModule-master". First, we need to "make" the Lepton SDK. Use the cd
command to navigate to the ".../software/raspberrypi_libs/leptonSDKEmb32PUB" directory and run the make
command.
Once that process has completed, use the cd ..
command twice to move back out of the folders. Then use the cd
to move into the ".../raspberrypi_video" directory. This directory contains all of the files you need to compile the example code. run qmake && make
:
Congratulations! You've just compiled the example code, and you're ready to run it. Simply type the following into your command line:
language:bash
sudo ./raspberrypi_video
Remember, if you have issues getting the camera to work with pin 26 on the Pi, you may need to adjust the CS pin to pin 24 (next to the CLK pin) like this tutorial from FLiR.
Aim the camera at something hot or step in front of it to begin viewing heat signatures!
Resources and Going Further
Now that you're successfully retrieving LWIR images from the Lepton module, you can dig into the example code and apply it to your own project!
For more information, check out the resources below:
- Breakout Board Schematic (PDF)
- Datasheet
- Raspberry Pi: Raspbian OS Download
- Mike's Electric Stuff: Reverse-Engineering the FLiR Lepton(R)
- Pure Engineering: Project Page
- Lepton Module GitHub Repo -- Library, Example Code, & Design Files. The example in this tutorial uses the code from this repository.
- PyLepton (Python)
- GetThermal Viewer ( Linux & macOS )
- FLIR’s Lepton SDKs
- 32-bit (ZIP)
- 64-bit (ZIP)
- Discussion Forum
- GroupGets: Product Page
- SparkFun Product Showcase
Thermography has hundreds of applications. Spend some time just playing with the camera to see where you might find uses for it. Try piping the frames captured from your Lepton module into some computer vision software like SimpleCV! We'd love to see what you do with the FLiR Dev Kit so be sure to leave a comment and tell us all about it!
Need some inspiration for your next project? Check out some of these related tutorials:
Building Large LED Installations
Bark Back Interactive Pet Monitor
Raspberry Pi 3 Starter Kit Hookup Guide
Advanced Autonomous Kit for Sphero RVR Assembly Guide
MLX90614 IR Thermometer Hookup Guide
Qwiic GRID-Eye Infrared Array (AMG88xx) Hookup Guide
Or check out the FLiRPiCam project which includes a 3D printed enclosure files: