Giter Site home page Giter Site logo

Comments (3)

maxritter avatar maxritter commented on May 20, 2024

Can you post the full code you are using to test this setup?

If you connect CLK to pin 14, you also need to issue startAltClockline() in addition to SPI.beginTransaction(SPISettings(20000000, MSBFIRST, SPI_MODE1)) and digitalWrite(pin_lepton_cs, LOW) to begin a transaction with the Lepton2.

What is the LeptonReadError retVal, when you try to read a package?

from diy-thermocam.

jandriea avatar jandriea commented on May 20, 2024

Hi Max, I'm using this code to test my Lepton module

I'm gonna use this fancy spoiler because the code is too long

#include "Wire.h"
#include "SPI.h"

#define USE_SPI1
/* Wiring
- SPI1
	-- CS	pin 6
	-- MOSI	pin 21
	-- MISO	pin 5
	-- SCK	pin 20
- SPI
	-- CS	pin 10
	-- MOSI	pin 11
	-- MISO	pin 12
	-- SCK	pin 13
*/

#ifdef USE_SPI1
#define pin_lepton_cs 6
#define pin_lepton_mosi (21)
#define pin_lepton_miso (5)
#define pin_lepton_sck  (20)
#else
#define pin_lepton_cs   (10)
#endif

void setup() {
	// put your setup code here, to run once:
	Wire.begin();
	Serial.begin(115200);

	Serial.println("Lepton module test");

#ifdef USE_SPI1
	// Initiate lepton SPI
	Serial.println("Init SPI1");
	pinMode(pin_lepton_cs, OUTPUT);
	digitalWriteFast(pin_lepton_cs, HIGH);
	SPI1.setMISO(pin_lepton_miso);
	SPI1.setMOSI(pin_lepton_mosi);
	SPI1.setSCK(pin_lepton_sck);
	SPI1.begin();
#else
	// Initiate lepton SPI
	Serial.println("Init SPI");
	pinMode(pin_lepton_cs, OUTPUT);
	digitalWriteFast(pin_lepton_cs, HIGH);
	SPI.begin();
#endif
}

void loop() {
	// put your main code here, to run repeatedly:
	int line = 0;
	byte leptonFrame[164];
	byte imageFrame[60 * 164];
	while (line != 60)
	{
#ifdef USE_SPI1
		// Start transaction
		SPI1.beginTransaction(SPISettings(20000000, MSBFIRST, SPI_MODE1));

		// Initiate CS pin
		digitalWriteFast(pin_lepton_cs, LOW);

		// Receive one frame over SPI
		for (int i = 0; i < (164 / 2); i++){
			// Read value via SPI
			leptonFrame[2 * i] = SPI1.transfer(0x00);
			leptonFrame[2 * i + 1] = SPI1.transfer(0x00);
		}

		// Disable CS pin
		digitalWriteFast(pin_lepton_cs, HIGH);

		// Stop transaction
		SPI1.endTransaction();
#else
		// Start transaction
		SPI.beginTransaction(SPISettings(20000000, MSBFIRST, SPI_MODE1));

		// Initiate CS pin
		digitalWriteFast(pin_lepton_cs, LOW);

		// Receive one frame over SPI
		for (int i = 0; i < (164 / 2); i++){
			// Read value via SPI
			leptonFrame[2 * i] = SPI.transfer(0x00);
			leptonFrame[2 * i + 1] = SPI.transfer(0x00);
		}

		// Disable CS pin
		digitalWriteFast(pin_lepton_cs, HIGH);

		// Stop transaction
		SPI.endTransaction();
#endif

		if ((leptonFrame[0] & 0x0F) != 0x0F){
			if (leptonFrame[1] == line){
				for (int i = 0; i < 164; i++){
					// Save frame
					imageFrame[(line * 164) + i] = leptonFrame[i];
				}
				line++;
			}
		}
	}

	// Print lepton frame ID
	for (size_t i = 0; i < 60; i++)
	{
		Serial.printf("%02X\t", imageFrame[(164 * i) + 1]);
		if (i % 10 == 9)
		{
			Serial.println();
		}
	}
	Serial.println();

	while (1);
}

The output should be like this

Lepton module test
Init SPI1
00	01	02	03	04	05	06	07	08	09
0A	0B	0C	0D	0E	0F	10	11	12	13
14	15	16	17	18	19	1A	1B	1C	1D
1E	1F	20	21	22	23	24	25	26	27
28	29	2A	2B	2C	2D	2E	2F	30	31
32	33	34	35	36	37	38	39	3A	3B

Somehow when I tried my code with CS at pin 15 and SCK at pin 14, it just hung up and never print any result (after init SPI) so I failed to replicate the same connection as DIY-Thermocam to make the lepton work.

the retVal value are 0,1, and sometimes 3

from diy-thermocam.

maxritter avatar maxritter commented on May 20, 2024

I am closing this issue now, as it's not directly related to the DIY-Thermocam.

from diy-thermocam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.