Skip to content

BackLogers/Lepton-Arduino

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arduino-lepton

FLIR Lepton drivers for Arduino HAL. Tested with ESP32-S3 + Lepton 3.5 on a custom board, but (in concept) should work on most Arduino platforms that have the enough memory and computational power.

Examples

All examples should build right out of the box with PlatformIO and have pinmaps defined at the top of main.cpp.

  • ESP32-S3 webserver example with single-frame capture and streaming MJPEG, in greyscale or RGB888 (colorized) mode. Uses the JPEGENC library and FreeRTOS (part of all ESP32 builds). Likely compatible across the ESP32 family.

    Lightly refrigerated plush ducks over the webserver example, as viewed from a browser.

  • Serial console example that prints frames to the console, each pixel being a single character (auto-scaled from 0-9). Likely works on any Arduino platform with a serial console, good basic test of functionality with minimal dependencies.

    Lightly refrigerated plush ducks over the serial console example.

Usage

FlirLepton lepton(i2c, spi, kPinLepCs, kPinLepRst);
uint8_t frameBuffer[160*120*2] = {0};

lepton.begin();  // resets the Lepton
while (!lepton.isReady());  // poll until Lepton reports ready

while (true) {
  bool readResult = lepton.readVoSpi(sizeof(frameBuffer), frameBuffer);  // returns true on a new frame
  if (readResult) {
    // do something with frameBuffer
  }
}

See full API in the header file.

Notes

  • VoSPI is a timing-sensitive protocol and desynchronizes if frames are not read out promptly. If using an RTOS, the Lepton driver needs to be high priority to ensure SPI is running fast enough.
  • In some cases (not quite sure why), the Lepton never returns any valid SPI data and constantly attempts to re-sync without success. Power-cycling / resetting the Lepton does not seem to fix the issue, though sometimes random modifications to the firmware might. Potentially related to using the VoSPI interface too early (?) or in-between frames (if not using the VSYNC signal).
  • Only tested with Lepton 3.5, but likely works with all Lepton 3 devices (160x120 resolution). For other devices, you can try manually setting the video parameters with FlirLepton::setVideoParameters(uint8_t bytesPerPixel, uint8_t frameWidth, uint8_t frameHeight, size_t videoPacketDataLen, size_t packetsPerSegment, size_t segmentsPerFrame)
  • readVoSpi blocks when reading a frame, but returns immediately during a discard frame. Future versions might look at splitting out the VoSPI into a different class that can have platform-specific optimized implementations, like using DMA and allowing other threads to run while a packet is being read.

Related Work

These projects do similar things:

About

FLIR Lepton library for Arduino

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%