ArduCAM / Arduino

This is ArduCAM library for Arduino boards
MIT License
472 stars 348 forks source link

ArduCam Mini not working #1

Closed deltaGPhys closed 9 years ago

deltaGPhys commented 9 years ago

There seems to be less documentation for the mini board than the others; I can't get it to work (OV 5642). I get just garbage back to the serial monitor. Also, since there's no SD port on the mini shield, how will I save pictures?

Any help is appreciated!

Thanks, jg

ArduCAM commented 9 years ago

Please find more documents from link: http://www.arducam.com/arducam-mini-released/ You can connect extra SD card reader or transfer the captured image to host app like this: www.arducam.com/downloads/app/ArduCAM_v1.0.exe Regards Lee

ArduCAM commented 9 years ago

Dear Sir, Thanks for your question.

Please read the software application note for detail: http://www.arducam.com/downloads/shields/ArduCAM_Camera_Shield_Software_Application_Note.pdf

Please try this sketch to test the ArduCAM mini 5MP https://github.com/ArduCAM/Arduino/tree/master/ArduCAM/examples/mini/ArduCAM_Mini_OV5642_Video_Streaming And use the host application console from, and save pictures on your PC. https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/mini/ArduCAM_host_v1.0.exe

Any question else,please feel free to let us know. Best Regards, Lee From: deltaGPhys Date: 2015-06-19 22:57 To: ArduCAM/Arduino Subject: [Arduino] ArduCam Mini not working (#1) There seems to be less documentation for the mini board than the others; I can't get it to work (OV 5642). I get just garbage back to the serial monitor. Also, since there's no SD port on the mini shield, how will I save pictures? Any help is appreciated! Thanks, jg — Reply to this email directly or view it on GitHub.

deltaGPhys commented 9 years ago

Thanks for the replies - I'll dig into this today and let you know!

deltaGPhys commented 9 years ago

I have installed the program and am getting an SPI interface error when I try to open the port on the software. Judging by the pinouts, it seems like I should just plug the Mini shield into the Arduino, digital pins 10-13,gnd, etc. - all of the way to the end of that section. The shield that I got is set up differently from the one in the picture (it's a continuous row of 8 pins, so it doesn't look like there will be any jumpering over to the ICSP section. Let me know if this isn't set up correctly.

Thanks for the help, jg

ArduCAM commented 9 years ago

Sorry there is a mistake in the demo code, it use pin9 as cs instead of pin10 // set pin 10 as the slave select for the digital pot: const int CS = 9; Would you please let me know which type of arduino board you are using, different arduino boards has different SPI pin out, it is more reliable to use ICSP pins because it is the same SPI port between arduino boards

deltaGPhys commented 9 years ago

It's an UNO R3. I've changed the pin in the sketch and reuploaded, but I'm still getting an SPI error from the application. It's hard to see the errors, BTW< because the windows application has a fixed height, which is higher than my screen. I'm using a tablet PC, so I rotate the screen to see it :)

deltaGPhys commented 9 years ago

Sometimes, after I open the port, I get "ArduCam start!", no error, but no pics. I see the RX LED lighting on the Arduino when I press capture, but it never transmits. Edit: Nevermind - errors consistently again now...

deltaGPhys commented 9 years ago

Any ideas on this? I'm going to have to return the camera if I can't get it to work - it's not doing anything for me at this point.

ArduCAM commented 9 years ago

Dear Sir, It seems that there is some thing wrong with the wiring. Would you please take a photo to show me how you do the wiring. You have to make the I2C and SPI working correctly before taking any pictures.

Any question else,please feel free to let us know. Best Regards, Lee


From: deltaGPhys Date: 2015-06-25 22:57 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Any ideas on this? I'm going to have to return the camera if I can't get it to work - it's not doing anything for me at this point. — Reply to this email directly or view it on GitHub.

deltaGPhys commented 9 years ago

Interesting news: Wiring it like this: 20150626_081653 ...does not work, though all of the pins are correctly placed, I think.

Wiring it like this: 20150626_082949 20150626_082944 20150626_083014 ...does. I'm using the ICSP pins for the SPI pins, but the same pin 10 and SCL/SDA pins.

Shouldn't those be exactly equivalent setups?

I'm glad that I'm getting something out of it, though! Is there a pre-made sketch for sending photos to an SD card (such as OpenLog?).

Thanks, jg

deltaGPhys commented 9 years ago

Aha: all the pins are exactly correct... except for the AREF, which should have the +5V pin there. 20150626_085309

deltaGPhys commented 9 years ago

Now that the camera works fine attached to the computer, my unsolved question is how to save those photos to an SD card (OpenLog is the card breakout that I have). I assume that I'll be able to figure out having the sketch take photos with large delays between, though if there's a good power-saving way to just take one photo a minute or so, I'm all ears.

ArduCAM commented 9 years ago

Hi again, Yes, you are right, and finally you resolved the problem by yourself. You are genius! The Arduino board VREF is not 5V VCC you have to use external power.

Any question else,please feel free to let us know. Best Regards, Lee


From: deltaGPhys Date: 2015-06-27 07:06 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Now that the camera works fine attached to the computer, my unsolved question is how to save those photos to an SD card (OpenLog is the card breakout that I have). I assume that I'll be able to figure out having the sketch take photos with large delays between, though if there's a good power-saving way to just take one photo a minute or so, I'm all ears. — Reply to this email directly or view it on GitHub.

deltaGPhys commented 9 years ago

My remaining issue is how to store images to OpenLog or similar SD card shield/breakout. Is there example code for that?

Thanks, jg

--  Joshua Gates  Physics Faculty  Tatnall School (Wilmington DE)  JHU Center for Talented Youth

Lee notifications@github.com , 6/29/2015 10:55 AM: Hi again, Yes, you are right, and finally you resolved the problem by yourself. You are genius! The Arduino board VREF is not 5V VCC you have to use external power.

Any question else,please feel free to let us know. Best Regards, Lee


From: deltaGPhys Date: 2015-06-27 07:06 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Now that the camera works fine attached to the computer, my unsolved question is how to save those photos to an SD card (OpenLog is the card breakout that I have). I assume that I'll be able to figure out having the sketch take photos with large delays between, though if there's a good power-saving way to just take one photo a minute or so, I'm all ears. — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub.

ArduCAM commented 9 years ago

please have a look at this example: https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/REVC/ArduCAM_OV2640_Digital_Camera/ArduCAM_OV2640_Digital_Camera.ino SD card cs pin should go Pin9 Best Regards, Lee


From: deltaGPhys Date: 2015-06-29 23:08 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) My remaining issue is how to store images to OpenLog or similar SD card shield/breakout. Is there example code for that?

Thanks, jg

Joshua Gates Physics Faculty Tatnall School (Wilmington DE) JHU Center for Talented Youth

Lee notifications@github.com , 6/29/2015 10:55 AM: Hi again, Yes, you are right, and finally you resolved the problem by yourself. You are genius! The Arduino board VREF is not 5V VCC you have to use external power.

Any question else,please feel free to let us know. Best Regards, Lee


From: deltaGPhys Date: 2015-06-27 07:06 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Now that the camera works fine attached to the computer, my unsolved question is how to save those photos to an SD card (OpenLog is the card breakout that I have). I assume that I'll be able to figure out having the sketch take photos with large delays between, though if there's a good power-saving way to just take one photo a minute or so, I'm all ears. — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub.

deltaGPhys commented 9 years ago

I'll check it out - thanks!

jg

--  Joshua Gates  Physics Faculty  Tatnall School (Wilmington DE)  JHU Center for Talented Youth

Lee notifications@github.com , 6/29/2015 11:19 AM: please have a look at this example: https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/REVC/ArduCAM_OV2640_Digital_Camera/ArduCAM_OV2640_Digital_Camera.ino
SD card cs pin should go Pin9 Best Regards, Lee


From: deltaGPhys Date: 2015-06-29 23:08 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) My remaining issue is how to store images to OpenLog or similar SD card shield/breakout. Is there example code for that?

