NachtRaveVL / Lepton-FLiR-Arduino

Arduino Library for the Lepton FLiR Thermal Camera Module.
MIT License
60 stars 17 forks source link

Read Next Frame not working on ESP32 #7

Closed techboycr closed 4 years ago

techboycr commented 4 years ago

Awesome initiative thanks a lot!

I am trying to run it in ESP32 (Sparkfun ESP32 Thing Plus) and Flir Lepton 2.5 with the latest Flir Breakout board, but is not getting the frames This is the debug output with one get frame.

`Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1044 load:0x40078000,len:8896 load:0x40080400,len:5816 entry 0x400806ac LeptonFLiR::init spiCSPin: 21, storageMode: 3, tempMode: 0 LeptonFLiR::init imageData: 1447B, spiFrameData: 367B, total: 1814B LeptonFLiR::init SPIPortSpeed: 15.00MHz (SPI_CLOCK_DIV16)



Chip Select Pin:
D21 (active-low)

SPI Port Speed:
15.00MHz (SPI_CLOCK_DIV16)

Image Storage Mode:
3: LeptonFLiR_ImageStorageMode_40x30_8bpp

Temperature Mode:
0: LeptonFLiR_TemperatureMode_Celsius

Memory Footprint:
Image Data: 1447B, SPI Frame Data: 367B, Telemetry Data: 0B, Total: 1814B

Power Register:
    LeptonFLiR::readRegister regAddress: 0x0
      LeptonFLiR::readRegister retVal: 0x0
0x0

Status Register:
    LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
0x6

AGC Enabled:
LeptonFLiR::agc_getAGCEnabled
  LeptonFLiR::receiveCommand cmdCode: 0x100
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x100
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x0-0x0
disabled

AGC Policy:
LeptonFLiR::agc_getAGCPolicy
  LeptonFLiR::receiveCommand cmdCode: 0x104
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x104
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x1-0x0
1: LEP_AGC_HEQ

AGC HEQ Scale Factor:
LeptonFLiR::agc_getHEQScaleFactor
  LeptonFLiR::receiveCommand cmdCode: 0x144
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x144
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x0-0x0
0: LEP_AGC_SCALE_TO_8_BITS

AGC Calculation Enabled:
LeptonFLiR::agc_getAGCCalcEnabled
  LeptonFLiR::receiveCommand cmdCode: 0x148
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x148
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x1-0x0
enabled

SYS Camera Status:
LeptonFLiR::sys_getCameraStatus
  LeptonFLiR::receiveCommand cmdCode: 0x204
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x204
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[4]: 0x0-0x0-0x0-0x0
0: LEP_SYSTEM_READY

FLiR Serial Number:
LeptonFLiR::sys_getFlirSerialNumber
  LeptonFLiR::receiveCommand cmdCode: 0x208
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x208
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[4]: 0x41A-0x134-0x0-0x0
041A:0134:0000:0000

Customer Serial Number:
LeptonFLiR::sys_getCustomerSerialNumber
  LeptonFLiR::receiveCommand cmdCode: 0x228
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x228
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[16]: 0xB7D5-0xDB98-0xAEEF-0x997E-0x7D69-0xAD8C-0x8EE7-0xADD5-0xE59D-0x1350-0xEFAF-0x9438-0xB527-0xBEDF-0xFBAF-0xBEE0
B7D5:DB98:AEEF:997E:7D69:AD8C:8EE7:ADD5:E59D:1350:EFAF:9438:B527:BEDF:FBAF:BEE0

Camera Uptime:
LeptonFLiR::sys_getCameraUptime
  LeptonFLiR::receiveCommand cmdCode: 0x20C
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x20C
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x771E-0x23
2324254 ms

Sys Aux Temperature:
LeptonFLiR::sys_getAuxTemperature
  LeptonFLiR::receiveCommand cmdCode: 0x210
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x210
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[1]: 0x75D4
28.49⸮C

Sys FPA Temperature:
LeptonFLiR::sys_getFPATemperature
  LeptonFLiR::receiveCommand cmdCode: 0x214
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x214
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[1]: 0x7602
28.95⸮C

Telemetry Enabled:
LeptonFLiR::sys_getTelemetryEnabled
  LeptonFLiR::receiveCommand cmdCode: 0x218
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x218
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x1-0x0
enabled

Vid Polarity:
LeptonFLiR::vid_getPolarity
  LeptonFLiR::receiveCommand cmdCode: 0x300
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x300
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x0-0x0
0: LEP_VID_WHITE_HOT

Vid Pseudo Color Lookup Table:
LeptonFLiR::vid_getPseudoColorLUT
  LeptonFLiR::receiveCommand cmdCode: 0x304
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x304
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x0-0x0
0: LEP_VID_WHEEL6_LUT

Vid Focus Calculation Enabled:
LeptonFLiR::vid_getFocusCalcEnabled
  LeptonFLiR::receiveCommand cmdCode: 0x30C
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x30C
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x0-0x0
disabled

Vid Freeze Enabled:
LeptonFLiR::vid_getFreezeEnabled
  LeptonFLiR::receiveCommand cmdCode: 0x324
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x324
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x0-0x0
disabled
LeptonFLiR::readNextFrame
  LeptonFLiR::receiveCommand cmdCode: 0x100
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x100
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x0-0x0
  LeptonFLiR::receiveCommand cmdCode: 0x218
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x218
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x1-0x0
  LeptonFLiR::receiveCommand cmdCode: 0x21C
    LeptonFLiR::waitCommandBegin
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
    LeptonFLiR::writeRegister regAddress: 0x4, value: 0x21C
    LeptonFLiR::waitCommandFinish
      LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
      LeptonFLiR::readDataRegister readWords[2]: 0x1-0x0
    LeptonFLiR::readRegister regAddress: 0x2
      LeptonFLiR::readRegister retVal: 0x6
  LeptonFLiR::readNextFrame AGC-8bit: disabled, Telemetry: enabled, Location: footer
  LeptonFLiR::readNextFrame Maximum resync retries reached. Aborting.
`

