Sparkfun Flir Dev Kit on Arduino Nano w/External RAM module

Hello,

I have purchased the Sparkfun Flir Dev kit, which used the Flir lepton thermal camera. My intention is to build a handheld thermal camera using an Arduino Nano, connected to a TFT screen.

I am aware that the Nano doesn't have enough RAM to store the frame from the lepton, so I have added a 23KB ram module using an SPI interface. I have tested this, and it works.

I am, however, having issues reading the data from the lepton itself. I can run the example sketch and I can access the camera setup information, serial number, etc. This information is here:

However, when I try to read actual data from the Lepton, I get garbage. Usually 0's and random numbers, or some other nonsense output. I believe this is due to the speed of SPI bus not being fast enough? Currently, I am using the serial port to print out the values, but this could be slowing things down. However, I am not sure if I am understanding the code well enough to modify it to use with my SPI RAM, or even if a Nano can be used with the lepton.

To clarify, what I want is to:

Grab a frame from the lepton, store it in SPI ram. Then, send the entire image data to file. Right now, the "file" is the serial port, eventually it will be the TFT screen and an SD card. I am not hugely interested in video output, just still images, so it should be possible to do this even with the nano's 16mhz processor, is this correct?

My code is here: It is a slightly modified version of some code that I found here.

I have also tried wiring the Lepton to the Arduino Due, but I still can't get a usable image out of it, I get garbled data. The code I am using for the Due is:

Thanks for any advice!

I have made some progress with this. I found out that I was wiring Sda and Scl to the wrong pins of the Due board, I should have had them wired to Pinds 20 and 21, and I was wiring them to the "SCL1" and "SDA1" pins.

I can now get the Serial numbers and setup information out of the lepton, such as:

beginTransmission
reg:2==0x6 binary:110
SYS Camera Customer Serial Number
reg:2==0x7 binary:111
busy
reg:2==0x6 binary:110
reg:6==0x20 binary:100000
payload_length=32
FFFFFF7E
FFFFB57F
5D5E
5CFD
FFFFF4D7
FFFFD7EB
FFFF96F5
7D47
FFFFDCD7
7570
55F9
7CFF
5CFF
FFFFDEEB
3D94
FFFFD55C
SYS Flir Serial Number
reg:2==0x7 binary:111
busy
reg:2==0x6 binary:110
reg:6==0x8 binary:1000
payload_length=8
FFFFF017

However I am still getting garbled data over the SPI bus. I can't seem to get it to work at all, no matter what I try. Is there anything obvious that I could be missing here?

In an attempt to make my code as simple as possible, I created this sketch:

#include <SPI.h>

int data[164];

void setup()
{
 Serial.begin(9600);

 pinMode(10, OUTPUT);

 SPI.setDataMode(SPI_MODE3);
 SPI.setClockDivider(0);
 SPI.begin();

 Serial.println("setup complete");
 delay(1000);

 for (int i = 0; i < 164; i++) {
   digitalWrite(10, LOW);
   int response1 = SPI.transfer(0xFF);
   data[i] = response1;
   digitalWrite(10, HIGH);

 }

 for (int i = 0; i < 164; i++) {
   int response1 = data[i];
   Serial.print(i);
   Serial.print(" ");
   Serial.println(response1);
 }
}

void loop()
{
}

But I am just getting a string of mostly 0's, with some other numbers in there.

   int response1 = SPI.transfer(0xFF);

SPI.transfer() returns what data type?

But I am just getting a string of mostly 0's, with some other numbers in there.

Why do you assume that that is wrong?

I have tried Byte, and 8 bit integer data types. I tried int as well, just to see if it would work. It should be a byte.

Well, From the Lepton datasheet, I should be getting 164 "bytes" coming out of the lepton. 4 bytes as a header, then two strings of 80 characters: a temperature value, then a frame number.

So, It should look like:
1: 80
2: 23
3: 45

Etc etc, down to 80.
That's one row, I then process 60 rows to get the 80x60 image. That's my understanding at least.

So, I am not seeing the ordered frame numbers, and temperature information being all zeros isn't correct, since there's nothing in front of the camera that would be that cold.

I believe I am getting what are called "discard frames" which don't contain usable data.

I ran this through an Oscilloscope, and the CLK and MISO pins are looking good (they are outputting data). I am also getting numerical data out, but I can't seem to make any sense of it...

I got this working!

It turns out that I was misunderstanding the format of the data that the Lepton was outputting. I posted more information on this on my blog here:
http://phoenixgamedevelopment.com/blog/?p=1588

and here:
http://phoenixgamedevelopment.com/blog/?p=1608

If anyone is interested.

I also created a Github Repo for all of my code and resources here:

Hopefully that will be useful to anyone who runs into issues with this in the future.