Click here to Skip to main content
13,251,760 members (88,570 online)
Click here to Skip to main content
Add your own
alternative version


21 bookmarked
Posted 5 Apr 2009

C328R Serial Camera Example with xBee using C#

, 5 Apr 2009
Rate this:
Please Sign up or sign in to vote.
C328R Serial Camera Example with xBee using C#


This is an example program on how to capture pictures with the CR328R serial camera using an xBee module hooked to your PC and an xBee module hooked to the CR328R camera.  In theory you shoudl be able to use a serial interface from you PC directly hooked into the camera and be able to use this software.


I am buidling a tank robot that can be driven with a Wii Mote interfaced with my PC, and my PC then relays the commands to my tank using the xBee Pro, which has a 1 mile range. When I did that I wanted to upgrade the range of the camera I was using because my old camera's range was only 100' or less. So I decided to use a serial camera and the xBee module so the range of my camera would be the same range of my tank.

I built my work on this application based on the great work of Pavel Bánský, who created a class to get pictures from the CR328R camera from a hardware device called the Tahoe development board that used the .NET Micro Framework. Because he used the .NET Micro Framework I only had to modify the code to use the SerialPort class and to account for the small buffer size the xBee has.

Hardware Connections

I hooked the TX pin of the camera to the DIN pin of the xBee. Then I hooked the Rx pin of the camera to the DOUT of the xBee. Because the camera and xBee module both work at 3.3 volts I used a 3.3V voltage regulator to power the camera and xBee. I also hooked a resistor in series with an LED between the PWM0 pin and ground. This will let you know when your xBee is receiving information.

My xBee Pro is set to 57600 baud.


When the program starts hit "Init" so the camera can start up and initialize to the baud rate of the xBee.  After that you can hit "Get Now" which uses the GetJpegPicture function to take the picture and immediatly start transfering it to your computer.  Or you can hit "Snapshot" which stores the JPEG image on the built in memory on the camera, then start transfering it to your computer.  Once these work for you hit "Movie" to display a clip of 10 sequential pictures. 

Points of Interest

I was only able to get the JPEG options for this camera working so the GetRawPicture function doesn't work.  I believe this is due to the small buffer size of the xBee.  Because the GetRawPicture function doesn't work framerate is limited.  In 80X64 I have only been able to get 1 frame every 1.14 seconds, in 160x128 I can only get a frame every 2.5 seconds, and it gets progresevly worse from there.  I am hoping in the fugure to figure out a way to get GetRawPicture working.

It's can befrustrating working with this camera.  Sometimes it seems it doesn't want to take pictures so you have to hit Reset or Init Camera.  It seems like if you don't constantly take pictures the camera or xBee goes to sleep so I have to hit Reset to wake it up.  Other times I have to restart the application. 

Outstanding Tasks

1. Make it more reliable.
2. Speed. Try to get GetRawPicture working to see if I can get the framerate up by reducing the color depth.


4/4/2009 - First Release 


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionCamera trap Pin
Sachit Naik22-Apr-13 21:36
memberSachit Naik22-Apr-13 21:36 
GeneralAnother camera please do help me Pin
tarekkkkk28-Nov-10 10:52
membertarekkkkk28-Nov-10 10:52 
QuestionA little assistance Pin
ushal26-Oct-09 14:55
memberushal26-Oct-09 14:55 
GeneralXBee Camera Pin
dktran25-Aug-09 16:29
memberdktran25-Aug-09 16:29 
GeneralRe: XBee Camera Pin
pyrokin30-Aug-09 18:57
memberpyrokin30-Aug-09 18:57 
GeneralRe: XBee Camera Pin
dktran31-Aug-09 10:32
memberdktran31-Aug-09 10:32 
GeneralRe: XBee Camera Pin
funkotron7631-Aug-09 11:23
memberfunkotron7631-Aug-09 11:23 
The program is written for AT mode i.e. serial line replacement. I used an xBee Pro Series 2.5, but I would think the others would work fine too. I don't know what firmware I was using, but that doesn't really matter.

I used the Router, End Device to connect to the camera. But I think you could use the coordinator too.

I would make sure that your xbees are actually talking to each other. I used 2 xBee explorers (from SparkFun) connected to the pc's serial ports. Then you can either create a program to have them talk back and forth like I did or you could use hyperterminal.
GeneralRe: XBee Camera Pin
dktran31-Aug-09 11:52
memberdktran31-Aug-09 11:52 
GeneralUsing the same setup. Pin
pyrokin3-Jul-09 18:58
memberpyrokin3-Jul-09 18:58 
GeneralCool stuff!! Pin
Mubi | www.mubshir.com17-Jun-09 9:55
memberMubi | www.mubshir.com17-Jun-09 9:55 
GeneralMy vote of 1 Pin
Sacha Barber5-Apr-09 5:56
mvpSacha Barber5-Apr-09 5:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171114.1 | Last Updated 5 Apr 2009
Article Copyright 2009 by funkotron76
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid