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.
This year, the year of COVID19, I decided to get that project out of the drawer and to adapt it to Nvidia Jetson Nano to realize an application to control human body temperature and issue alerts in case of fever.
FLIR Lepton 3The FLIR Lepton3 communicates with the host using two different communication channels:
- I2C to control the sensor settings
- SPI to send thermal image data
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.
ConnectionThe schematic of the connections is reported below
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.
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 SPIThe 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 sizeThe 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 methodFirst of all remove the spidev module from the Kernel
$ sudo rmmod spidev
then reload the module setting the required parameter
$ sudo modprobe spidev bufsize=20480
Permanent methodTo permanently set the value of the SPI buffer you must create a configuration file for modeprobe
$ sudo gedit /etc/modprobe.d/spidev.conf
Enter the following line
options spidev bufsiz=20480
Save and reboot the Jetson Nano
SPI Buffer size checkTo 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
$ cat /sys/module/spidev/parameters/bufsiz
if you correctly followed the configuration procedure, the output should be 20480.
Check I2C communicationTo verify that the I2C cables are correctly connect you can use the command
$ i2cdetect -y -r 0
the I2C interface of the FLIR Lepton3 module should reply at address 0x2a
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- 2a -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Protective caseThe Lepton3 breakout board is placed inside a protective 3D printed case that I designed 3 years ago. It is available on Thingiverse.
A Github repository is available that contains a library driver to control the Lepton3 by I2C and to get thermal image by SPI.
https://github.com/Myzhar/Lepton3_Jetson
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 COVID19In 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.
Enjoy my work and STAY SAFE.
Comments