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…
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:
FLIR Lepton Hookup Guide Wishlist SparkFun Wish List
Note: To reduce the number of components used, you could wire the thermal camera straight to the Pi using F/F jumper wires. For a secure connection, you could also use solder a custom Raspberry Pi hat using a prototyping board.
Heads up! If you are getting the PureThermal 2: FLIR Lepton Smart I/O Board, the board does not include the FLIR Lepton camera module. However, this handles control of the camera and raw video data via USB. This is useful if you are attaching it to your computer and using it as a USB web camera.
For more information on setting up the smart I/O board with your computer, check out the following videos related to your setup to install the official Lepton app.
- Windows
- Mac OS
- Raspberry Pi
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.
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.
Electromagnetic spectrum with visible light highlighted. Image courtesy of Wikimedia Commons.
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:
sudo raspi–config
You should be presented with the following screen as shown below. Click on the “Advanced Options” menu.
Having a hard time seeing the circuit? Click on the image for a closer look.
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.
Having a hard time seeing the circuit? Click on the image for a closer look.
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:
sudo apt–get install qt4–dev–tools
Which will look something like this…
Once installation is complete, go to the Pure Engineering GitHub repo and retrieve the …/software/raspberrypi_videodirectory. 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:
unzip LeptonModule–master.zip
Now cd into the unzipped folder “LeptonModule-master” and the directory “…/raspberrypi_video”. This directory contains all of the files you need to compile the example code. 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, cd back out to the “…/raspberrypi_video” directory and 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:
Read More info…..