Library for COMedia C328R Serial Camera

Hey guys,

I just started working with this camera and Arduino and I have programmed the Arduino as in the last post, but I do not know what to do with the callback method. What should it include in order to send the photo via software serial to my computer and save it as a jpeg image?

Thank You!!!!!!!

I am trying to interface the C328R module with Arduino. I would really appreciate if you could post a picture showing how you interfaced your C328R with Arduino.

Hi folks. Somehow I missed these messages. I've been away on vacation in Hawaii :)

I'm going to make the changes to the library today and tomorrow, as well as post the relevant sample code to get the camera working on my blog: http://gizmologi.st

I will update here when all that is done.

Cheers, Sean

I am working on a project that involves Arduino, XBee Transceivers and C328R.
The camera will capture the image and send it to the other transceiver which will be connected to the PC using XBee Explorer.

Right now I am trying to interface C328R with arduino using C328R library that Sean posted. I would greatly appreciate if someone could post a simple code that will store the snap shot in the C328R’s EEPROM and then send it to the PC after 7 sec , using Sean’s library for C328R.Code with comments is always helpful.

The pins of the camera module are setup as follows:
-GND goes to GND
-Vcc goes to 3.3 Vdc
-Rx goes to Arduino Tx and so forth
No internal circuitry between the Module and Arduino is present. Every thing is directly connected through wires.

Thanks Enzo. It looks like my problem was the baud rate. I am using the Arduino Pro Mini at 3.3V and for me this class only worked when I talked with it between 28800 and 33600.

Alibaba, your connections sound fine. However, keep in mind that the serial pins on the Arduino are hardwired to the USB serial. This may cause some problems if both the camera and the computer are communicating with the Arduino over serial.

I've never used XBee, so I can't help you there. I believe that is the method Enzo was using however. I store the photo on an external Atmel EEPROM using SPI (using getJPEG), then I power off the camera, then use the same hardware serial to send it to the computer.

There is a small bug I'm trying to fix where the last ACK command is getting sent over as JPEG data. Once I fix that I'll post the code.

NEW VERSION (v002): http://gizmologi.st/downloads/c328r_arduino

Changes:

  • A few internal optimizations (sendACK)
  • Added keywords.txt for syntax coloring
  • Fixed warnings when library is compiled the first time
  • Imported WProgram.h so you don't have to
  • getJPEGPicture callback now sends a pointer to first byte in picture data per packet, so no need to skip the first 4 bytes of each data packet

Let me know if you encounter any bugs. Next step is to post sample code/schematics. Hopefully later today.

Hey svoisen and enzo,

I put in the callback the following code:

for (int i=0; i < packCount; i++){
softSerial.print(pack*, BYTE);*
}
but when I try to save the hex output as a jpg image it does not show an image. I also get a very small output, something like 250 bytes.
What should I put in the callback method, using the new library?
Thanks,
Anthony

Hi Antoniss,

Well, you don't want to loop up to packCount, as that is the count of the actual image packages and not a count of the bytes within each individual package.

The callback will be called every time the camera sends a package of JPEG data, and it may take many of these packages to make a full picture.

So, what you want to do is loop from 0 to packageSize (2nd param in callback) and store those bytes in an array buffer. Then, once the size of your buffer is equal to the pictureSize (1st param), you know you have a full image in the buffer. The packageCount param is actually not terribly useful for most purposes, but I put it there just in case.

Hope that helps.

svoisen thank you very much for your help!!!

Could you please post an example with the code where I save a complete image to the EEPROM of the Arduino using the new library?

Anthony - Absolutely. I keep getting swamped with work but I will definitely post the example by tomorrow.

Note: You can’t use the Arduino’s EEPROM, because it is not big enough. My example will use an external EEPROM on a breadboard, connected using pins 10-13 for SPI communication. If you don’t have one, I suggest getting a 128K or larger Atmel brand EEPROM chip from Digi-Key or similar.

The tutorial on how to use this library (with sample code) is now up on my blog: http://gizmologi.st/2009/04/taking-pictures-with-arduino/

Hope that helps!

I modified the code at http://bansky.net/blog/2008/03/jpeg-camera-and-micro-framework/comments.html to send a picture to my PC with the camera directly hooked into the camera. It’s about as fast as I can get it. Using resolution 80X64 I can get about 0.88 frames per second displayed to my PC. What kind of frame rate are you guys getting displayed to your PC using your method through the Arduino?

Hi Rick - Haven't tried video yet. The whole "getRawPicture" method is untested at the moment.

I hope to try it when I get a chance, but it's not a requirement of my current project so it may be later than sooner. If you manage to get to it before I do, please post your results :)

OK thanks, I haven't gotten the GetRawPicture function working yet either.

For my previous comment I ment to say that I got the camera directly hooked to an xBee pro module. Then I have an xBee hooked to my pc. That is how I am relaying the image.

Also, I have an article posted at http://www.codeproject.com/KB/recipes/C328R.aspx that has the code for this.

Hey guys,

my camera does not even sync! Why could this happen?

Thanks, Anthony

It is also weird, because I get the fail for the sync in less than 5 seconds and as response time I have 500, max sync attempts I have 60, so I should wait for at least 30 seconds untli I get a fail. Why does this happen?

Thanks, Anthony

I dont know if you do this. But i always reset by Hardware the C328R camera. And i do many timeout consistence during PACKAGE receiveing... I used a PIC to create a CAMERA INTERFACE to TELIT MODULE... tcpipchip @ hotmail.com

Hello,

Great library :) I want to start using the C328 but have some questions:

If possible I would like to send the pictures and video using a wireless connection (2 x nrf24L01 and 2x Arduino Mega).

Sending pictures is not so difficult I think. This is a single file that I will store on a SD card and send wireless (chopped into little packets) to the host. Correct me if I am wrong.

What format is the video (i am not experienced on this area)? Will this be separate pictures send with a high rate (frame rate)? Or is this a raw format (one continuous stream)? I've heard that sending a raw format (one continuous file) is very difficult for a beginner.

How fast can pictures be taken using the still mode? Is there a delay?

I would like to start experimenting with this camrea but first would like to get some answers :)

Sending photos wirelessly is possible. I've not done it yet, but from my understanding enzo (in this thread) has done it using the XBee system.

If you've not used the Arduino to read and write to a microSD card, it's not as straightforward as it seems. I have managed to save photos to microSD using the uFAT library for Arduino, but not without significant modification to the library code (the uFAT library was designed primarily for storing text, not arbitrary bytes). Also, uFAT only reads/writes existing files rather than allows you to create new ones (all the JPGs on your card need to pre-exist - I created empty files of appropriate size).

However, if you're just sending images to a computer host, there's really no need to store them on an SD card beforehand. Just transmit them as you receive them. The camera has a built-in EEPROM that will store one snapshot at a time.

Nobody has yet experimented with the video to my knowledge. Basically, you would get the RAW, uncompressed images as a series of frames, not a single video file. This is good news, but I'm not sure about the framerate. The camera is not terribly fast, and even at 112,500 kbps baud transmitting 640x480 JPG images does take a few seconds. My guess would be that at 160x120 RAW you might get 5 fps or so. But, that's just a guess.