C328R camera and Arduino

C328_arduino_sketch.pde (8981Bytes)
RunHandler.java (200Bytes)
SerialPortDataHandler.java (2236Bytes)

Well I've decided to replace my 2.4 ghz wireless camera on Ardbot with this guy:

JPEG Color Camera - UART Interface

While it isn't as capable as the video camera I had planned to use, it has the advantage of having a serial interface that can communicate with the Arduino, uses 3.3v, so my hope is to be able to stream the JPEG images via XBEE to my PC.

For some examples of others using the same camera, see here (pre-build library for Arduino), here (example usage of the Arduino library), and here (DIY Drones).

I've used Sean Voisen's C++ code as a base and inspiration for most of my Arduino code. His example shows you how to use his Arduino library to take snapshots with the camera, store them to an EEPROM, and then send the data through a serial port to a Processing sketch that displays the picture - turning the Arduino into a camera.

The problem that I wanted to solve was how to just immediately stream the image data out the serial port line on the Arduino. Sean's library uses the Arduino's built-in TX/RX lines to communicate with the camera and I need to have those available for other uses in the Ardbot. I've incorporated the NewSoftSerial Arduino library to allow me to control the camera using the other available digital pins on the Arduino and hopefully still use the built-in serial port for the XBEE communications.

I also wanted to learn about how the camera's communication protocol works at a low level so I've taken Sean's code and re-written it as an Arduino sketch.

The snapshot functionality is working in that I can capture the image and stream it back to the PC and see the resulting picture. It's only working at 9600 baud and I'm not sure if that is a limitation of the Arduino, the NewSoftSerial library, or my code :) I'm working now with how to stream video from the camera and capture/display on the pc.

I'm assuming that the maximum frames per second will be limited with this configuration but hopefully it will give my robot an 'eye' that doesn't suffer from the crowded 2.4 ghz band in his environment.

Here's an example picture taken at 160x128 resolution:

test_0.jpg

 

 

 

 

 

 

i've attached my Arduino sketch and the java code i'm running on the PC to capture the picture and write it to a file.

I run the "RunHandler" java class with the following command line args:

-Djava.library.path=/home/scott/rxtx-2.1-7-bins-r2/Linux/i686-unknown-linux-gnu -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0

after plugging the Arduino in to the pc and making sure that it's using /dev/ttyUSB0. Pressing the reset button on the Arduino syncs everything up, takes the snapshot, sends it to the java program. When the data is completely received, the java program writes the picture to "test.jpeg" and closes.

As I mentioned, I can't get any baud rate other than 9600 to work at this point...more to follow!

Camera-Squee!

I got the same thing, I am soooo grateful for this post because I need some help in the coding area…

Muchos Gracias Signor!

You used a sketch. Is is possible for an Ard. that is not connected to the PC to process a sketch? I want image processing on my robot, so if I can get it to take a pic, then process it while unconnected, I’m set!