How to comunicate C28 camera ???

Hi everybody !!!

I have the C328 camera, an arduino duemilanove and a SD module. And I want to save the photos of the camera in the SD memory. I’ve been reading many posts of the camera and the SD module but now I’m confused.

I’m using SDCameraC328R.h library because it also has the necesarry functions for the SD memory

#include <SDCameraC328R.h>//librereria para la camara de fotos

SDCameraC328R camera;

void setup()
{  
  
  camera.sync(); // iniicializa la comunicacion con la camara
  camera.initial( SDCameraC328R::CT_JPEG, SDCameraC328R::PR_80x60, SDCameraC328R::JR_640x480 );
  //configuracion de la camara
  camera.setPackageSize( 100 );
  camera.setLightFrequency( SDCameraC328R::FT_50Hz );
  
  delay(1000);
}

void loop()
{
       tomamuestras();
      delay(1000);   
}

void tomamuestras(){
  //tomar fotografias con una secuenia de posiciones de los servomotores
  camera.InitializeSD()
      camera.snapshot( SDCameraC328R::ST_COMPRESSED, 0 );
      camera.getJPEGPicture( SDCameraC328R::PT_JPEG, PROCESS_DELAY, &getJPEGPicture_callback);
     
    }
  
  }

}

void getJPEGPicture_callback( uint16_t pictureSize, uint16_t packageSize, uint16_t packageCount, byte* package )
{
}

I don’t find what is wrong with my code, so I hope you can help me, please!!! :-[

I don't find what is wrong with my code, so I hope you can help me, please!!!

You need to tell us what the problem is. Does the code not compile? Does it compile but not do what you want? What is it that it does that it shouldn't? What does it not do that it should?

What exactly is your callback function doing, do you know?

Well, my problem is that I can’t get the camera take photos and save them in the SD. Also you probably are right and is not the code maybe are my connections. this is my diagram. The camera Rx is connected to the Tx of the arduino and the camera Tx is connected to the Rx of the arduino

http://www.subirimagenes.com/otros-esquematicoarduinos-5075934.html

Thanks for help me !! :slight_smile:

I still didn´t go ahead to interface arduino and sd cards.

However, i saw this wiring scheme: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206874649/8

He uses resistances connected to different pins and ground. However, you use other component in the middle. So i don´t know if this could help to you or not. Just only an idea.

On the other hand, you don´t show how you have wired your C328R camera to arduino. it could also help.

Cheers,

[edit]OK, you say in your previous post how you wire the camera. I think that is not correct.

Take a look the third image of this post, the wiring scheme: http://arms22.blog91.fc2.com/blog-entry-261.html

I tried it and it works perfect for me!! So may be the problem is how you wired the camera. You could also test the code from this page to know if you could take images previously to store them into a SD.

Good Luck![/edit]

Well, my problem is that I can't get the camera take photos and save them in the SD.

How do you know that the camera is not taking the picture?

In the tomamuestras() function, you call camera.InitializeSD() to initialize the SD card. That function might or might not return a value indicating whether it was successful. If it does, you ignore it.

Then, you call camera.snapshot( SDCameraC328R::ST_COMPRESSED, 0 ); to take the picture. Again, that function might or might not return a value indicating whether it was successful. If it does, you ignore it.

Finally, you call camera.getJPEGPicture() to register a callback function that actually deals with the picture that was just taken (if one was).

In that callback, you do this:

void getJPEGPicture_callback( uint16_t pictureSize, uint16_t packageSize, uint16_t packageCount, byte* package )
{
}

It's hardly surprising, then, that nothing is written to the SD card.

How much magic are you expecting to have happen?

First of all thank you for all your help, but I continue with my problem :'( I made many tests and nothing Any other idea ?? . PaulS I understand your point but I don't know how to do it. Could you explain me please ??

Again thanks for your help and support!!!

I understand your point but I don't know how to do it.

You don't know how to do what?

Add Serial.begin() to setup(), and Serial.print() and Serial.println() statements to the loop() and getJPEGPicture_callback() functions, to see what is happening.

If the problem is in actually transferring the data passed to the getJPEGPicture_callback() function to the SD card, that shouldn't be too hard. But, you have no include file referencing a SD card library, and you are not initializing the access to the SC card.

First of all take some time to look for answers - plenty of people here have done a lot of the upfront work and provided real code to test as well as working real-life examples.

Do a search of the forums, both Sparkfun and Arduino - use Google...

Then when you have some real code not just guesswork lines and empty functions, let us know what's happening.

here's a good start: http://jarv.org/sdcam.shtml and the post that started that one has many other references in it.. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1253595882/

Hi !

Again me, I had been working in the camera and reading a lot. Now my code is different but it isn’t work yet :frowning:

#include <SDCameraC328R.h>

void blink(int times);
void getJPEGPicture_callback( uint16_t pictureSize, uint16_t packageSize,
            uint16_t packageCount, byte* package);
#define ledPin 13
SDCameraC328R camera;

void setup()   {
    Serial.begin( 57600 );
    blink();
  
    camera.InitializeSD();  // setting up the SD will result in images written to an attached SD card
    blink();
    
   camera.sync();
   blink();
       
    camera.initial( SDCameraC328R::CT_JPEG, SDCameraC328R::PR_80x60, SDCameraC328R::JR_640x480 );
    blink();
    
    camera.setPackageSize( 100 );
    blink();
    
    camera.setLightFrequency( SDCameraC328R::FT_50Hz );
    blink();
    

    // Let camera settle, per manual
    delay(2000);
}



void loop()
{
                camera.snapshot( SDCameraC328R::ST_COMPRESSED, 0 );
blink();
                camera.getJPEGPicture( SDCameraC328R::PT_JPEG, PROCESS_DELAY, &getJPEGPicture_callback);
blink();
                delay(10000);

}


void blink()
{
    digitalWrite(ledPin, HIGH);   // set the LED on
    delay(1500);                  // wait for a second
    digitalWrite(ledPin, LOW);    // set the LED off
    // wait for a second
    delay(2500);
}

void getJPEGPicture_callback( uint16_t pictureSize, uint16_t packageSize, uint16_t packageCount, byte* package )
{
   // if not writing to an SD card do something with the image data here..
}

According to my code a led is going to blink for each process that it make, but I only get 2 blinks, so I think that camera is not sync, and I don’t why . Some ideas??

thnks !!!