I dont know if there anything that I am doing wrong. 

Thanks for your help.
NachtRaveVL commented 4 years ago

Heyhey,

Thank you for testing this on the ESP32 and filing out an issue. This is actually a known issue as of currently, due to the slow SPI interface that the Arduino libraries utilize. A more thorough explanation of what’s happening is on the other issue: https://github.com/NachtRaveVL/Lepton-FLiR-Arduino/issues/2

Essentially, you’re experiencing a de-sync and that’s not surprising given that this has long since been the major bottleneck of the library.

I’ve been working on a new version of the library and a completely different fast SPI transfer mechanism in my spare time as of more recently. I don’t have a time table for any of it, as I have only time in the evening after the day job to work on such, but I would recommend instead to go the route of RasPi to utilize the FLiR as of currently.

On a different note: did you experience any compilation difficulties with compiling the library on ESP32? I admit I haven’t looked too far into the Espressif toolkit there (although I did install it for sake of future experimentation), as I’ve been busy with a lot of other projects lately.

Thanks again! NR

techboycr commented 4 years ago

Hello Hello!

Well this piece of software you did is just amazing, thanks for that! I will give it a different try tonigh and I will keep you inform on my findings.

And to answer your not I didn’t experience no problems at compiling time, So that led me to think that maybe we will be able to make it work soon.

Thanks for your help!

M-A-Kitchlew commented 2 years ago

Hi

I'm using ESP32 with lepton 3 and Pure Thermal Breakout board

I keep getting NACK on address and what appear to be default values whenever I try to output module info on serial monitor

LeptonFLiR::readNextFrame LeptonFLiR::receiveCommand cmdCode: 0x100 LeptonFLiR::waitCommandBegin LeptonFLiR::readRegister regAddress: 0x2 LeptonFLiR::checkErrors lastI2CError: 2: Received NACK on transmit of address LeptonFLiR::receiveCommand cmdCode: 0x218 LeptonFLiR::waitCommandBegin LeptonFLiR::readRegister regAddress: 0x2 LeptonFLiR::checkErrors lastI2CError: 2: Received NACK on transmit of address LeptonFLiR::readRegister regAddress: 0x2 LeptonFLiR::checkErrors lastI2CError: 2: Received NACK on transmit of address LeptonFLiR::readNextFrame Errors reading state encountered. Aborting. 0