Wireless Camera with Arduino and the CC3000 WiFi chip

One nice thing to have in any home automation or alarm system is a camera to see what’s going on remotely. Of course, such solutions already exists, and you even have WiFi cameras that you can buy for under $50. But they are not open-source, and therefore it is difficult to have the control on what’s going on, or to customize the interface. In 2012, a nice tutorial was published on how to build such a connected camera. You can find the tutorial here. We will do something different in this article: we will use the CC3000 WiFi chip and the Arduino platform, along with a serial camera, to build you own wireless camera. You will learn how to take still pictures from your home and display them on your computer remotely. Let’s dive in!

Hardware Requirements

The whole project is based on the Arduino platform, so of course you will need an Arduino board. I really recommend using the Arduino Uno board for this project, as it is the only board that is currently compatible with the CC3000 library at the time this article was written.

Then, you need the CC3000 chip. I recommend using the Adafruit CC3000 breakout board, which is the only one I tested that worked without problem. It is nice and compact, has voltage regulators onboard, as well as an onboard antenna. You can also make your own breakout board, as there are many PCB layout available online.

Then, you need a camera. I used a TTL serial camera from Adafruit. It is quite easy to connect and to use, thanks to a library developed for Arduino. It can take pictures up to 640*480. Not great, but enough to see what’s going on in your house. You will also need two 10K ohms resistors to connect the camera to the Arduino.

Finally, you need a breadboard and some jumper wires to make the connections between the different parts.

This is the list of the part that were used in this tutorial:

Software Requirements

For this project, you just need the usual Arduino IDE, and the Adafruit’s CC3000 library. To install a library, just download the required folder, and put it into your /Arduino/libraries/ folder. You will also need the library for the serial camera.

You will also need a web server running on your computer.

Hardware Configuration

The hardware configuration for this project is actually not that complicated, thanks to the good informations that you will find on the CC3000 breakout board. Connect the IRQ pin of the CC3000 board to pin number 3 of the Arduino board, VBAT to pin 5, and CS to pin 10. Then, you need to connect the SPI pins to the Arduino board: MOSI, MISO, and CLK go to pins 11,12, and 13, respectively. Finally, take care of the power supply: Vin goes to the Arduino 5V, and GND to GND.

Now, the camera. There are four pins to connect: the power pins VCC and GND, and the two serial pins TX and RX . Connect VCC to the 3.3V pin of the CC3000 board, and GND to the Arduino ground. After that, connect the TX pin to the Arduino pin number 2 using a voltage divider with the two 10K ohms resistors, following the picture below. Then, connect RX directly to the Arduino pin number 4.

The following picture summarizes the hardware connections:


Testing the Camera

In this part, we are simply going to test the camera. I also recommend testing if your CC3000 module is wired correctly. For that, please refer to this tutorial. The code for this part is available on our GitHub repository.

In this test sketch, we will just see if the camera is correctly recognized, and try to take a picture. It starts by importing the correct libraries:

#include <Adafruit_VC0706.h>
#include <SoftwareSerial.h>

Then, we have to create the correct objects to use the camera: a software serial connection on the right pins, and finally the camera object:

SoftwareSerial cameraconnection = SoftwareSerial(2, 4);
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);

Then, in the setup() function, we can check if the camera can be initialized:

