An attractive wireless camera node can be made using Texas Instruments CC3200 WiFi launchad.  This wireless camera will captures image and stores the image on SD card. The CC3200 acts as Wi-Fi Web server. By entering the IP address of web server on browser a web page stored in the SD card is loaded. The image taken by camera is displayed on that webpage.

Hardware requirements

·         CC3200 SimpleLink Wi-Fi LaunchPad,

·         Miniature TTL Serial JPEG Camera with NTSC Video,

·         SD card shield,

·         SD card,

·         Two 10 k resistors,

·         Jumper wires.

The whole project is based on Energia platform. The Texas Instruments CC3200 WiFi launchad will help us to create a wifi web server that will store the images.

Software Requirements

Hardware Configuration

The RX and TX pins are 10 and 9. The camera TX is connected to RX of CC3200 directly. RX should  not connected directly as it is TTL logic TX pin voltage has to be reduced, so it is connected to TX of CC3200 through voltage divider circuit.
            The SD card uses four GPIO of CC3200.MISO (Master In Slave Out) – The Slave line for sending data to the master,-Pin no: 14.MOSI (Master Out Slave In) – The Master line for sending data to the peripherals, -Pin no: 15.SCK (Serial Clock) – The clock pulses which synchronize data transmission generated by the master and one line specific for every device: -Pin no: 7.SS (Slave Select) – the pin on each device that the master can use to enable and disable specific devices. -Pin no: 18.
Import libraries

          include <SPI.h>
          #include <WiFi.h>
          #include <WiFiClient.h>
          #include <WiFiServer.h>
          #include "Adafruit.h"
          #include "SPI.h" 
          #include "pfatfs.h"

            Lets define pin 18 as cs_pin  ie chipselect pin . The read buffer size reccomends 128. We have to mention the camera connection whether it is sofware serial or hardware serial. Here we are using hardware serial -- &Serial1.

            #define cs_pin      18             // chip select pin 
          #define r_buff 128     // size (in bytes) of read buffer
          Adafruit cam = Adafruit (&Serial1);

The WiFi parameters have to mention. It is better to configure the IP rather than DHCP. As mentioned below the server will start at IP
                     // your network name also called SSID

          char ssid[] = "************";
        // your network password
          char password[] = "***********";
         // your network key Index number (needed only for WEP)
         IPAddress ip(192, 168, 251, 101);
          WiFiServer server(80);

In the setup function we can initialize the SD card.
                  FatFs.begin (cs_pin);

We can check whether the  camera is initialized in the setup() function.

        // Try to locate the camera
           if (cam.begin()) {
           Serial.println("Camera Found:");
           } else {
             Serial.println("No camera found?");

Set the image size
Wait for 3 seconds and take the snap. 

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

 Now the important part of the project is storing the image on SD card. Before that we have to check the size of image taken

      uint16_t jpglen = cam.frameLength();
      Serial.print("Storing ");
      Serial.print(jpglen, DEC);
      Serial.print(" byte image.");

        Petit FatFS SD Card Library  is not having any setup for creating a new file in the SD card, we can only modify the file already exist on the SD card. We have to store one image named sample1.jpg on the SD card after formatting.

         rc ="SAMPLE10.JPG");
        if (rc) die(rc);

      We can’t   write the image bytes whole at a time. We have to read 32 to 64 byte at time and write on the SD card file sample.jpg. we have to give some delay after each write otherwise it will leads to error.

         byte wCount = 0; // For counting # of writes
         while (jpglen > 0) {
         uint8_t *buffer;
         uint8_t bytesToRead = min(64, jpglen);

         buffer = cam.readPicture(bytesToRead);
         rc = FatFs.write(buffer, bytesToRead, &bw);


Now the image is taken and stored on SD card. We can move to loop () function. The web server should start. The web server hosts one webpage that links the image sample1.jpg. So we have to store one HTML page named as index.htm in the SD card. As follows.

                        <!DOCTYPE html>
                                           <title>CC 3200 web server with image </title>
                        <h1>CC 3200 web server with image </h1>
                             <img src="sample1.jpg" />

Now moving to web server part. Webserver is started port 80:

        server.begin();   // start the web server on port 80.

We have to save HTTP request characters  if any client is connected.

        if (client.available()) {
       char c =;
       if (req_index < (REQ_BUF_SZ - 1)) {
        HTTP_req[req_index] = c;// save HTTP request character

       Serial.print(c);  // print HTTP request character
      // to serial monitor
      // last line of client request is
      // blank and ends with \n
      // respond to client only after last line received
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");

 If any request is made by the client we have print the content to client from server. The html file index.htm and image is send to client.

        if (StrContains(HTTP_req, "GET / ")
          StrContains(HTTP_req, "GET /index.htm"))
         { rc  ="index.htm");        
         // open web page file
        else if (StrContains(HTTP_req, "GET /sample10.jpg")) {
       rc  ="sample1.jpg");
       // open  image file
         if (rc) {
                client.println("HTTP/1.1 200 OK");

 The file is opened and we have to write the content to client.

          for (;;) {
         rc =, sizeof(buffer), &br);   /* Read a                                    chunk of file */
        if (rc || !br) break;     /* Error or end of file */
            for (uint32_t i = 0; i < br; i++)
          {     /* Type the data */

After each write we have to reset the buffer

      // reset buffer index and all buffer elements to 0
     req_index = 0;
     StrClear(HTTP_req, REQ_BUF_SZ); 

Here is the prototype of camera and image taken by camera on browser


  1. good work man

    do you know how to control digital output pin using freeboard and dweet.
    i do not find widget on freeboard to control the output pin on cc3200 launchpad.

  2. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Home Automation in Chennai
    smart home in Chennai
    Home security in Chennai
    Burglar alarm in Chennai
    Wifi Camera Chennai

  3. Hello! I think is an excellent project! It's great!
    I'm using CC3200 for making a Web Page and send data from CC3200 to the page.
    I'm using a SD card for load the web page, but I don't know how to call it from SD in Energia.
    Do you have any idea?

    1. i m doing the same stuff .have you got any results?


Post a Comment

Popular posts from this blog

MSP430F5529LP + CC3100