Thanks, jg

--
Joshua Gates
Physics Faculty
Tatnall School (Wilmington DE)
JHU Center for Talented Youth

Lee notifications@github.com , 6/29/2015 10:55 AM: Hi again,
Yes, you are right, and finally you resolved the problem by yourself. You are genius!
The Arduino board VREF is not 5V VCC you have to use external power.

Any question else,please feel free to let us know.
Best Regards,
Lee


From: deltaGPhys
Date: 2015-06-27 07:06
To: ArduCAM/Arduino
CC: Lee
Subject: Re: [Arduino] ArduCam Mini not working (#1)
Now that the camera works fine attached to the computer, my unsolved question is how to save those photos to an SD card (OpenLog is the card breakout that I have). I assume that I'll be able to figure out having the sketch take photos with large delays between, though if there's a good power-saving way to just take one photo a minute or so, I'm all ears.

Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub.

geolog125 commented 9 years ago

Dear Lee, hello! I have encountered same problem! Arducam mini occupies same pins on Arduino Uno, so no possibilities to save any pictures to SD card. No pins to connect SD card besides Arducam mini. SD card data logging shield has a conflict with Arducam mini.

In Internet and both you web site I didn't find any solution. Please, give us CLEAR answer of how to connect both Arducam mini and SD card module.

I maybe order for portion of these Arducam modules, if It can be resolved.

ArduCAM commented 9 years ago

Dear Sir, Please connect other free pin to ArduCAM mini CS pin and change the arduino example sketch accordingly. Would you please send me a wiring diagram you currently do.

Any question else,please feel free to let us know. Best Regards, Lee


From: geolog125 Date: 2015-07-07 08:13 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Dear Lee, hello! I have encountered same problem! Arducam mini occupies same pins on Arduino Uno, so no possibilities to save any pictures to SD card. No pins to connect SD card besides Arducam mini. SD card data logging shield has a conflict with Arducam mini. In Internet and both you web site I didn't find any solution. Please, give us CLEAR answer of how to connect both Arducam mini and SD card module. I maybe order for portion of these Arducam modules, if It can be resolved. — Reply to this email directly or view it on GitHub.

geolog125 commented 9 years ago

Dear Lee, thanks for an answer. I connect Arducam mini to Arduino by this way. arducam_mini_arduino This scheme works, It gives me opportunity to read data from PC in your appropriate software. But I need to save data to SD card. arduino-and-sdcard_bb

But pins 11,12,13 are occupied. How to connect in that case? Please, help.

geolog125 commented 9 years ago

Also, I can connect my microsd card via ICSP and all goes well. But when I tried to add ArducamMini to that connection, I got "SPI interface error" message in Arducam sketch. What to do? microsd_arduino

ArduCAM commented 9 years ago

Dear Sir, The two Chipselect signal from ArduCAM mini and SD card reader should be only one active at a given time. Can you send me your test code?

Best Regards, Lee


From: geolog125 Date: 2015-07-07 10:19 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Also, I can connect my microsd card via ICSP and all goes well. But when I tried to add ArducamMini to that connection, I got "SPI interface error" message in Arducam sketch. What to do? — Reply to this email directly or view it on GitHub.

geolog125 commented 9 years ago

Dear friend, when I updated Arducam classes from your github, I tried these connection:

arducam_sd_card

But, alas, your sample (https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/REVC/ArduCAM_OV2640_Digital_Camera/ArduCAM_OV2640_Digital_Camera.ino) brought a random errors like: "Arducam is not detected", "SD card error", and all spectrum of mistakes. One moment I even captured a picture with mess data. After all, I got code here: http://forum.arduino.cc/index.php?topic=331067.msg2298891#msg2298891

It worked for me! But image quality is following (that's little keyboard lamp):

image08

How to make quality better or manage it?

ArduCAM commented 9 years ago

Hi again, To fix the RGB color issue, please read the post here: http://www.arducam.com/rgb565-format-issues/Best Regards, Lee


From: geolog125 Date: 2015-07-07 11:13 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Dear friend, when I updated Arducam classes from your github, I tried these connection:But, alas, your sample brought a random errors like: "Arducam is not detected", "SD card error", and all spectrum of mistakes. One moment I even captured a picture with mess data. After all, I got code here: http://forum.arduino.cc/index.php?topic=331067.msg2298891#msg2298891 It worked for me! But image quality is following (that's little keyboard lamp): How to make quality better of manage it? — Reply to this email directly or view it on GitHub.

geolog125 commented 9 years ago

After applying these http://www.arducam.com/rgb565-format-issues/ I obtain stranger picture: image76

Any solutions?

ArduCAM commented 9 years ago

Things become more and more complex. Please try to read the document here: http://www.arducam.com/downloads/shields/ArduCAM_Camera_Shield_Software_Application_Note.pdf And use the host application from: https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/mini/ArduCAM_host_v1.0.exe Make sure if you use the example sketches in mini folder https://github.com/ArduCAM/Arduino/tree/master/ArduCAM/examples/mini/ArduCAM_Mini_OV2640_Video_Streaming Before you changing any code by yourself, please try the steps above. Best Regards, Lee


From: geolog125 Date: 2015-07-07 11:23 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) I 'll try. Why your code for digital cam (https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/REVC/ArduCAM_OV2640_Digital_Camera/ArduCAM_OV2640_Digital_Camera.ino) is not running with my scheme, generates an errors? ― Reply to this email directly or view it on GitHub.

geolog125 commented 9 years ago

Dear Lee, thanks for answer. But maybe there are any solutions for SD card image write for Arducam mini? I did image capture with your PC software it is OK, but I need just save images into SD card with Arducam mini. In your examples Arducam mini can only be used as a PC camera. In my projects I need autonomous capture by Arduino. The samples you have shown did not coincide, because it is PC image capture. What I have to fix to obtain normal image? image07 mobile


//code from here http://forum.arduino.cc/index.php?topic=331067.msg2298891#msg2298891
//format issue fix from here http://www.arducam.com/rgb565-format-issues/

#include <UTFT_SPI.h>
#include <SD.h>
#include <Wire.h>
#include <ArduCAM.h>
#include <SPI.h>
#include "memorysaver.h"
#include <avr/pgmspace.h>
#include <ov2640_regs.h>

#define BMPIMAGEOFFSET 54
#define SD_CS 9
const int CS1 = 10;

// Constants that define the format of the picture taken
const int bmp_mode = 0;
const int mode = bmp_mode;

const char bmp_header[54] PROGMEM =
{
      0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
      0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Instanciation of the class ArduCAM
ArduCAM myCAM1(OV2640, CS1);
static int k = 0;

// Used in takePicture() to transfer the buffer of the ArduCAM into a BMP file
// inspired by http://sauerwine.blogspot.fr/2013/07/an-arduino-time-lapse-camera-using.html
void writeBMP(File outFile){

  //char VH, VL;
  char VH, VL, buf[256];
  uint8_t temp,temp_last;
  int i, j, posn, nextNum;

 /*
    //Write the BMP header
  for( i = 0; i < 54; i++)
  {
    char ch = pgm_read_byte(&bmp_header[i]);
    outFile.write((uint8_t*)&ch,1);
  }

  //Read the first dummy byte from FIFO
  temp = myCAM1.read_fifo();
  //Read 320x240x2 byte from FIFO
  for(i = 0; i < 240; i++)
    for(j = 0; j < 320; j++)
    {
      VH = myCAM1.read_fifo();
      VL = myCAM1.read_fifo();
      //RGB565 to RGB555 Conversion
      if (false) {
        VL = (VH << 7) | ((VL & 0xC0) >> 1) | (VL & 0x1f);
        VH = VH >> 1;
      }
      //Write image data to file
      outFile.write(VL);
      outFile.write(VH);
  }
}

*/
//Write the BMP header
for( i = 0; i < BMPIMAGEOFFSET; i++)
{
  char ch = pgm_read_byte(&bmp_header[i]);
  buf[k++] = ch;
}
outFile.write(buf,k);
//Read first dummy byte
//myCAM.read_fifo();

k = 0;
//Read 320x240x2 byte from FIFO
//Save as RGB565 bmp format
for(i = 0; i < 240; i++)
  for(j = 0; j < 320; j++)
{
    VH = myCAM1.read_fifo();
    VL = myCAM1.read_fifo();
    buf[k++] = VL;
    buf[k++] = VH;
    //Write image data to bufer if not full
    if(k >= 256)
    {
      //Write 256 bytes image data to file from buffer
      outFile.write(buf,256);
      k = 0;
    }
}
}

// IMAGE FILE GENERATION
// generates a name and returns the opened file
File imageFile(){
    // generates the filename
 char filename[13];
File outFile;

  strcpy(filename, "IMAGE00.BMP");
  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;
    }}
   Serial.println(filename);

    // opens the file
    outFile = SD.open(filename,O_WRITE | O_CREAT | O_TRUNC);
    if (! outFile){
    Serial.println("open file failed");
    } else {
    Serial.println("File opened sucessfully");
    }

    return outFile;
}