if (cam.begin()) {
Serial.println("Camera found:");
 } else {
Serial.println("Camera not found !");

We also need to set the picture size:


Finally, after 3 seconds, we can try to take a picture:


if (! cam.takePicture())
Serial.println("Failed to snap!");
Serial.println("Picture taken!");

As usual, you will find the complete sketch on the GitHub repository of the project. You can upload the complete sketch, open the serial monitor, and you should see the following lines:

Camera test
Camera found
Picture in 3 seconds …
Picture taken!

Uploading a Picture on Your Computer

Now let’s dive in the core of the article: automatically uploading the pictures taken by the camera to your computer. We’ll keep it very basic: the Arduino will simply upload a picture at given time interval, and erase the picture that was uploaded before. But it is quite easy to modify the software to do some more advanced functions. The code for this project is available on our GitHub repository.

First, the Arduino sketch. I will really focus on the code to upload the picture to your computer, you can find the details of how to connect to a WiFi network in a previous tutorial. The whole difficulty in this project is to format the right HTTP message to send to the server. We will transmit the picture using a “multipart/form-data” content type. And for that, we need to know the exact length of the message we are going to send to the server. After taking a picture like in the test sketch, we need to know the size of the picture:

uint16_t jpglen = cam.frameLength();

The size of the data being sent will be this jpglen, plus the extra length of the headers around the picture. This is done by these lines:

start_request = start_request + "\n" + "--AaB03x" + "\n" + "Content-Disposition: form-data; name=\"picture\"; filename=\"CAM.JPG\"" + "\n" + "Content-Type: image/jpeg" + "\n" + "Content-Transfer-Encoding: binary" + "\n" + "\n";
end_request = end_request + "\n" + "--AaB03x--" + "\n";

We can then compute the final length of the message with:

uint16_t extra_length;
extra_length = start_request.length() + end_request.length();
uint16_t len = jpglen + extra_length;

We can then connect via TCP to the server:

Adafruit_CC3000_Client client = cc3000.connectTCP(ip, port);

And send the start of the request:

client.println(F("POST /arduino-camera-wifi/camera.php HTTP/1.1"));
client.println(F("Content-Type: multipart/form-data; boundary=AaB03x"));
client.print(F("Content-Length: "));

Now, we get to the part where we actually have to transfer the picture. We are going to send it chunk by chunk to the server. This is the loop that transfer the picture to the server:

byte wCount = 0; // For counting # of writes
while (jpglen > 0) {

 uint8_t *buffer;
 uint8_t bytesToRead = min(16, jpglen); // change to 32 or 64 for a speedup but may not work with all setups!

 buffer = cam.readPicture(bytesToRead);
 client.write(buffer, bytesToRead);

 if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
  wCount = 0;
 jpglen -= bytesToRead;

This code basically put the picture in a buffer of 16 bytes, and transfer it to the server with a write() operation. There are two parameters you can play with here: the size of the buffer, and the delay() at the end. I had to reduce the size to 16 bytes and add a 100 ms delay to actually make it work, otherwise the picture was corrupted when it arrived on my computer. So at the moment the file transfer is quite slow. It might work with other parameters for you, I would really be interested by your results!

We can finish with the end of the request:


You can go over to our GitHub repository to check out the complete sketch.

Now, the server part, which is much shorter. It is basically a PHP file, camera.php, that is called by the Arduino sketch. This is the content of the file:

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['picture']['name']);

if(move_uploaded_file($_FILES['picture']['tmp_name'], $target_path)) {
 echo "The file ". basename( $_FILES['picture']['name']).
 " has been uploaded";

else {
 echo "There was an error uploading the file, please try again!";

This code is actually quite simple: the main part is the move_uploaded_file command that move the $_FILES[‘picture’][‘tmp_name’] to the target path. It checks if this operation was successful, and return an error otherwise.

You can now upload the sketch, and look at the serial monitor. You should see the Arduino take the picture, connect to the server, and start uploading it:

Screen Shot 2013-10-01 at 10.15.54 AM

You can check the little dots on the Serial monitor to be sure it’s actually doing something. After a while, this is what was uploaded on my computer:


Of course, you can now use this code to develop some more advanced applications using this simple serial camera. It already has a built-in motion detector feature that I didn’t try yet, it would be an interesting application as well ! Note that in this tutorial, we will only cover a tiny part of the possibilities offered by the Arduino platform. If you want to learn more about the topic and discover more similar projects, I recommend checking out our main digital product, Home Automation with Arduino.

You have an idea on how to improve this tutorial ? You made it and developed some cool applications ? Please let us know by commenting below!

Like What You've Read?
If yes, join over 2,000 people who receive exclusive information about open-source home automation & the IoT. You will also receive my free eBook "Building a Simple Alarm System with Arduino". Simply click on the button below!
Get Started!
  • Sandro

    Great Job! I have a question. Is it possible with the same project to capture video and not a single image?

    • Unfortunately, the Arduino Uno board is not powerful enough for such tasks (live video streaming). But it might be possible using a Raspberry Pi or a BeagleBone (or some of the new Arduino boards that were recently announced like the Arduino Tre). Also, this camera is really meant for snapshots only and not for live video streaming.

  • Ibrahim Odeh

    Initially I would like to thank you for this great project.

    I am newbie here and I know the question that I will ask right now may be considered stupid question but to be stupid one time much better to be stupid for the whole life 🙂 …

    Can this project work independently I mean without connecting the Arduino to computer (PC) can this project works alone and send the captured image to some server? I believe that it must be connected initially to upload the code but my after uploading can I disconnect Arduino from the PC?

    Thanks in Advance.


    • Hello Ibrahim,

      Thanks for your question ! Sure, once it is uploaded to the board you can just connect the project to a power supply and it will just work by itself! You will just have to modify the sketch for your needs (for example, taking a picture every 10 minutes or so).

  • Pingback: Wireless Camera with Arduino and the Adafruit CC3000 breakout board « adafruit industries blog()

  • Pingback: Wireless Camera with Arduino and the Adafruit CC3000 breakout board | electronics-trade blog()

  • miguipda


    why not doing it with the last Arduino Yun which already have a wifi and could allow to use it as webserver inside.

    It will just need the motion detection facilities and it could become to have a perfect remote home survey.

    Have a nice day.

    Miguipda 😉

    It will then just need to add an independant IR with light (with sensibility switch) for night vision could be perfect.

    • Hello,

      The Arduino Yun is also a possibility. We love working with the CC3000 WiFi chip because it allows people to integrate the chip easily in their own products later 🙂

  • Amjad

    is there any cheaper Camera module?

    is this one good ?? CF0706C-V1 TTL Serial Camera Module

    • There definitely are cheaper cameras, but I guess the hard part will be to find a working Arduino library for that specific camera module.

  • martin

    Hi Marco,

    nice tutorial, thx.
    Did you manage to transfer the data faster?
    Its a pitty that it is so slow but I have to use the same settings as you do to make it work.

    cheers, martin

    • Hello Martin,

      Thanks for your comment ! Unfortunately not, I tried it again recently and it’s still slow. I don’t really know if it’s a problem in the library (cause the CC3000 chip can definitely handle faster transmissions) or the Arduino Uno microcontroller is just too slow to handle such a task.

  • Amit Kumar

    i m working on a quadrotor project for autonomous flight. i want to use the image taken by the camera to process it and use it for finding the position of the target.
    can this camera be implemented and how we can use it in such application???

    • Hello Amit,

      The Uno is not powerful enough for that, but I invite you to check the Yun tutorial that uses a camera and that I will release quite soon.

  • David Joy

    Can this be done using the Arduino Wi-fi shield for the UNO?

    • Hello David,

      For sure, the same can be done with the Arduino WiFi shield with only small modifications to the code. Look at the official WiFi shield documentation to know which part you have to modify.

  • Kris

    Im a newbie and I have a question. Say i have a website hosted by google drive, how do i connect to the site/server for sending/recieving data to the cc3000? All i have is the site URL..

    Thx anyway for great tutorial!

    • That’s something I didn’t work on yet, might be difficult (but not impossible) with the CC3000 chip. If you want to use ready-to-use web libraries and Arduino, I recommend using the Arduino Yun along with the Temboo service (https://www.temboo.com/)

  • Phil

    Great project and nice tutorial. Thanks for that 😉

    I jave one question. Do you think it’s possible to replace the cc3000 with a blietooth module and send the pictures to the computer over bluetooth?

    Thanks for reply

    • Hello Phil,

      Interesting comment, that should be possible in theory! You would have to transmit the picture chunk by chunk using Serial.write() commands, and then reconstruct it on the server side. Let me know if you have any success with this!

  • umair

    helo sir.
    our project is ” wifii controlled robotic vehicle with live video transmisson.:
    is this camera is suitable for us?, or guide us which one we use here.

  • zerul

    Hello sir…
    i want to ask about TTL camera, can i change this component with webcam..

    • Not in this project, it’s really only for this specific kind of cameras.

  • Lina


    Thanks for this code and example! I am trying to run it with my current setup, but it appears to stop after “Connected! ” in the Serial Monitor (i.e, the dots for processing never appear)

    I’m thinking it has something to do with camera.readPicture, but I’m not sure. I’ve changed it from 64 to 32 and still nothing. Any suggestions?

    • It’s quite a quite ‘experimental’ project, it’s tough for the little Arduino Uno to read a picture coming from the camera and then transmit. I recommend switching to the Yun and follow this article: http://www.openhomeautomation.net/wireless-security-camera-arduino-yun/

      • Lina

        Hi Marco thanks for the info. I’m actually using a Mega so ram shouldn’t be an issue. Upon closer inspection it appears that it is getting hung up writing to the client right before reading the camera. Not sure what could be causing this…

      • Guest

        So far I found that I got 408 211 error code in access_log on server side.

    • Guest

      I’ve used Arduino Uno and TTL camera to capture a picture and write it to a SD card. It worked fine, so this project should work fine too. However, I’ve experienced the same problem. It at least should work as you’ve did I assume:(

      Is that possible a problem of the power source? Adafruit website says people should use at least 1A but what I use is 500mA plus the USB.

      Or is that possible a problem of IDE? Which IDE were you use?

      I also saw people talking about bit-error artifacts here: https://forums.adafruit.com/viewtopic.php?f=22&t=53711 (people really loves this project.)

      Looking forward to get your feedback and appreciate!

    • Guest

      It looks like CC3000 library removed println method o_o||||

      They added a new method fastprint, and I found a few other methods however I am not sure which one should I use:

      void printHex(const byte * data, const uint32_t numBytes);
      void printHexChar(const byte * data, const uint32_t numBytes);
      void printIPdots(uint32_t ip);
      void printIPdotsRev(uint32_t ip);

  • Guest

    I am trying to run it with my current setup, but it appears to stop after “Starting connection to server ” in the Serial Monitor. What does the problem probably be? Thank you.

  • John Wang

    How to set the server part? Is this IP address my local ip or it’s the ip from the server?
    Really need to solve this issue, please let me know as soon as possible

    • It is indeed the IP address of your computer where the server is running, hope that helps!

  • PCVAL87

    Hello every

  • PCVAL87

    I am trying to get the serial camera to connect. The IP address I am using is the laptop I am using to run the Arduino IDE & it is connected to the same wireless network that the WiFi module is connected to. Also not sure where to put the string repository. I have it on the C: directory. Also port 80 is the default port. I am not sure how to check if it is being initialized or not. Any feedback would be very helpful. Thank you.

  • braggy

    Hi is it ok if I use the cc3000 wifi shield instead of the breakout board? I’m having problems with the wiring. I would really appreciate if someone can help me with this.. THanks! 🙂

  • Guest

    I’ve almost there. The code process good until client.connected(), and it says ‘Connected !’. However, it stops at there and ‘client.println’ did not show up accordingly.

    Server side works fine saying ‘There was an error uploading the file, please try again!’. 🙁

  • Guest

    Latest update: my code locks up at ‘client.print(start_request);’ 🙁

  • Guest

    Hey, I’ve just figured it out in this thread: http://forums.adafruit.com/viewtopic.php?f=19&t=61156

    “I have a feeling you’re hitting the limit on amount of data that can be sent in a single request. The transmit buffer is about 130 characters long, but the first 40 or so bytes are needed for internal CC3000 headers & parameters. This leaves 90 bytes free for request data”

    I fixed by following the instruction in this thread, however the picture did not show up in the dictionary T_T I am keep working on it….

  • Eivind Mork

    I tried to create this using the CC300 shield and an Uno. I ended up with corrupted images. I found your comments about adding a delay and reading 16 bytes at a time (not 32 or 64). When I add a delay the connection is dropped alf way through the transfer. Using wireshark on the computer it seems like the CC3000 just drops the connection. Any idea what is going on? Is it a problem to use too much time sending the data with a CC3000?

  • Mangpo Phitchaya Phothilimthan

    My code is stuck but at client.write(buffer, bytesToRead). Any suggestion how to make this work?

  • Dries


    I’m trying this code with the Arduino Wifi Shield. Anyone tried that?
    The code runs fine and it connects, sends the data, tells me that the Transmission is over and does not give any feedback. But the image is not uploaded. I don’t see any logs on my webserver…
    Any idea?

    • Ramanan Ramesh

      Please use a WebTraffic monitoring tool such as Microsoft Message Analyzer/Fiddler to check your HTTP Message.

      Also, try to construct your own HTTP Request using Fiddler and compare if what you send from Arduino EXACTLY matches that

      (Worked for me)

  • Deltan

    Hello Marco!

    Instead of using the SoftwareSerial library, can’t I use the digital pins tx and rx for the serial communication?

    • Hey Deltan! That should work indeed. But you will need to remove the camera when programming the board.

      • Deltan

        Aha, thanx!

  • Deltan

    buffer = cam.readPicture(bytesToRead); Is this when the arduino get the binary data from the camera?

  • Deltan

    Where should I upload the php file to? And can this be done using the ethernet shield?

    • Sure, that would work just as well with the Ethernet shield using a code like you suggested!

    • Ramanan Ramesh

      CC3000 understands your IP Address as a unsigned unicode 8bit integer.(uint8_t) (might be wrong on the exact definition).

      your host name translates to such a value , in this example, the variable ‘ip’ the cc3000.printIPdotsRev(ip) function displays the same value as 192.168.x.x value that we can read/understand.

      Hope that helps!

  • Max

    Hi Marco!
    Great tutorial! I’m definitely going to try.

    Just one question, I want to do same thing but instead of Wi-Fi to use a GSM shield.
    Is it possible to send the Photo to a cell phone?
    Which GSM module would u recommend? Can u help me with the code to such thing?

    Thanks a lot!

    • Hey Max! That should be possible with any GSM module, I have played with this one in the past: http://ow.ly/MzGRb. However never tried to send a picture with it, but that would be a nice thing to try!

  • Pierre


    Really nice article ! What the speed of the photo upload ? (how many photos can you take & upload in one minute ?)

    Is it realistic to use it in a RC car ? If not, what other solution can be use ?


    • Hello Pierre, thanks! Well it’s really slow as the project uses an Arduino Uno, so to use such a project in a RC car I would more recommend a USB camera connected to either an Arduino Yun or a Raspberry Pi.


    Hi,Thanks for this code and example!

    I’ve got some questions about wiring and the code.

    1. Could you explain why you wrote:
    SoftwareSerial cameraconnection = SoftwareSerial(A0, A1);
    but you wired pins 2 e 4 to the camera’s RX-TX?

    2. The voltage divider shouldn’t be on the camera’s RX?

    3. The camera’s alimentation input is 5V but it’s wired to the 3.3V port from the cc3000, why?

    Thanks a lot!

  • syamili

    hi,really nice tutorial
    I am working on similar project but instead of wifi module I have to use gprs shield..
    is it possible to send to web server?
    can you tell me how to do?

    • Sure, this is definitely possible. I don’t have any article yet about the GPRS shield, but continue to follow the blog to make sure you don’t miss it 🙂

  • Nguyễn Ngọc Quốc Duy

    PHP Notice: Undefined index: picture in C:inetpubwwwrootcamera.php on line 5
    PHP Notice: Undefined index: picture in C:inetpubwwwrootcamera.php on line 7
    i try to run it on webrowser with http:\localhostcamera.php => and it show these mistakes, some one can help me, please help me marco Schartz.
    i really want to know how you run our camera.php file.

    • AetherWu

      In your HTML code you should make sure that your input name=picture. The same as the index in your camera.php file $_FILES[‘picture’].

  • Nguyễn Ngọc Quốc Duy

    i run it but when i open camera.jpg file. it crashed like this. some one can help me.

  • AetherWu

    I eventually put everything all together to this post:

    The project runs perfectly expect it is a bit slow to upload to a cloud sever. I am moving forward to research on a SPI camera to replace the TTL serial camera. But I hope my post helps.

  • Ramanan Ramesh


    Could you please share the ASP.NET/WCF Equivalent of the upload code to post the image
    I do not have a PHP server set up but have a working IIS on my laptop.

    Any pointers would be much helpful.

    • Hi, I never used ASP.net, but all the best for your project!

      • Ramanan Ramesh

        Hi Marco Schwartz,

        My hardware setup includes the following:

        1. Arduino Mega
        2. SEEED Camera Shield
        3. CC3000 WiFi Shield with a SD Card slot.

        (all three stacked together)

        after so much trial and error, I got the image capture to save on the SD card on the WiFi Shield.
        But problem is now when I try to tx the image from SD card over wifi. The transmission either gets into an infinite loop or gets stuck halfway (I do not see any discernible pattern in this 🙁 )
        I have tested that the WiFi Shield without the Camera Shield is able to upload (the previously saved image from stack) properly onto the laptop’s IIS/local folder.

        Any direction/pointers on this tracking the source of the would be helpful 🙂

        • Hi Ramanan, I never used the Seeed camera shield so it’s gonna be difficult for me to help you for your issue.

          • Ramanan Ramesh

            I got mine to work!
            Made it work by adjusting the Baud Rate and adding some delay between the writes. 🙂


    Can i use an Arduino yun ?
    And will i be able to stream videos?
    Thanks 🙂

  • Dushyant Singh

    I am trying this with arduino wifi shield, I know it shouldn’t effect it but I am getting following error and I have no idea why

    HTTP/1.1 400 Bad Request
    Date: Fri, 06 Nov 2015 08:51:48 GMT
    Server: Apache
    Content-Length: 300
    Connection: close
    Content-Type: text/html; charset=iso-8859-1

    400 Bad Request

    Bad Request
    Your browser sent a request that this server could not understand.
    Request header field is missing ':' separator.

  • Dushyant Singh

    I am trying this with Arduino WiFi shield, I know it shouldn’t affect it but I am getting following error and I have no idea why. Also I have exact same post request as mentioned in the blog.

    HTTP/1.1 400 Bad Request
    Date: Fri, 06 Nov 2015 08:51:48 GMT
    Server: Apache
    Content-Length: 300
    Connection: close
    Content-Type: text/html; charset=iso-8859-1

    400 Bad Request

    Bad Request

    Your browser sent a request that this server could not understand.
    Request header field is missing ‘:’ separator.

    • The WiFi library is unfortunately quite different from the CC3000 library, so I imagine there will be several changes to make especially on timings.

    • Ramanan Ramesh

      Could you post what you construct in your HTTP Message please?

      Also, try some tool like Fiddler or Network Monitor or Microsoft Message Analyzer to see what goes down as the HTTP Message.

      That’s how I got mine to work 🙂

  • shelly

    Where is the picture uploaded?

  • Hello,

    Nice post about “Wireless Camera with Arduino and the CC3000 WiFi chip”. I like the concept and nicely explained. Thanks for sharing a great post.

    Donna Carter

    • Hello, thanks!

      • Khin Nyo Nyi Htwe

        In a weather wifi station cc3000 its ask password to install node.js what is the password to install node.js..PLease?

  • bj

    its really a great project Marco Schwartz
    …..but can it be implemented with esp8266-01 WiFi module

  • Jay

    Hi, Is it possible to use a 5V ready micro-SD breakout board+ from adafruit?