An alternate firmware for tCam-Mini yields analog video out

A project log for Lepton 3.5 Thermal Imaging Camera

Documenting my experiments with the FLIR Lepton 3.5 thermal imaging camera.

dan-julioDan Julio 09/27/2023 at 01:090 Comments

I recently came across a library on github written by a mysterious user named aquaticus that uses the ESP32 I2S and DAC peripherals to generate a monochrome analog video output.

It never ceases to amaze me what people are doing with this chip and I immediately thought about mashing it up with the existing tCam-Mini firmware.  I was in part motivated by tear downs of old thermal imaging cameras I have seen in the Thermal Imaging Forum on Dave Jones' website.  Some of these old cameras where incredibly complex (and costly) and now we can generate similar results with the cheap Lepton and super-cheap ESP32.

A couple of days effort yielded some great results and it has all been pushed up to github if you want to take a look.

The ESP32 DAC is 8-bits referenced to the 3.3V supply.  Video levels into a 75-ohm load are typically 0 - 1V with blanking at zero, black at around 0.3V and full white at around 1V.

The video library generates buffers full of data constructed to properly generate the hsync and vsync amongst the video data and then uses the I2S to DMA that through the DAC.  The original video library demo code constructed the buffers so the DAC never outputs voltages greater than 1V which means the value of any data sent to it must be less than 1/3.3 * 255 = 77.  With the need for sync this means only about 55 counts available for video data which is not a lot.  Fortunately you can adjust the parameters and I ended up going with voltages between 0 - 2.36V which gives me 128 intensity levels.  More but still not the 256 intensity levels that are usually used.  Because of that I always enable AGC in the lepton so it outputs data with the best contrast.  The resultant image looks OK.  No radiometric data but we can still pull the spot meter temperature from the telemetry.  The additional voltage range requires an external 100 ohm resistor so that the voltage seen by the 75 ohm input display is scaled back to 0 - 1 V.  The video output can be on either DAC pin (GPIO25 or GPIO26).  Fortunately I am already bringing GPIO26 out to the Slave IF port which makes connecting the video very easy.

The firmware supports a few features.

  1. Works with Lepton 3.0, 3.1R or 3.5. Radiometric Leptons configured with AGC enabled for best image quality. Gets the full 8.7 FPS possible from the Leptons.
  2. 320x240 pixel image display (linearly interpolated from Lepton 160x120 image).
  3. Optionally displays the 2x2 pixel spotmeter and spotmeter temperature in the center of the image for radiometric Leptons.
  4. Optionally displays min/max temperature location markers.
  5. Supports both white-hot and black-hot palettes.
  6. Supports setting emissivity.
  7. Supports both Imperial (°F) and Metric (°C) temperature readouts.
  8. Stores configurable operating parameters in ESP32 Non-volatile flash.
  9. Firmware may be re-compiled with reduced number of gradations to eliminate need for external 100-ohm resistor.

The button is used to change various operating parameters.  It can cycle through the two palettes, enable or disable the markers and spot meter, set the emissivity and configure the readout units.

The firmware can draw text over the image using one of two fonts.  An 8x16 pixel 7-segment numeric font is used for the temperature and a 7x10 pixel alphanumeric font used to display some parameters as they are changed.

The project is configured to support ESP32 Rev 1 and beyond processors so it can also be run on home-brew tCam-Mini cameras if you already have a Lepton breakout board.  But you have to have a ESP32 WROVER module since it has the necessary external PSRAM.

All in all a fun little diversion.  Here's a camera aimed at some black body radiator temperature references.

Full instructions and the code are at the new github repo.