// ========= TAKE PICTURE ========
// simple to use function, which takes a picture
// either in JPEG (bugged) or BMP format in function
// of the 'mode' constant

void takePicture(){
  Serial.println("Taking picture...");
  File outFile;

  uint8_t start_capture = 0;

  myCAM1.write_reg(ARDUCHIP_MODE, 0x00);

  // Initialisation
  // Warning : if you use set_format(JPEG) before Init, it will freeze
  myCAM1.set_format(BMP);
  Serial.print("Init ? ");
  myCAM1.InitCAM();
  Serial.println("OK");

  myCAM1.flush_fifo(); // clean ArduCAM buffer
  myCAM1.clear_fifo_flag(); // start capture
  myCAM1.start_capture();
  Serial.print("Waiting for capture..."); //waiting until capture is done
  while (!(myCAM1.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) {
   delay(10);
  }
  Serial.println("OK");

  // open a file onto the SD card
  outFile = imageFile();

    // writes the content of the ArduCAM buffer into the file, with the right
    // function, defined by the 'mode' value
    Serial.print("Buffering...");
    writeBMP(outFile);
    Serial.println("OK");

    // close the file and clean the flags and the buffers
    outFile.close();
    Serial.println("Capture finished");
    myCAM1.clear_fifo_flag();
    start_capture = 0;
    myCAM1.InitCAM();
}

// Function that waits for n seconds, writing a countdown on the Serial console
void countdown(int n = 10){
 while (n>0){
    Serial.print(n);
    Serial.println("... ");
    n=n-1;
    delay(1000);
  }
}

// ======== SETUP ========

void setup(){
  uint8_t vid,pid;
  uint8_t temp;
  #if defined (__AVR__)
    Wire.begin();
  #endif
  #if defined(__arm__)
    Wire1.begin();
  #endif
  // begins the Serial communication
  Serial.begin(115200);
  Serial.println("ArduCAM Start!");
  pinMode(CS1, OUTPUT);
  SPI.begin();

  myCAM1.write_reg(ARDUCHIP_TEST1, 0x55);
  temp = myCAM1.read_reg(ARDUCHIP_TEST1);
  if(temp != 0x55)
  {
    Serial.println("SPI interface Error!");
    while(1);
  }
  else {
  Serial.println("SPI All Good");
  } 

  // change MCU mode (?)
  myCAM1.write_reg(ARDUCHIP_MODE, 0x00);
  myCAM1.InitCAM();

  // SD card initialisation
  if (!SD.begin(SD_CS))
  {
    while (1);      //If failed, stop here
    Serial.println("SD Card Error");
  }
  else
 {   Serial.println("SD Card detected!");
}}

void loop(){
        takePicture();
        delay(20000);

}
ArduCAM commented 9 years ago

Dear Sir, Thanks for your information. I bought a SD card module exactly the same as yours, and found the same problem. I have figured out that there is design fault on SD card module. The SD moudule use a SN74LVC125A as a level shifter to buffer the 5V and 3.3V signals. And I found that all the OE signals are connected to GND directly, so all the output pin Y are always driver the SPI signals like MISO, MOSI, SCLK. There is no problem for MOSI and SCLK which are output signal from processor. But the MISO are shared by all SPI devices on the bus, it should be tri-state when the device is inactive. But the SD card reader alway drive the MISO with a fixed logic '0' or '1' when it is inactive. For this kind of SD reader, it can only monopolize the SPI bus, it can not work with other SPI devices.

We have another product which is Rev.C arducam, which as build in SD card reader and LCD screen and the ArduCAM circuit like the ArduCAM mini. So don't doubt there is such problem with ArduCAM shield, we have fully tested it. http://www.arducam.com/arducam-shiled-rev-c-released/

Any question else,please feel free to let us know. Best Regards, Lee


From: geolog125 Date: 2015-07-07 16:45 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Dear Lee, thanks for answer. But maybe there are any solutions for SD card image write for Arducam mini? I did image capture with your PC software it is OK, but I need just save images into SD card with Arducam mini. In your examples Arducam mini can only be used as a PC camera. In my projects I need autonomous capture by Arduino. The samples you have shown did not coincide, because it is PC image capture. What I have to fix to obtain normal image?

//most promising, i think. saves nonsense data, though. //http://forum.arduino.cc/index.php?topic=285778.0 // inspired by http://sauerwine.blogspot.fr/2013/07/an-arduino-time-lapse-camera-using.html // and http://www.arducam.com/how-arducam-use-a-external-trigger-from-a-sensor/

include

include

include

include

include

include "memorysaver.h"

include <avr/pgmspace.h>

include

define BMPIMAGEOFFSET 54

define SD_CS 9

const int CS1 = 10; // Constants that define the format of the picture taken const int bmp_mode = 0; const int mode = bmp_mode; const char bmp_header[54] PROGMEM = { 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Instanciation of the class ArduCAM ArduCAM myCAM1(OV2640, CS1); static int k = 0; // Used in takePicture() to transfer the buffer of the ArduCAM into a BMP file // inspired by http://sauerwine.blogspot.fr/2013/07/an-arduino-time-lapse-camera-using.html void writeBMP(File outFile){ //char VH, VL; char VH, VL, buf[256]; uint8_t temp,temp_last; int i, j, posn, nextNum; / //Write the BMP header for( i = 0; i < 54; i++) { char ch = pgm_read_byte(&bmp_header[i]); outFile.write((uint8_t)&ch,1); }

//Read the first dummy byte from FIFO temp = myCAM1.read_fifo(); //Read 320x240x2 byte from FIFO for(i = 0; i < 240; i++) for(j = 0; j < 320; j++) { VH = myCAM1.read_fifo(); VL = myCAM1.read_fifo(); //RGB565 to RGB555 Conversion if (false) { VL = (VH << 7) | ((VL & 0xC0) >> 1) | (VL & 0x1f); VH = VH >> 1; } //Write image data to file outFile.write(VL); outFile.write(VH); } }

*/ //Write the BMP header for( i = 0; i < BMPIMAGEOFFSET; i++) { char ch = pgm_read_byte(&bmp_header[i]); buf[k++] = ch; } outFile.write(buf,k); //Read first dummy byte //myCAM.read_fifo(); k = 0; //Read 320x240x2 byte from FIFO //Save as RGB565 bmp format for(i = 0; i < 240; i++) for(j = 0; j < 320; j++) { VH = myCAM1.read_fifo(); VL = myCAM1.read_fifo(); buf[k++] = VL; buf[k++] = VH; //Write image data to bufer if not full if(k >= 256) { //Write 256 bytes image data to file from buffer outFile.write(buf,256); k = 0; } } } // IMAGE FILE GENERATION // generates a name and returns the opened file File imageFile(){ // generates the filename char filename[13]; File outFile; strcpy(filename, "IMAGE00.BMP"); 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; }} Serial.println(filename); // opens the file outFile = SD.open(filename,O_WRITE | O_CREAT | O_TRUNC); if (! outFile){ Serial.println("open file failed"); } else { Serial.println("File opened sucessfully"); } return outFile; } // ========= TAKE PICTURE ======== // simple to use function, which takes a picture // either in JPEG (bugged) or BMP format in function // of the 'mode' constant void takePicture(){ Serial.println("Taking picture..."); File outFile; uint8_t start_capture = 0; myCAM1.write_reg(ARDUCHIP_MODE, 0x00); // Initialisation // Warning : if you use set_format(JPEG) before Init, it will freeze myCAM1.set_format(BMP); Serial.print("Init ? "); myCAM1.InitCAM(); Serial.println("OK"); myCAM1.flush_fifo(); // clean ArduCAM buffer myCAM1.clear_fifo_flag(); // start capture myCAM1.start_capture(); Serial.print("Waiting for capture..."); //waiting until capture is done while (!(myCAM1.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) { delay(10); } Serial.println("OK"); // open a file onto the SD card outFile = imageFile(); // writes the content of the ArduCAM buffer into the file, with the right // function, defined by the 'mode' value Serial.print("Buffering..."); writeBMP(outFile); Serial.println("OK"); // close the file and clean the flags and the buffers outFile.close(); Serial.println("Capture finished"); myCAM1.clear_fifo_flag(); start_capture = 0; myCAM1.InitCAM(); } // Function that waits for n seconds, writing a countdown on the Serial console void countdown(int n = 10){ while (n>0){ Serial.print(n); Serial.println("... "); n=n-1; delay(1000); } } // ======== SETUP ======== void setup(){ uint8_t vid,pid; uint8_t temp;

if defined (AVR)

Wire.begin();

endif

if defined(arm)

Wire1.begin();

endif

// begins the Serial communication Serial.begin(115200); Serial.println("ArduCAM Start!"); pinMode(CS1, OUTPUT); SPI.begin(); myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM1.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println("SPI interface Error!"); while(1); } else { Serial.println("SPI All Good"); } // change MCU mode (?) myCAM1.write_reg(ARDUCHIP_MODE, 0x00); myCAM1.InitCAM(); // SD card initialisation if (!SD.begin(SD_CS)) { while (1); //If failed, stop here Serial.println("SD Card Error"); } else { Serial.println("SD Card detected!"); }} void loop(){ takePicture(); delay(20000); } — Reply to this email directly or view it on GitHub.

geolog125 commented 9 years ago

Dear Lee, hi again! I got another SD card module of another manufacturer (not micro SD). So, the is been changed slightly, and green fields disappeared. But there is another problems not related to SD card's conflict. 1) Magenta and blue spots on light areas (marked red on picture below) Can they be removed?; image051

2) The only resolution is 320x240. How to change (enlarge) it? I need distinct Arducam mini because of its size and form factor. I need just little camera guided by Arduino.

