In the description of the ttl serial camera it says that you can change the baud rate of the camera. But how is it possible?? I tried changing the baud rate in the Adafruit_VC0706.h document of the library. But when I change 38400 to for instance 115200 I get the error message that my camera was not found.
So how can I transmit the data from camera faster. For one image it takes about 15 seconds using the example of the Adafruit example.
Changing the baud rate of the ttl serial camera
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 4
- Joined: Sat Dec 01, 2012 3:16 pm
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Changing the baud rate of the ttl serial camera
The sketches use Arduino SoftwareSerial, which really can't run reliably above 38400bps. You would have to use hardware serial to get up to 115200.
- t.praveen
- Posts: 31
- Joined: Fri Apr 05, 2013 8:17 pm
Re: Changing the baud rate of the ttl serial camera
Good day,
I am currently using hardware serial via the lib ray provided by Adafruit, I intend to use 115200 baud rate, to capture these images faster and dump it in my sd card...Where do I make these baud rate changes? In the library or cam.begin(115200)..
Thank you very much in advance...
I am currently using hardware serial via the lib ray provided by Adafruit, I intend to use 115200 baud rate, to capture these images faster and dump it in my sd card...Where do I make these baud rate changes? In the library or cam.begin(115200)..
Thank you very much in advance...
- t.praveen
- Posts: 31
- Joined: Fri Apr 05, 2013 8:17 pm
Re: Changing the baud rate of the ttl serial camera
Good day,
I am currently using hardware serial via the lib ray provided by Adafruit, I intend to use 115200 baud rate, to capture these images faster and dump it in my sd card...Where do I make these baud rate changes? In the library or cam.begin(115200)..
Thank you very much in advance...
I am currently using hardware serial via the lib ray provided by Adafruit, I intend to use 115200 baud rate, to capture these images faster and dump it in my sd card...Where do I make these baud rate changes? In the library or cam.begin(115200)..
Thank you very much in advance...
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Changing the baud rate of the ttl serial camera
The tutorial explains how to change the camera's serial baud rate.
To use hardware serial, you initialize the library object with the hardware serial connection you want to use. For example, in the snapshot example sketch, comment out the software serial setup and replace it with hardware serial setup:
Then, specify your baudrate in the call to cam.begin
To use hardware serial, you initialize the library object with the hardware serial connection you want to use. For example, in the snapshot example sketch, comment out the software serial setup and replace it with hardware serial setup:
Code: Select all
// 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(2, 3);
// On Mega: camera TX connected to pin 69 (A15), camera RX to pin 3:
//SoftwareSerial cameraconnection = SoftwareSerial(69, 3);
//#else
//NewSoftSerial cameraconnection = NewSoftSerial(2, 3);
//#endif
#include <HardwareSerial.h>
HardwareSerial cameraconnection = Serial1; //'Serial1' is TX1/RX1 on a Mega. It is TX/RX on a Leonardo. On a Uno, use 'Serial'
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);
Code: Select all
// Try to locate the camera
if (cam.begin(115200)) {
Serial.println("Camera Found:");
} else {
Serial.println("No camera found?");
return;
}
- t.praveen
- Posts: 31
- Joined: Fri Apr 05, 2013 8:17 pm
Re: Changing the baud rate of the ttl serial camera
Hi, do I need to include software serial library also in the code you provided me above?
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Changing the baud rate of the ttl serial camera
You don't need to include SoftwareSerial if you are using the hardware serial port.
- t.praveen
- Posts: 31
- Joined: Fri Apr 05, 2013 8:17 pm
Re: Changing the baud rate of the ttl serial camera
But if I don't include software serial library, the code doesn't compile..
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Changing the baud rate of the ttl serial camera
Probably because you are using software serial. Post the code you are using.But if I don't include software serial library, the code doesn't compile..
- t.praveen
- Posts: 31
- Joined: Fri Apr 05, 2013 8:17 pm
Re: Changing the baud rate of the ttl serial camera
Code: Select all
#include <Adafruit_VC0706.h>
#include <SD.h>
#include <SoftwareSerial.h>
#include <HardwareSerial.h>
#define chipSelect 53
HardwareSerial cameraconnection = Serial1;
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);
void setup() {
Serial.begin(9600);
Serial.println("VC0706 Camera snapshot test");
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
return;
}
if (cam.begin(115200)) {
Serial.println("Camera Found:");
} else {
Serial.println("No camera found?");
return;
}
char *reply = cam.getVersion();
if (reply == 0) {
Serial.print("Failed to get version");
} else {
Serial.println("-----------------");
Serial.print(reply);
Serial.println("-----------------");
}
cam.setImageSize(VC0706_160x120);
uint8_t imgsize = cam.getImageSize();
Serial.print("Image size: ");
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!");
char filename[13];
strcpy(filename, "IMAGE00.JPG");
for (int i = 0; i < 100; i++) {
filename[5] = '0' + i/10;
filename[6] = '0' + i%10;
if (! SD.exists(filename)) {
break;
}
}
File imgFile = SD.open(filename, FILE_WRITE);
uint16_t jpglen = cam.frameLength();
Serial.print("Storing ");
Serial.print(jpglen, DEC);
Serial.print(" byte image.");
int32_t time = millis();
pinMode(8, OUTPUT);
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;
}
jpglen -= bytesToRead;
}
imgFile.close();
time = millis() - time;
Serial.println("done!");
Serial.print(time); Serial.println(" ms elapsed");
}
void loop() {
}
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Changing the baud rate of the ttl serial camera
It looks like the latest version of the library references SoftwareSerial - even if you don't use it. So you do need to include it.
However, you don't need to include HardwareSerial. You can just define your camera this way:
However, you don't need to include HardwareSerial. You can just define your camera this way:
Code: Select all
#include <Adafruit_VC0706.h>
#include <SD.h>
#include <SoftwareSerial.h>
#define chipSelect 53
Adafruit_VC0706 cam = Adafruit_VC0706(&Serial1);
- t.praveen
- Posts: 31
- Joined: Fri Apr 05, 2013 8:17 pm
Re: Changing the baud rate of the ttl serial camera
Hi bill,
How about cam.begin()?
Bill, could you please guide me on the steps on how to make this camera take images at 160x120 for 2-3 frames per second and store in the SD card?At the moment it is capturing image at 160x120 in a second. I am using an arduino mega by the way. Hence, from the steps you will provide, I may counter check where am I wrong.
Please and thank you very much.
How about cam.begin()?
Bill, could you please guide me on the steps on how to make this camera take images at 160x120 for 2-3 frames per second and store in the SD card?At the moment it is capturing image at 160x120 in a second. I am using an arduino mega by the way. Hence, from the steps you will provide, I may counter check where am I wrong.
Please and thank you very much.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Changing the baud rate of the ttl serial camera
The tutorial also explains how to change the image size:
You must specify the baudrate in cam.begin for anything other than 38400:You can also change the snapshot image dimension to 160x120, 320x240 or 640x480 by changing these lines:
// 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
Code: Select all
cam.begin(115200);
- t.praveen
- Posts: 31
- Joined: Fri Apr 05, 2013 8:17 pm
Re: Changing the baud rate of the ttl serial camera
This is where i face the problem...I cant get it to read at 115200 eventhough I have set it up in the CommTool at 115200..adafruit_support_rick wrote:The tutorial also explains how to change the image size:You must specify the baudrate in cam.begin for anything other than 38400:You can also change the snapshot image dimension to 160x120, 320x240 or 640x480 by changing these lines:
// 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
Code: Select all
cam.begin(115200);
- t.praveen
- Posts: 31
- Joined: Fri Apr 05, 2013 8:17 pm
Re: Changing the baud rate of the ttl serial camera
Regarding the image sizes, I dont face any issue..My intention is to get this camera to store images maybe 2 or 3 images in a second to my SD card..Is this possible?
Please be positive and constructive with your questions and comments.