"Camera Not Found" Arduino UNO TTL JPEG Serial Camera VC0706

Hi there,

I bought and wired up a VC0706 serial camera to my arduino UNO, and everything works great through the comm tool, but once I try running the example code provided, it says that the camera can’t be found. The TX and RX on the UNO are on pin 1 and 0, respectively, so I’ve changed that in the code, to no avail. If there’s any other info I can provide, I’d be happy to. Any help is greatly appreciated!

// This is a basic snapshot sketch using the VC0706 library.
// On start, the Arduino will find the camera and SD card and
// then snap a photo, saving it to the SD card.
// Public domain.

#include <Adafruit_VC0706.h>
#include <SD.h>
     

// SD card chip select line varies among boards/shields:
// Adafruit SD shields and modules: pin 10
// Arduino Ethernet shield: pin 4
// Sparkfun SD shield: pin 8
// Arduino Mega w/hardware SPI: pin 53
// Teensy 2.0: pin 0
// Teensy++ 2.0: pin 20
#define chipSelect 10

// Pins for camera connection are configurable.
// With the Arduino Uno, etc., most pins can be used, except for
// those already in use for the SD card (10 through 13 plus
// chipSelect, if other than pin 10).


// Using SoftwareSerial (Arduino 1.0+) or NewSoftSerial (Arduino 0023 & prior):
#if ARDUINO >= 100
// On Uno: camera TX connected to pin 2, camera RX to pin 3:
SoftwareSerial cameraconnection = SoftwareSerial(1, 0);

#endif

Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);



void setup() {

  // When using hardware SPI, the SS pin MUST be set to an
  // output (even if not connected or used).  If left as a
  // floating input w/SPI on, this can cause lockuppage.
#if !defined(SOFTWARE_SPI)
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  if(chipSelect != 53) pinMode(53, OUTPUT); // SS on Mega
#else
  if(chipSelect != 10) pinMode(10, OUTPUT); // SS on Uno, etc.
#endif
#endif

  Serial.begin(9600);
  Serial.println("VC0706 Camera snapshot test");
  
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }  
  
  // Try to locate the camera
  if (cam.begin()) {
    Serial.println("Camera Found:");
  } else {
    Serial.println("No camera found?");
    return;
  }
  // Print out the camera version information (optional)
  char *reply = cam.getVersion();
  if (reply == 0) {
    Serial.print("Failed to get version");
  } else {
    Serial.println("-----------------");
    Serial.print(reply);
    Serial.println("-----------------");
  }

  // Set the picture size - you can choose one of 640x480, 320x240 or 160x120 
  // Remember that bigger pictures take longer to transmit!
  
  cam.setImageSize(VC0706_640x480);        // biggest
  //cam.setImageSize(VC0706_320x240);        // medium
  //cam.setImageSize(VC0706_160x120);          // small

  // You can read the size back from the camera (optional, but maybe useful?)
  uint8_t imgsize = cam.getImageSize();
  Serial.print("Image size: ");
  if (imgsize == VC0706_640x480) Serial.println("640x480");
  if (imgsize == VC0706_320x240) Serial.println("320x240");
  if (imgsize == VC0706_160x120) Serial.println("160x120");

  Serial.println("Snap in 3 secs...");
  delay(3000);

  if (! cam.takePicture()) 
    Serial.println("Failed to snap!");
  else 
    Serial.println("Picture taken!");
  
  // Create an image with the name IMAGExx.JPG
  char filename[13];
  strcpy(filename, "IMAGE00.JPG");
  for (int i = 0; i < 100; i++) {
    filename[5] = '0' + i/10;
    filename[6] = '0' + i%10;
    // create if does not exist, do not open existing, write, sync after write
    if (! SD.exists(filename)) {
      break;
    }
  }
  
  // Open the file for writing
  File imgFile = SD.open(filename, FILE_WRITE);

  // Get the size of the image (frame) taken  
  uint16_t jpglen = cam.frameLength();
  Serial.print("Storing ");
  Serial.print(jpglen, DEC);
  Serial.print(" byte image.");

  int32_t time = millis();
  pinMode(8, OUTPUT);
  // Read all the data up to # bytes!
  byte wCount = 0; // For counting # of writes
  while (jpglen > 0) {
    // read 32 bytes at a time;
    uint8_t *buffer;
    uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
    buffer = cam.readPicture(bytesToRead);
    imgFile.write(buffer, bytesToRead);
    if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
      Serial.print('.');
      wCount = 0;
    }
    //Serial.print("Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");
    jpglen -= bytesToRead;
  }
  imgFile.close();

  time = millis() - time;
  Serial.println("done!");
  Serial.print(time); Serial.println(" ms elapsed");
}

void loop() {
}

You can NOT do hardware serial AND software serial on the same set of pins.

Oh, that makes a world of sense, I don't know why I didn't think of that. So I would just hook up the camera to different digital pins, e.g. 3,4 (I have another sensor hooked up to 2), and then change the code to 3,4 instead of 1,0?

Thanks!

You need to make sure that the arguments to the SoftwareSerial constructor are in the correct order. Otherwise, yes, that is what you need to do.

As well as, of course, paying attention in the future to what pins are used for what. Though I suspect that you'll remember to do that.

Yea, makes sense. Thanks so much! My project group and I are novices when it comes to Arduino, so I had no idea that the TX and RX pins on the UNO weren't meant for... well whatever we were using them for, haha.

Hey,

We are trying to connect the VC0706 to a Jeenode V6 and having the same issue. Camera module is never found in the example provided. We tried moving the software serial to pins 5 and 6 in order to isolate the software serial from the hardware serial. Any idea what else might cause a problem with software serial?

Thanks

We too are having issues. The camera is never found and I can not get the version number...

We had to add a bunch of 'inline' commands to the Adafruit_VC0706.h files. The raw example code was full of " multiple definitions" errors. dangle123 did you guys also have the multiple definitions error? if so how did you fix it?

Thanks for any more assistance guys!

We have fixed nothing and are very demoralized. Any help would be appreciated.

Any details would be appreciated

I have the same problem to, can any one help me to solve the problem ?

I have the same problem to

So, you too are trying to do SoftwareSerial on the hardware serial pins? What part of DON'T DO THAT do you think you can ignore?

I finally found the problem! Since the camera RX and TX pins work with RS232 standard, therefore you must convert them to TTL standard (by converting rs232 to tll using a module) or use the MAX3232 IC RX and TX (on the shield) directly and connect them to arduino. So :
Green wire must be connected to Arduino RX (software pin) and purple to Arduino TX.