ArduCAM commented 9 years ago

Dear Sir, I'm glad to hear that you are making progress. But I am on a business trip these days and will be back at the weekend. So I would like you to test the SD card saving function with the following examples, although they are designed for Rev.C arducam, but it can work for ArduCAM mini board: This example is for BMP file saving, 320x240 bmp image supported only, https://github.com/ArduCAM/Arduino/tree/master/ArduCAM/examples/REVC/ArduCAM_OV2640_Camera_Playback This example is for JPEG file saving, and save 1600x1200 JPEG images, https://github.com/ArduCAM/Arduino/tree/master/ArduCAM/examples/REVC/ArduCAM_OV2640_Digital_Camera

Any question else,please feel free to let us know. Best Regards, Lee


From: geolog125 Date: 2015-07-08 07:50 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Dear Lee, hi again! I got another SD card module of another customer (not micro SD). So, the is been changed slightly, and green fields disappeared. But there is another problems not related to SD card's conflict. 1) Magenta and blue spots on light areas. Can they be removed?; 2) The only resolution is 320x240. How to change (enlarge) it? I need distinct Arducam mini because of its size and form factor. I need just little camera guided by Arduino. — Reply to this email directly or view it on GitHub.

geolog125 commented 9 years ago

Dear Lee, thank you very much! After the modification of code you supplied above all started to work as need! The reason of malfunction with my prior attempts to use it was bad microsd reader. With this reader everything is OK. sku_142121_1 Thank you again for your consult!

