I am currently trying to use the above camera (https://www.sparkfun.com/products/10061?) with an Arduino Uno in one of my projects; however, I cannot get the camera to communicate properly via the SoftwareSerial port under Linux (currently using Mint 13). When I send a command to the camera I don't get back the expected response - for example (from the manual):
After many days / weeks puzzling at this, I turned to the dark side ] and uploaded my code via a windows machine - and now I get the expected response ... I can even receive the correct response from the Linux serial monitor - providing the code was uploaded from Windows ...
Can anybody provide any sort of explanation for this behaviour? Is there any logical reason why the compiled code should be different? And is there anything I can do about it?
The 38400 could be close to the maximum of the SoftwareSerial library.
The codes you read seems like a baudrate mismatch. If you are sure that the baudrate is set properly, it might have to do with optimazations or different versions of the Arduino IDE.
If you have Arduino installed from the repositories, you have an older version.
The behaviour in Windows and Linux should be the same if the same version of the Arduino IDE was used.
The software serial library claims speeds of up to 115200 - though I have not tested this. In simple serial communication it can do 57600 easily though.
If I change the baudrate at all, then the camera fails to transmit anything.
Bizarrely the same sketch compiles to different sizes under both Linux and Windows (using the same version of the IDE - 1.0)!
This is the code:
/*
* latest version of the camera tester - 09-12-2012
*
*/
#include <SoftwareSerial.h>
SoftwareSerial camport(10,11);
void setup()
{
Serial.begin(115200);
// set up the software serial pins properly
// rx = input, tx = output
pinMode(10, INPUT);
pinMode(11, OUTPUT);
camport.begin(38400);
}
void loop()
{
// send a command to the camera
Serial.println("resetting camera");
resetCamera();
delay(4000);
// try and read the camera response
while(camport.available() > 0)
{
byte inByte = camport.read();
Serial.print(inByte, HEX);
Serial.print(" ");
}
Serial.println();
// stop
while(true)
{
}
}
// send the reset command to the camera: 0x56 0x00 0x26 0x00
void resetCamera()
{
byte resetCmd[4] = {0x56, 0x00, 0x26, 0x00};
camport.write(resetCmd, 4);
}
Which weighs in at 5056 bytes under Windows and 4688 bytes in Linux.
I am about to try the very latest Linux version - will report how that goes!
Well, the latest Arduino IDE version under Linux behaved exactly the same ...
I have noticed as well that the blink sketch compiles to different sizes under both Linux and Windows - I assume that this must be something to do with the toolchain / gcc-avr version.
It looks like my only solution to use these cameras is to program them under Windows! However, I'm not sure I'll be using them very much as they aren't very capable. They are OK if you need to take occasional still images (1 per minute at best), but the resolution isn't great and they are slow.
I'm still baffled by the difference though and would dearly love to figure it out!