Jpeg serial camera returning 00 data

Hi guys

I’m using a link sprite ls-201y and the LinkSprite suggested code for that camera. I got the camera here:

http://www.tinyosshop.com/index.php?rou … uct_id=586

And on the same page link to its tutorial with this sketch:

/* Linksprite */
//SPITS OUT WHITE SCREEN SERIAL MONITOR SCROLLING DOWN BUT NO DATA SAVED TO SD
// could white spaces on monitor be the data?  if i let it run then it should show up as an image on sd car

#include <SoftwareSerial.h>

byte incomingbyte;
SoftwareSerial mySerial(4,5);                     //Configure pin 4 and 5 as soft serial port
long 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 4 second to send take picture command
      
      SendTakePhotoCmd();

     while(mySerial.available()>0)
      {
        incomingbyte=mySerial.read();
        Serial.print(incomingbyte);
      }   
      byte a[32];
      
      while(!EndFlag)
      {  
         j=0;
         k=0;
         count=0;
         SendReadDataCmd();

         delay(5000);
          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((byte)0x56);
      mySerial.write((byte)0x00);
      mySerial.write((byte)0x26);
      mySerial.write((byte)0x00);
}

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

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

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

I got help with the (byte) error & the software serial error.

Now I’m stuck at getting 00 bytes back as evidenced in the serial monitor and the resulting file I’m saving to the SD card.

I’m logging the incomingbyte to the serial and I that’s where I get 00

You’ve got a never-ending while-loop at the end of the loop function holding it up. That would only allow 1 frame to be processed.

P.S. Can you show the latest output on the serial port? I’m curious what the linksprite returns after you send a command.

Well the sketch is the one from linksprite tutorial:

http://learn.linksprite.com/jpeg-camera … h-arduino/

quique:
Well the sketch is the one from linksprite tutorial:

http://learn.linksprite.com/jpeg-camera … h-arduino/

Fair enough, it’s in there too. But your code looks a lot different that that, so may not behave the same way in timing. You may need a delay after calling the SendTakePhotoCmd() command. The code in the linksprite tutorial waits a full second, and even takes the time to open a file on the SD-card.

Also, the mySerial and normal Serial port are working at very different baudrate. That is going to create a bottleneck if the camera is streaming data faster than the Arduino can send to the pc.

Yes I agree. My originally posted sketch has been modified to the one linked to in my post (Sun May 10, 2015 7:12 pm) just above. I’m getting 00 bytes still. Ill try setting both serials at 38,400 or 19,200 and get back…