ArduCAM commented 9 years ago

Dear Sir, Thanks for your news. Would you please describe how do you resolve your problems in the forum, it will help others to use ArduCAM more easily. Any question else,please feel free to let us know. Best Regards, Lee


From: geolog125 Date: 2015-07-08 14:15 To: ArduCAM/Arduino CC: Lee Subject: Re: [Arduino] ArduCam Mini not working (#1) Dear Lee, thank you very much! After the modification of code you supplied above all started to work as need! The reason of malfunction with my prior attempts to use it was bad microsd reader. With this reader everything is OK.

Thank you again for your consult! — Reply to this email directly or view it on GitHub.

zeidooo commented 9 years ago

Dear Lee, i'm triing to interface the Arducam OV2640 with Beagle Bone Black and i'm using your code in Github but everytime it show me the same error "SPI interface ERROR!" any information will be helpful for me Thank you

rei-vilo commented 9 years ago

Same for me! SPI interface ERROR!

What are the exact settings for SPI, which mode?

shravanib commented 8 years ago

Dear Sir, I purchase arducam OV5642 last week. Since the time I connected it, I keep on getting the "SPI Interface Error" evrytime I run the Host application for PC console. I have not been able to see any image whatsoever.

I am new to arduino and thus wanted to know what does the error exactly mean? What is the actual problem? Is something wrong with the Arducam or the code or the arduino board itself (Uno R3). I have tried all the connections and solutions you provided previously in the forum with no luck.

I would be highly obliged if you could please help me solve this problem. Thank you.

capblack commented 8 years ago

Dear Lee, I have the same problem whit OV5642

SPI.begin(); 64 //Check if the ArduCAM SPI bus is OK 65 myCAM.write_reg(ARDUCHIP_TEST1, 0x55); 66 temp = myCAM.read_reg(ARDUCHIP_TEST1); 67 Serial.println(temp); <<<<<<========== here temp return 0x85 "SPI Interface Error" 68 if (temp != 0x55)
69 { 70 Serial.println("SPI interface Error!"); 71 //while(1); 72 }

   with all my boards , any help ?
   Thank you.
ArduCAM commented 8 years ago

Hi capblack, please try the camera on Arduino UNO R3 first before moving to other platform to make sure hte hardware is working. BTW: which kind of board you are using right now?

capblack commented 8 years ago

Dear Lee, thanks for you fast response , but yesterday started to work ok, right now I'm using a Mega 2560 and I would like to work with nodeMCU, I have also tried and received the same error "SPI Interface Error", the difference started to run I think it is in the ArduCAM_v3.3.1 not sure. my intention really is to try to run this camera with pic32mz or stm32f4 and try to get 60fps 1280x720 , I do not know if the FPGA allows do this Thank you.

ArduCAM commented 8 years ago

Hi Capblack, are you sure ArduCAM-Mini-5MP works fine with Mega2560? Did you try the workaround hieudini suggested? The ArduCAM is designed for high resolution still image not for video. Due to the limitation of the SPI speed, you can only get low resolution low frame rate video. Let me know if you need more help.

capblack commented 8 years ago

Hi Mr Lee, yes I'm sure , I implement this example and now work fine http://www.arducam.com/how-to-connect-arducam-shield-to-mega-2560/#more-509 Yes I can see the SPI is very slow, maybe I move to OV5642 Camera Module ? can this module bring 60 fps on 720p ? Thank you.

ArduCAM commented 8 years ago

Hi capblack, the OV5642 datasheet says it supports 60fps at 720p, but I'm afraid that it is not easy to make it work on that setting. would you please let me know more about your application, maybe I can give you more suggestions. We will be off for Chinese New Year holiday from Feb. 5th to Feb. 16th, so my reply will be delay, please understand.

capblack commented 8 years ago

Hi Mr Lee, yes is not intended for Arduino ,could be on pic32mz or STM32F4. the idea is to use it to FPV, so I need a high fps and low latency essentially is the most important. on the other hand I have development a high-speed link RF, that's why I brought her camera simple. thanks for your kindness

ArduCAM commented 8 years ago

Hi capblack. Yes I understand. But as you can see the 5MP full frame output is only 15fps. If you need 720p with 60fps, you have to tune the register in the sensor which is not easy though. I'm interested in your high-speed RF link, what kind of solution do you want to use?

capblack commented 8 years ago

Hi Mr Lee,I have developed a link on standard 5.8ghz video transmitter and receiver, similar to Manchester encoding and reached 0.5 Mb / s enough to carry 720p at 60fps I think . the point is I do not have much experience in digital video cameras and that's why I'm trying, and I started with ArduCam Mini found it more simple, I had no account the limitation of spi speed , but anyway I'm looking for a fast camera that can give me raw data, in the easiest way :) Thanks

ArduCAM commented 8 years ago

I'm afraid you can not use raw data which is much bigger size. In your application you can only use MJPEG or H.264 stream to transfer the realtime video, MJPEG is eaiser compared to H.264. The OV5642 camera support MJPEG output, but as I said eariler to get 60fps@720p output from OV5642 is not easy, we have to try.

capblack commented 8 years ago

Hi Mr Lee, when I referred to raw data, I meant hypothetically go obtaining data byte by byte each photo and then process it in a shift register and transmit them, then the receiver was in charge of rebuilding the data, surely a compressed format such as MJPEG facilitates work,, but as you say the main thing is to make the camera to operate in that resolution.

andrawes commented 8 years ago

Dear ArduCam,

My new camera so far has been only giving me the SPI interface error message so far. When I see what "temp" returns, it seems that it returns 0. Thank you for your help, Andy

ArduCAM commented 8 years ago

@andrawes, would you please let me know what kind of ArduCAM you have and what kind of Arduino board you are using, what is the wiring between them?

AHVMF commented 8 years ago

Dear @ArduCAM ,

I am trying to get a 4 camera burst for OV2640 using the OV5642 code. I tried making changes to the number of frames and also to the resolution size. Although the cameras are being detected, i am not getting any image. And the size i am receiving from the host application is 0.

May i please know what are the changes i need to make in the OV5642 code to get 4 OV2640 to work in the burst mode without an ArduCAM shield.

Thank you so much!!

TimoteoMendes commented 8 years ago

hello all, recently i bought a arduCAM 4 cameras adapter board and a arducam mini 5MP. connect all together using an arduino uno but always have the same problem with all exemples. First i have to include the:

include

because is not on the examples and change the baud rate for serial 115200. i allwasy receave a nicer reply that all is ok but stops on take picture. Finally i even used the code on this page from the geolog125 but have the same problem. After adapted it to use my ov5642. always receave this: ArduCAM Start! SPI All Good SD Card detected! Taking picture... Init ? OK Waiting for capture...

anyhelp is apreciated. If this is an hardware problem i have to return the camera. Thanks, Timóteo

tomburtonwood commented 8 years ago

Hello,

Is there a drawing, schematic or photograph showing how to connect the 4 camera module to the Raspberry Pi - as shown in this image ( http://www.arducam.com/arducam-porting-raspberry-pi/arducam-pizero-3/ ) would appreciate some guidance on this - i just bought the module and would love to get up and running asap. T