Thermal Images on Jetson™ Nano with FLIR Lepton3

In the far 2017 I partecipated (and won) to a challenge promoted by FLIR and the BeagleBoard.org Foundation. I used a FLIR Lepton3 module and a BeagleBone Blue to detect and track people using their temperature.

In this article I will explain how to use the same Lepton3 module with a NVIDIA® Jetson™ Nano.

FLIR Lepton3

The FLIR Lepton® is a radiometric-capable LWIR camera solution that is smaller than a dime, fits inside a smartphone, and is one tenth the cost of traditional IR cameras. Using focal plane arrays of either 160×120 or 80×60 active pixels, Lepton easily integrates into native mobile-devices and other electronics as an IR sensor or thermal imager. The radiometric Lepton captures accurate, calibrated, and noncontact temperature data in every pixel of each image.

From FLIR website
Flir Lepton3

The FLIR Lepton3 communicates with the host using two different communication channels:

  • I2C to control the sensor settings
  • SPI to send thermal image data

The breakout board

The FLIR Lepton3 module requires a breakout board to connect it to our device. I use the GroupGets FLIR breakout board v1.4. All required Lepton system voltages, I2C pullups, and clocking is provided by this board so you can focus on your application software and not the Lepton setup hardware. Recently the new breakout board v2 has been released with an useful VSINC signal and other useful features, that allow to realize more stable communication drivers.

Connection

The schematic of the connections is reported below

FLIR Lepton3 to NVIDIA® Jetson™ Nano Developer Kit connection
Lepton3
PIN
Lepton3
NAME
ColorJetson Nano
NAME
Jetson Nano
PIN
1CSGreenSPI1-CS024
2MOSIN.C.N.C.
3MISOYellowSPI1-MISO21
4CLKWhiteSPI1-CLK23
5GNDBlackGND6
6VINRed3V31
7SDAOrangeI2C1-SDA27
8SCLBrownI2C1-SCL28
Connection table
Lepton3 side
Jetson Nano side

I created a simply carrier board using a protoboard to keep the FLIR Lepton 3 vertical, but the cables can be directly connected to the pin headers of the breakout board v1.4.
An optional resistor of 10KΩ is connected between MOSI and GND to keep the connection stable.

Carrier board top
Carrier board bottom

If you are curious about the rear single pin… it’s a GND test point, useful to connect the GND of the probe of the oscilloscope to analyze the status of each signal.

Enable SPI

The first operation to perform is enabling one SPI port on the Jetson™ Nano. The operation is quite simple, there is a very good guide to follow and I will not replicate every step here, just go to visit the JetsonHacks blog and follow the guide of my friend kangalow about using the Jetson-IO tool to enable the SPI1 port available on the PINS 19,21,23,24,26 of the expansion header (J41) of the NVIDIA® Jetson™ Nano Developer Kit.

Change SPI buffer size

The default buffer size use for SPI communication is set to 4096 bytes by the spidev module. Lepton3 requires 20KB of buffer to retrieve a full segment of data that composes the thermal image.

To change the size of the SPI buffer we have two methods. The first is temporary and the default buffer size will be restored after the next reboot, the second is permanent.

Temporary method

First of all remove the spidev module from the Kernel

then reload the module setting the required parameter

Permanent method

To permanently set the value of the SPI buffer you must create a configuration file for modeprobe

Enter the following line

options spidev bufsiz=20480

Save and reboot the Jetson Nano

SPI Buffer size check

To be sure that the buffer size of the SPI has the correct value we can check the content of the file /sys/module/spidev/parameters/bufsiz using the command

if you correctly followed the configuration procedure, the output should be 20480 .

Check I2C communication

To verify that the I2C cables are correctly connect you can use the command

the I2C interface of the FLIR Lepton3 module should reply at address 0x2a

Protective case

The Lepton3 breakout board is placed inside a protective 3D printed case that I designed 3 years ago. It is available on Thingiverse.

The two parts of the protective case
Lepton3 safe inside its protective case

Software

A Github repository is available that contains a library driver to control the Lepton3 by I2C and to get thermal image by SPI.

The repository contains a sample demo that illustrates how to control the sensor features, how to acquire thermal images and how to display them using OpenCV.

The repository contains also a real world application that illustrates how to convert raw data values to real temperature values.

An useful application for COVID19

In this strange period of COVID19 an useful application for a thermal image is to measure the human temperature and alert in case it overcomes the “security value” of 37.5°C. The application is available in the Github repository and illustrates how to measure the person temperature and send visual alarms in case of possible fever.

The application allows to “simulate fever” adding °C to the temperatures that are in the range of human temperature.

The code is self-explaining and fully commented, but you can write me an email if something is not clear. I will be happy to discuss about it.

Now it’s time for images and videos, that are always better than many words.

Fever Normal
Simulated Fever Warning
Simulated Fever Alert

Enjoy my work and STAY SAFE.

Comments are closed.