arduino + camera + sd memory card

I’ve had some recent success working with a 3.3V arduino pro, a camera module and SD memory so I thought I would share what I have so far to see if anyone has done something similar.
My end goal is to take pictures periodically and geotag them, putting gps cordinates in the exif section of the jpeg.
This is the camera module - http://www.sparkfun.com/commerce/product_info.php?products_id=9334
Letting this run in a loop (see sketch below) I was able to take 100pictures, storing them on SD without an issue.
There is a boilerplate EXIF header added to each JPEG until I figure out how to add GPS data that I will be reading from an attached module.
The software to interface to the camera module is a modified version of
http://gizmologi.st/2009/04/taking-pictures-with-arduino/

The software to interface to the SD card is
http://www.roland-riegel.de/sd-reader/#

This is the library that goes along with the sketch which is a combination of the above two with some modifications
http://jarv.org/sdcam/sdc328_20090922.tar

The module for interfacing to the camera was modified to work with an attached SD card. For SD pin connections you might want to check out this thread - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235125412

Note that with the arduino pro (pictured) since it operates at 3.3v you won’t need to step down the voltage.

In addition to the SD card and the camera an LED is connected to pin 2 which is what is used to report ERRORS (see SDCameraC328.h for a long list of error codes…)

The module is hard-coded to write picture0001, picture0002, etc. every time a snapshot is taken.

Here is the prototype:

And here is an example picture feature my very dark work area (yeah the camera isn’t that great…)

#include <SDCameraC328R.h>





void blink(int times);
void getJPEGPicture_callback( uint16_t pictureSize, uint16_t packageSize,
            uint16_t packageCount, byte* package);
#define ledPin 2
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 ));

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



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

}


void blink(int times) 
{
  if (!times) return;
  while (1) {
    digitalWrite(ledPin, HIGH);   // set the LED on
    delay(200);                  // wait for a second
    digitalWrite(ledPin, LOW);    // set the LED off
    delay(200);                  // wait for a second
  }
  delay(1000);  
}

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..
}

You look like some evil genius in the picture XD On the other hand, Pretty neat stuff, I didn't even know the arduino was capable of such things :O

lol yeah that's attacking the camera with a can of compressed air

Great job,

I am also involve in a similar proyect, but i am pretty new in arduino, so i am so so lost.

I use arduino duemilanove, a microSD (libelium), and the C328 camera. Could you show me how do you save the image in the SD?

I used your code and it seems to work, because when i open the serial windows, a sequence of symbols is wrote there, but the led only have light when i open the serial. May be since i didn´t do anything with the data (such as you propose in the comment at the end of your code, eg, save it in the SD), the sketch is waiting to do something...

And i neither know how to use Processing to see the image...

So any help will be very useful to me.

Thanks for your help!

since posting this originally I've managed to add geo-tagging to captured images using a LS20031 gps module. details posted here - http://jarv.org/sdcam.shtml

Thanks for the link. Looks like a great project. I will try to learn about how it works. Cheers,

I am trying to reproduce your project but compilation of your sketch giving me a lots of errors:

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c: In function 'sd_raw_init':

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:184: error: 'PB2' undeclared (first use in this function)

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:184: error: (Each undeclared identifier is reported only once

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:184: error: for each function it appears in.)

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c: In function 'sd_raw_read':

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:471: error: 'PB2' undeclared (first use in this function)

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c: In function 'sd_raw_write':

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:719: error: 'PB2' undeclared (first use in this function)

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c: In function 'sd_raw_get_info':

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:864: error: 'PB2' undeclared (first use in this function)

I am using "Adruino Duemilanove" and I get your latest code from jarv_org/sdcam.shtml

what version of avr-gcc are you using?

Nice!

wow! That's very usefull for me! ;)

I have got exactly the same error messages as Posox while compiling the program with AVR-GCC 4.3.4. Did anybody find our mistake ?

I think this is terrific and am looking at following your lead. First question though -the camera Nowhere does anybody give the resolution in megapixels. The photo of you looks a bit grainy but the one on the first site mentioned looks much better.

I'd like to start off with a decent camera image if I am going to spend the time

