Jump to content
Sign in to follow this  
quique

JPEG IR Camera for Arduino/Mac

Recommended Posts

Hi,

 

I need help getting my linksprite camera to work properly.  From what I gather,

 

1)  Given that the sketch included by the manufacturer here: https://www.sparkfun.com/products/11610 which links to this file: https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/LinkSprite_Cam_IRa.zip, doesnt work...

 

 

2)  It is imperative that I test the unit with a direct connection from my Mac to the camera.

 

I would like to know what options I have, short of buying a USB-Serial cable which I am unable to find locally at the moment.  Is there any other way to find out if this unit is working?

 

This is what my camera looks like and here is my sketch:

/****************************************************************************** 
LinkSprite_Cam
Ryan Owens @ SparkFun Electronics>
Revised by Joel Bartlett on 03/25/15 for compilation on Arduino 1.6+

This code allows you to control the LinkSprite IR Camera (SEN-11610) with an Arduino microcontroller

Development environment specifics:
Arduino 1.6.0

This code is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round!

Distributed as-is; no warranty is given. 
*********************************************************************************/
#include <SoftwareSerial.h>

/* Linksprite */
byte incomingbyte;
SoftwareSerial mySerial(5,6); // RX, TX         //Configure pin 4 and 5 as soft serial port

int a=0x0000,j=0,k=0,count=0;                    //Read Starting address       
uint8_t MH,ML;
boolean EndFlag=0;
                               
void SendResetCmd();
void SendTakePhotoCmd();
void SendReadDataCmd();
void StopTakePhotoCmd();

void setup()
{ 
  Serial.begin(19200);
  mySerial.begin(38400);
}

void loop() 
{
     SendResetCmd();
     delay(4000);                               //After reset, wait 2-3 second to send take picture command
      
      SendTakePhotoCmd();

     while(mySerial.available()>0)
      {
        incomingbyte=mySerial.read();

      }   
      byte a[32];
      
      while(!EndFlag)
      {  
         j=0;
         k=0;
         count=0;
         SendReadDataCmd();

         delay(25);
          while(mySerial.available()>0)
          {
               incomingbyte=mySerial.read();
               k++;
               if((k>5)&&(j<32)&&(!EndFlag))
               {
               a[j]=incomingbyte;
               if((a[j-1]==0xFF)&&(a[j]==0xD9))      //Check if the picture is over
               EndFlag=1;                           
               j++;
	       count++;
               }
          }
         
          for(j=0;j<count;j++)
          {   if(a[j]<0x10)
              Serial.print("0");
              Serial.print(a[j],HEX);
              Serial.print(" ");
          }                                       //Send jpeg picture over the serial port
          Serial.println();
      }      
     while(1);
}

//Send Reset command
void SendResetCmd()
{
      mySerial.write(0x56);
      mySerial.write((byte)0);
      mySerial.write(0x26);
      mySerial.write((byte)0);
}

//Send take picture command
void SendTakePhotoCmd()
{
      mySerial.write(0x56);
      mySerial.write((byte)0);
      mySerial.write(0x36);
      mySerial.write(0x01);
      mySerial.write((byte)0);  
}

//Read data
void SendReadDataCmd()
{
      MH=a/0x100;
      ML=a%0x100;
      mySerial.write(0x56);
      mySerial.write((byte)0);
      mySerial.write(0x32);
      mySerial.write(0x0c);
      mySerial.write((byte)0); 
      mySerial.write(0x0a);
      mySerial.write((byte)0);
      mySerial.write((byte)0);
      mySerial.write(MH);
      mySerial.write(ML);   
      mySerial.write((byte)0);
      mySerial.write((byte)0);
      mySerial.write((byte)0);
      mySerial.write(0x20);
      mySerial.write((byte)0);  
      mySerial.write(0x0a);
      a+=0x20;                            //address increases 32£¬set according to buffer size
}

void StopTakePhotoCmd()
{
      mySerial.write(0x56);
      mySerial.write((byte)0);
      mySerial.write(0x36);
      mySerial.write(0x01);
      mySerial.write(0x03);        
}

post-4650-0-55898000-1442521975_thumb.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×