What would you use if you were to do it over?

@tytower - thanks! the max resolution is 640x480. check out http://jarv.org/sdcam.shtml for what I ended up doing with it eventually. It worked out well but I don't have any future plans beyond what I've done so far.

@stan49 - PB2 is just the pin number for the board, should be grabbing it from the include files. Not sure what is going on there with the arduino project. Maybe try the project from http://jarv.org/sdcam.shtml to see if you get better results?

Yes jarv I saw that before and liked the idea .

My question more concerned the resolution of the images .
Is there a sample of what you shot over the park ?

If you were doing it over would you use the same camera or seek a better one?

yeah check out the flickr set here → http://www.flickr.com/photos/43574582@N05/sets/72157622621272658/

quality is not that great, i’m not sure what i would use the camera for given the low quality. With digicams as cheap as they are which can be controlled with a relay I don’t know how useful it is unless you are interested in direct image manipulation.

hello everyone, i'm newbie in this forum..

this is my first time experience using arduino and i'm interesing in this project and this post is very usefull for me..

but i still understand how to interface the sd card with the EEPROM..

I'm using Arduino Deamilanova, Breakout Board for SD-MMC Cards and C328 camera module

thank you very much for your help.

I think that the 1st question isn't

how to interface the sd card with the EEPROM

. The 1st question is why?

What is it you want to do that involves both EEPROM and the SD card?

okay i get it now..

EEPROM and SD/MMC Card both are same memory.. i don't need to us both of them at the same time..

thank you very much for the information.. this is my first project on arduino

I'm already compiling the sketch the code from jarv website http://jarv.org/sdcam.shtml

but i get some errors here (same like posox and stan49) :

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c: In function 'sd_raw_init':

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:184: error: 'PB2' undeclared (first use in this function)

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:184: error: (Each undeclared identifier is reported only once

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:184: error: for each function it appears in.)

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c: In function 'sd_raw_read':

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:471: error: 'PB2' undeclared (first use in this function)

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c: In function 'sd_raw_write':

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:719: error: 'PB2' undeclared (first use in this function)

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c: In function 'sd_raw_get_info':

/Users/posox2000/Documents/Arduino/libraries/sdc328/sd_raw.c:864: error: 'PB2' undeclared (first use in this function)

I am using "Adruino Duemilanove" and arduino0017 as compiler

i already read the latest post on this topic but i can't find the answer.. can you guys help me?

thanks

Bumping this thread, has there been a resolution to the above issue? I tried the same thing. Downloaded the package from:

http://jarv.org/sdcam.shtml

Tried to compile the example code and got the following error:

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c: In function 'sd_raw_init':

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c:184: error: 'PB2' undeclared (first use in this function)

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c:184: error: (Each undeclared identifier is reported only once

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c:184: error: for each function it appears in.)

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c: In function 'sd_raw_read':

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c:471: error: 'PB2' undeclared (first use in this function)

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c: In function 'sd_raw_write':

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c:719: error: 'PB2' undeclared (first use in this function)

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c: In function 'sd_raw_get_info':

/home/erik/arduino-0018/libraries/sdc328/sd_raw.c:864: error: 'PB2' undeclared (first use in this function)

any advice would be appreciated

grayscale: debes entrar a sd_raw_config.h y cambiar:

#define select_card() PORTB &= ~(1 << PINB2)
#define unselect_card() PORTB |= (1 << PINB2)
#define configure_pin_available() //DDRC &= ~(1 << DDC4)
#define configure_pin_locked() //DDRC &= ~(1 << DDC5)

#define get_pin_available() 0 //((PINC >> PC4) & 0x01)
#define get_pin_locked() 0 //((PINC >> PC5) & 0x01)

luego te vas a sdcamera.cpp y pones en comillas

SDCameraC328R::SDCameraC328R()
{
_packageSize = DEFAULT_PACKAGE_SIZE;
_sd = 0;
_file_counter = 0;
/** set_output(DDRD,LED); */
strcpy(filename, “picture.jpg”);

suerte.

HOW READ THE SD CARD…I CANT READ SD CARD