ArduCAM / Arduino

This is ArduCAM library for Arduino boards
MIT License
473 stars 349 forks source link

ARDUCAM Mini-2mp (OV2640) connection with Arduino Uno R3 #179

Closed Luddite-John closed 7 years ago

Luddite-John commented 7 years ago

Does anyone have a simple diagram (and expereince ) of how to connect the Arducam-Mini-2Mp to an Arduino Uno, and a code sample that matches.

After a number of false starts, I have connected the Mini-2Mp to the Arduino Uno R3 as follows: Mini-2Mp Pin 1 - Uno D10 Mini-2Mp Pin 2 - Uno D11 Mini-2Mp Pin 3 - Uno D12 Mini-2Mp Pin 4 - Uno D13 Mini-2Mp Pin 5 - Uno Digital Gnd pin Mini-2Mp Pin 6 - Uno Power connector pin (5v) Mini-2Mp Pin 7 - Uno 3 pins above D13 Mini-2Mp Pin 8 - Uno 4 pins above D13

I have installed Arducam in my library and commented out everything except OV2640 in memorysaver.h and then ran all examples for File>Examples> Arducam> mini), then used Arducam _v1.0.exe to control and review the output.

Adjusting the baud rate to either 115200 or 921600 I get a readable output. For example runnning the sketch "Arducam_Mini_2MP_LowPowerMode", gives an output in Arducam_V1.0.exe of:

Port Opened. ACK CMD ArduCAM Start! ACK CMD SPI interface Error! ACK CMD SPI interface Error! (this error just keeps repeating)

I get different errors for each .ino (example/ sketch) that I run, but it never has produced an image. Any help would be greatly appreciated

supprot commented 7 years ago

@Luddite-John Hi,

In our demo ,we define SPI CS 7 instead of 10. Please connect the pin 1 to uno 7 instead of 10.

Let us know if you need more help. Regards, ArduCAM suport team.

Luddite-John commented 7 years ago

Thank you for responding.

I came across the same message where you had responded to someone else with a similar problem.

I used the UNO to simplify the learning path, as i am trying to interface the Arducam min 2mp to a Mega 2650, and I thought it would be easier to use the Uno as there was a lot more data .

I have now connected the Mini 2mp to the Arduino Mega (using exactly the same pin configuration i used on the UNo), and once again it has the SPI error "ACK CMD SPI interface Error!"

I tried connecting CS (pin 1 on mini 2mp) to the Digital pin 10 and also to Digital Pin 7, but neither worked.

Is there other differences/ programming required to use the Mega in polace of the UNO?

Thanks

supprot commented 7 years ago

@Luddite-John Hi, On Mega2560 platform, we suggest you use SPI signals from the ICSP. Look at the picture we attached to you: 85e70a89-a4ee-4a79-b2e1-5d517d5dd2bc

Let us know if you need more help. Regards, ArduCAM support team.

Luddite-John commented 7 years ago

Thanks Arducam Support Team.

I have made the wiring changes as per your suggestion, I think the table for the Arducam mini-2mp shield looks like this:

Pin TYPE Type Description UNO-R3 Mega - 2560 1 CS Input SPI slave chip select input D7 D10 2 MOSI Input SPI master output slave input D11 ICSP4 3 MISO Output SPI master input slave output D12 ICSP1 4 SCLK Input SPI serial clock D13 ICSP3 5 GND Ground Power ground Gnd Gnd 6 +5V POWER 5V Power supply VCC VCC 7 SDA Bi-directional Two-Wire Serial Interface Data I/O D16 D20 8 SCL Input Two-Wire Serial Interface Clock D17 D21

Are there any code changes or pin reallocation required (such as previously in ArduCAM_Mini_LowPowerMode sketch you changed your code for the Mini 2mp uses D7 instead of D10).

What if any code changes are required to make the camera work in the configuration for the Mega

Thanks

supprot commented 7 years ago

@Luddite-John Hi, About SPI CS,it's up to you, we just provide a demo,you should not change others except CS. If you set the CS 7 in the code,you shoud connect SPI CS to 7.

Let us know if you need more help. Regards, ArduCAM support team.

Luddite-John commented 7 years ago

Thank you.

I understand this, so I have change SPI Cs harware to pi 7 and run it no work, says "CMD SPI Interface Error". So I change hardware to digital pin 10 and change SPI Cs to pin 10 and run again, still says "CMD SPI Interface Error".

So problem not using pin 7 or pin 10. Do you know what other mistake can cause error message "CMD SPI Interface Error".

supprot commented 7 years ago

@Luddite-John Hi, It also maybe a hardware connection problem. You can check it by oscilloscope.

Let us know if you need more help. Regards, ArduCAM support team.

Luddite-John commented 7 years ago

Hi,

Yes I need help.

Interesting that you think it might be a hardware problem.

So I switched everything back and ran the mini 2mp shield on the Arduino Uno again, and it worked fine.

When I connect ujp min 2mp to Arduino Mega again it does not work.

So no, not a hardware problem.

Please you can help by writing what each of the 8 pins on the Mini 2MP shield must go to on the Arduino Mega, to run the sample code you have provided, as what you have provided to date does not work.

If you do not have a list, then maybe a picture with a working one, or review the list I provided above and make corrections as needed.

Thank you

supprot commented 7 years ago

@Luddite-John Hi, Very glad to hear your camera can work fine on UNO. Please refer to those pictures we attached for you. We use our adapter in order to make multi cameras work together. We chose 5 and 7 as SPI CS. 5abe492a-e36c-4a7e-bb48-9eaaa3606621 e5e78f09-b067-426b-8165-31b29d5fe61a

6878c507-3c44-4c3c-b502-1d821916d929

Let us know if you need more help. Regards, ArduCAM support team.

Luddite-John commented 7 years ago

Thanks for your timely responses and your continued efforts to resolve (successfully), my original issue.

I went back to my original question and I now believe that this issue thread should now be closed (I will raise a separate issue on connecting the Mini-2mp shield to the Mega), as the advice provided has resulted in a working camera using the Mini-2MP Shield and an Arduino Uno R3

For anyone reading this thread who also has this issue (Arducam Mini -2MP camera not working on UNO), I make this reccm:

robkwan commented 7 years ago

Hello!

I am totally new to this ArduCAM_Mini development and I just got my setup today with:-

  1. Arduino ESP 8266 UNO;
  2. OV2640 Camera Shield for Arduino; &
  3. ArduCAM 4 Cameras Adapter Board

And I installed Arduino IDE 1.8.2.

I have no problem to run the basic examples with 1 & 2 only.

However, when I try to add the 4 camera adapter board in-between, nothing works!

I tried to download the ArduCAM_Mini_4CAM_Capture2SD but it would crash immediately after bootup.

I tried to follow the document: Multi-Camera Adapter Board User Guide Rev 1.1, Oct 2015 and it mentions about ArduCAM_Mini_2MP_4Cams_TimeElapse2SD_LowPower.ino

But I find that I cannot use it either even if I can find it from github because the codebase is so different from 2015 to now?!

Therefore, I would like to ask if there would be another example .ino which can allow me to plug in the Camera to the Adaptor board and run ok please. Initially, I just want to have a good stand for the one and only one camera first but I may buy the other 3 later if it really works...!

Any suggestion please?

Thanks & Best Regards, Robert

UCTRONICS commented 7 years ago

@robkwan Hi,

About ESP8266 UNO, please refer to this document: http://www.arducam.com/downloads/ESP8266_UNO/ArduCAM_ESP8266_UNO_DS.pdf We have update our codes, so it will exist some differents.

The ArduCAM Mini codes are used for Arduino UNO board instead of ESP8266 UNO board.

Let us know if you need more help. Regards, ArduCAM support team.

robkwan commented 7 years ago

Hello!

Thanks for your prompt reply!

However, as I said before, I have no problem to use the ESP8266 UNO board with the Camera.

So is there any reference example/s which can show me how to use the 4 Camera Adapter board with ESP8266 UNO board please?! Or it is not possible to use the Adapter board with ESP8266 UNO board pls?!

Thanks & BR, Robert

On Mon, May 8, 2017 at 6:16 PM, UCTRONICS notifications@github.com wrote:

@robkwan https://github.com/robkwan Hi,

About ESP8266 UNO, please refer to this document: http://www.arducam.com/downloads/ESP8266_UNO/ArduCAM_ESP8266_UNO_DS.pdf We have update our codes, so it will exist some differents.

The ArduCAM Mini codes are used for Arduino UNO board instead of ESP8266 UNO board.

Let us know if you need more help. Regards, ArduCAM support team.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ArduCAM/Arduino/issues/179#issuecomment-300033945, or mute the thread https://github.com/notifications/unsubscribe-auth/AbOj3fO94q8dfRR-m5LTLA9R-wopLtKVks5r375VgaJpZM4NFw9k .

UCTRONICS commented 7 years ago

@robkwan Hi, At ESP8266 platform, we don't have enough pin sources, so At present our ESP8266 can only support two cameras work together. Please refer to this code we atached for you,but you can't use our adapter directly for ESP8266, you can connect the other camera by dupont line.

// ArduCAM Mini demo (C)2017 Lee // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with ArduCAM Mini 2MP camera, and can run on any Arduino platform. // // This demo was made for ArduCAM Mini Camera. // It needs to be used in combination with PC software.It can take 4 photos at the same time with 4 cameras. // The demo sketch will do the following tasks: // 1. Set the 4 cameras to JPEG output mode. // 2. Read data from Serial port and deal with it // 3. If receive 0x00-0x08,the resolution will be changed. // 4. If receive 0x15,cameras will capture and buffer the image to FIFO. // 5. Check the CAP_DONE_MASK bit and write datas to Serial port. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM Minicamera // and use Arduino IDE 1.6.8 compiler or above

include

include

include

include "memorysaver.h"

//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform.

if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP)

error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file

endif

if !(defined ESP8266 )

error Please select the ArduCAM ESP8266 UNO board in the Tools/Board

endif

// set pin 4,5,6,7 as the slave select for SPI: const int CS1 = 16; const int CS2 = 0;

//the falgs of camera modules bool cam1=true,cam2=true,cam3=true,cam4=true; //the flag of JEPG data header bool is_header; //the falg data of 4 cameras' data byte flag[5]={0xFF,0xAA,0x01,0xFF,0x55}; int count = 0;

if defined (OV2640_MINI_2MP)

ArduCAM myCAM1(OV2640, CS1); ArduCAM myCAM2(OV2640, CS2);

else

ArduCAM myCAM1(OV5642, CS1); ArduCAM myCAM2(OV5642, CS2);

endif

void setup() { // put your setup code here, to run once: uint8_t vid,pid; uint8_t temp; Wire.begin(); Serial.begin(921600); Serial.println("ArduCAM Start!"); // set the CS output: pinMode(CS1, OUTPUT); pinMode(CS2, OUTPUT);

// initialize SPI: SPI.begin(); while(1){ //Check if the 2 ArduCAM Mini 2MP Cameras' SPI bus is OK myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM1.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI1 interface Error!")); cam1 = false; } myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM2.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI2 interface Error!")); cam2 = false; } if(!(cam1||cam2)){ delay(1000);continue; }else break; }

if defined (OV2640_MINI_2MP)

while(1){ //Check if the camera module type is OV2640 myCAM1.wrSensorReg8_8(0xff, 0x01); myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ Serial.println(F("ACK CMD Can't find OV2640 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV2640 detected."));break; } }

else

while(1){ //Check if the camera module type is OV5642 myCAM1.wrSensorReg16_8(0xff, 0x01); myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); if((vid != 0x56) || (pid != 0x42)){ Serial.println(F("ACK CMD Can't find OV5642 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV5642 detected."));break; } }

endif

myCAM1.set_format(JPEG); myCAM1.InitCAM();

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);

else

myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM1.OV5642_set_JPEG_size(OV5642_320x240);

endif

delay(1000); myCAM1.clear_fifo_flag(); myCAM2.clear_fifo_flag(); }

void loop() { // put your main code here, to run repeatedly: uint8_t temp = 0xff, temp_last = 0; uint8_t start_capture = 0; uint8_t finish_count; if (Serial.available()){ temp = Serial.read(); switch(temp) { case 0:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_160x120);delay(1000);
Serial.println(F("ACK CMD switch to OV2640_160x120"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000);
Serial.println(F("ACK CMD switch to OV5642_320x240"));

endif

temp = 0xff; break; case 1:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_176x144);delay(1000);
Serial.println(F("ACK CMD switch to OV2640_176x144"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_640x480);delay(1000);
Serial.println(F("ACK CMD switch to OV5642_640x480"));

endif

temp = 0xff; break; case 2:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);delay(1000);
Serial.println(F("ACK CMD switch to OV2640_320x240"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000);
Serial.println(F("ACK CMD switch to OV5642_1024x768"));

endif

temp = 0xff; break; case 3: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_352x288);delay(1000);
Serial.println(F("ACK CMD switch to OV2640_352x288"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000);
Serial.println(F("ACK CMD switch to OV5642_1280x960"));

endif

break; case 4: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_640x480);delay(1000);
Serial.println(F("ACK CMD switch to OV2640_640x480"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000);
Serial.println(F("ACK CMD switch to OV5642_1600x1200"));

endif

break; case 5: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_800x600);delay(1000);
Serial.println(F("ACK CMD switch to OV2640_800x600"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000);
Serial.println(F("ACK CMD switch to OV5642_2048x1536"));

endif

break; case 6: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000);
Serial.println(F("ACK CMD switch to OV2640_1024x768"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000);
Serial.println(F("ACK CMD switch to OV5642_2592x1944"));

endif

break;

if defined (OV2640_MINI_2MP)

case 7: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1280x1024")); break; case 8: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1600x1200")); break;

endif

case 0x10: if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } break; case 0x20: while(1){ if (Serial.available()){ temp = Serial.read(); if (temp == 0x21)break; } if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } } break;

} } } uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp,temp_last; uint32_t length;

myCAM.flush_fifo(); myCAM.clear_fifo_flag();
myCAM.start_capture(); while(!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); length = myCAM.read_fifo_length(); myCAM.CS_LOW(); myCAM.set_fifo_burst(); length--; while( length-- ) { temp_last = temp; temp = SPI.transfer(0x00);//read a byte from spi if(is_header == true) { Serial.write(temp); } else if((temp == 0xD8) & (temp_last == 0xFF)) { Serial.println(F("ACK IMG")); is_header = true; Serial.write(temp_last); Serial.write(temp); } if( (temp == 0xD9) && (temp_last == 0xFF) ) break; delayMicroseconds(15); } myCAM.CS_HIGH(); is_header = false; //Clear the capture done flag myCAM.clear_fifo_flag(); }

Let us now if you need more help. Regards, ArduCAM support team.

robkwan commented 7 years ago

Hello!

Thanks for the information!

Two is enough for the moment as I mainly want the stand support from the adapter board but I don't really understand what you meant by:-

but you can't use our adapter directly for ESP8266, you can connect the other camera by dupont line.

If so, it means that I still can't get the camera standing right like as on adapter board?!

Any other adapter board? Or suggestion please?!

Thanks & Best Regards, Robert

On Mon, May 8, 2017 at 6:43 PM, UCTRONICS notifications@github.com wrote:

@robkwan https://github.com/robkwan Hi, At ESP8266 platform, we don't have enough pin sources, so At present our ESP8266 can only support two cameras work together. Please refer to this code we atached for you,but you can't use our adapter directly for ESP8266, you can connect the other camera by dupont line.

// ArduCAM Mini demo (C)2017 Lee // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with ArduCAM Mini 2MP camera, and can run on any Arduino platform. // // This demo was made for ArduCAM Mini Camera. // It needs to be used in combination with PC software.It can take 4 photos at the same time with 4 cameras. // The demo sketch will do the following tasks: // 1. Set the 4 cameras to JPEG output mode. // 2. Read data from Serial port and deal with it // 3. If receive 0x00-0x08,the resolution will be changed. // 4. If receive 0x15,cameras will capture and buffer the image to FIFO. // 5. Check the CAP_DONE_MASK bit and write datas to Serial port. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM Minicamera // and use Arduino IDE 1.6.8 compiler or above

include

include

include

include "memorysaver.h"

//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform.

if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED

|| defined OV2640_MINI_2MP)

error Please select the hardware platform and camera module in the

../libraries/ArduCAM/memorysaver.h file

endif

if !(defined ESP8266 )

error Please select the ArduCAM ESP8266 UNO board in the Tools/Board

endif

// set pin 4,5,6,7 as the slave select for SPI: const int CS1 = 16; const int CS2 = 0;

//the falgs of camera modules bool cam1=true,cam2=true,cam3=true,cam4=true; //the flag of JEPG data header bool is_header; //the falg data of 4 cameras' data byte flag[5]={0xFF,0xAA,0x01,0xFF,0x55}; int count = 0;

if defined (OV2640_MINI_2MP)

ArduCAM myCAM1(OV2640, CS1); ArduCAM myCAM2(OV2640, CS2);

else

ArduCAM myCAM1(OV5642, CS1); ArduCAM myCAM2(OV5642, CS2);

endif

void setup() { // put your setup code here, to run once: uint8_t vid,pid; uint8_t temp; Wire.begin(); Serial.begin(921600); Serial.println("ArduCAM Start!"); // set the CS output: pinMode(CS1, OUTPUT); pinMode(CS2, OUTPUT);

// initialize SPI: SPI.begin(); while(1){ //Check if the 2 ArduCAM Mini 2MP Cameras' SPI bus is OK myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM1.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI1 interface Error!")); cam1 = false; } myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM2.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI2 interface Error!")); cam2 = false; } if(!(cam1||cam2)){ delay(1000);continue; }else break; }

if defined (OV2640_MINI_2MP)

while(1){ //Check if the camera module type is OV2640 myCAM1.wrSensorReg8_8(0xff, 0x01); myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ Serial.println(F("ACK CMD Can't find OV2640 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV2640 detected."));break; } }

else

while(1){ //Check if the camera module type is OV5642 myCAM1.wrSensorReg16_8(0xff, 0x01); myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); if((vid != 0x56) || (pid != 0x42)){ Serial.println(F("ACK CMD Can't find OV5642 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV5642 detected."));break; } }

endif

myCAM1.set_format(JPEG); myCAM1.InitCAM();

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);

else

myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM1.OV5642_set_JPEG_size(OV5642_320x240);

endif

delay(1000); myCAM1.clear_fifo_flag(); myCAM2.clear_fifo_flag(); }

void loop() { // put your main code here, to run repeatedly: uint8_t temp = 0xff, temp_last = 0; uint8_t start_capture = 0; uint8_t finish_count; if (Serial.available()){ temp = Serial.read(); switch(temp) { case 0:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240"));

endif

temp = 0xff; break; case 1:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480"));

endif

temp = 0xff; break; case 2:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768"));

endif

temp = 0xff; break; case 3: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); Serial.println(F("ACK CMD switch to OV2640_352x288"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960"));

endif

break; case 4: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200"));

endif

break; case 5: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); Serial.println(F("ACK CMD switch to OV2640_800x600"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536"));

endif

break; case 6: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1024x768"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944"));

endif

break;

if defined (OV2640_MINI_2MP)

case 7: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1280x1024")); break; case 8: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1600x1200")); break;

endif

case 0x10: if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } break; case 0x20: while(1){ if (Serial.available()){ temp = Serial.read(); if (temp == 0x21)break; } if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } } break;

} } } uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp,temp_last; uint32_t length;

myCAM.flush_fifo(); myCAM.clear_fifo_flag(); myCAM.start_capture(); while(!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); length = myCAM.read_fifo_length(); myCAM.CS_LOW(); myCAM.set_fifo_burst(); length--; while( length-- ) { temp_last = temp; temp = SPI.transfer(0x00);//read a byte from spi if(is_header == true) { Serial.write(temp); } else if((temp == 0xD8) & (temp_last == 0xFF)) { Serial.println(F("ACK IMG")); is_header = true; Serial.write(temp_last); Serial.write(temp); } if( (temp == 0xD9) && (temp_last == 0xFF) ) break; delayMicroseconds(15); } myCAM.CS_HIGH(); is_header = false; //Clear the capture done flag myCAM.clear_fifo_flag(); }// ArduCAM Mini demo (C)2017 Lee // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with ArduCAM Mini 2MP camera, and can run on any Arduino platform. // // This demo was made for ArduCAM Mini Camera. // It needs to be used in combination with PC software.It can take 4 photos at the same time with 4 cameras. // The demo sketch will do the following tasks: // 1. Set the 4 cameras to JPEG output mode. // 2. Read data from Serial port and deal with it // 3. If receive 0x00-0x08,the resolution will be changed. // 4. If receive 0x15,cameras will capture and buffer the image to FIFO. // 5. Check the CAP_DONE_MASK bit and write datas to Serial port. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM Minicamera // and use Arduino IDE 1.6.8 compiler or above

include

include

include

include "memorysaver.h"

//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform.

if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED

|| defined OV2640_MINI_2MP)

error Please select the hardware platform and camera module in the

../libraries/ArduCAM/memorysaver.h file

endif

if !(defined ESP8266 )

error Please select the ArduCAM ESP8266 UNO board in the Tools/Board

endif

// set pin 4,5,6,7 as the slave select for SPI: const int CS1 = 16; const int CS2 = 0;

//the falgs of camera modules bool cam1=true,cam2=true,cam3=true,cam4=true; //the flag of JEPG data header bool is_header; //the falg data of 4 cameras' data byte flag[5]={0xFF,0xAA,0x01,0xFF,0x55}; int count = 0;

if defined (OV2640_MINI_2MP)

ArduCAM myCAM1(OV2640, CS1); ArduCAM myCAM2(OV2640, CS2);

else

ArduCAM myCAM1(OV5642, CS1); ArduCAM myCAM2(OV5642, CS2);

endif

void setup() { // put your setup code here, to run once: uint8_t vid,pid; uint8_t temp; Wire.begin(); Serial.begin(921600); Serial.println("ArduCAM Start!"); // set the CS output: pinMode(CS1, OUTPUT); pinMode(CS2, OUTPUT);

// initialize SPI: SPI.begin(); while(1){ //Check if the 2 ArduCAM Mini 2MP Cameras' SPI bus is OK myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM1.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI1 interface Error!")); cam1 = false; } myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM2.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI2 interface Error!")); cam2 = false; } if(!(cam1||cam2)){ delay(1000);continue; }else break; }

if defined (OV2640_MINI_2MP)

while(1){ //Check if the camera module type is OV2640 myCAM1.wrSensorReg8_8(0xff, 0x01); myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ Serial.println(F("ACK CMD Can't find OV2640 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV2640 detected."));break; } }

else

while(1){ //Check if the camera module type is OV5642 myCAM1.wrSensorReg16_8(0xff, 0x01); myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); if((vid != 0x56) || (pid != 0x42)){ Serial.println(F("ACK CMD Can't find OV5642 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV5642 detected."));break; } }

endif

myCAM1.set_format(JPEG); myCAM1.InitCAM();

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);

else

myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM1.OV5642_set_JPEG_size(OV5642_320x240);

endif

delay(1000); myCAM1.clear_fifo_flag(); myCAM2.clear_fifo_flag(); }

void loop() { // put your main code here, to run repeatedly: uint8_t temp = 0xff, temp_last = 0; uint8_t start_capture = 0; uint8_t finish_count; if (Serial.available()){ temp = Serial.read(); switch(temp) { case 0:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240"));

endif

temp = 0xff; break; case 1:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480"));

endif

temp = 0xff; break; case 2:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768"));

endif

temp = 0xff; break; case 3: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); Serial.println(F("ACK CMD switch to OV2640_352x288"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960"));

endif

break; case 4: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200"));

endif

break; case 5: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); Serial.println(F("ACK CMD switch to OV2640_800x600"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536"));

endif

break; case 6: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1024x768"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944"));

endif

break;

if defined (OV2640_MINI_2MP)

case 7: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1280x1024")); break; case 8: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1600x1200")); break;

endif

case 0x10: if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } break; case 0x20: while(1){ if (Serial.available()){ temp = Serial.read(); if (temp == 0x21)break; } if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } } break;

} } } uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp,temp_last; uint32_t length;

myCAM.flush_fifo(); myCAM.clear_fifo_flag(); myCAM.start_capture(); while(!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); length = myCAM.read_fifo_length(); myCAM.CS_LOW(); myCAM.set_fifo_burst(); length--; while( length-- ) { temp_last = temp; temp = SPI.transfer(0x00);//read a byte from spi if(is_header == true) { Serial.write(temp); } else if((temp == 0xD8) & (temp_last == 0xFF)) { Serial.println(F("ACK IMG")); is_header = true; Serial.write(temp_last); Serial.write(temp); } if( (temp == 0xD9) && (temp_last == 0xFF) ) break; delayMicroseconds(15); } myCAM.CS_HIGH(); is_header = false; //Clear the capture done flag myCAM.clear_fifo_flag(); }

Let us now if you need more help. Regards, ArduCAM support team.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ArduCAM/Arduino/issues/179#issuecomment-300037764, or mute the thread https://github.com/notifications/unsubscribe-auth/AbOj3ZIT-l8lX8pkkpl1afRnCHRLKMksks5r38SrgaJpZM4NFw9k .

robkwan commented 7 years ago

Sorry that I might not be giving the right information to question!

In fact, I did use the dupont lines to connect the Camera to the ESP8266 UNO board and all the samples are working fine.

However, if I plug the camera into the middle slot as attached picture from the document, it would not work.

Any idea please?!

Thanks & BR, Robert

On Mon, May 8, 2017 at 7:24 PM, Robert Kwan robert.kwan@gmail.com wrote:

Hello!

Thanks for the information!

Two is enough for the moment as I mainly want the stand support from the adapter board but I don't really understand what you meant by:-

but you can't use our adapter directly for ESP8266, you can connect the other camera by dupont line.

If so, it means that I still can't get the camera standing right like as on adapter board?!

Any other adapter board? Or suggestion please?!

Thanks & Best Regards, Robert

On Mon, May 8, 2017 at 6:43 PM, UCTRONICS notifications@github.com wrote:

@robkwan https://github.com/robkwan Hi, At ESP8266 platform, we don't have enough pin sources, so At present our ESP8266 can only support two cameras work together. Please refer to this code we atached for you,but you can't use our adapter directly for ESP8266, you can connect the other camera by dupont line.

// ArduCAM Mini demo (C)2017 Lee // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with ArduCAM Mini 2MP camera, and can run on any Arduino platform. // // This demo was made for ArduCAM Mini Camera. // It needs to be used in combination with PC software.It can take 4 photos at the same time with 4 cameras. // The demo sketch will do the following tasks: // 1. Set the 4 cameras to JPEG output mode. // 2. Read data from Serial port and deal with it // 3. If receive 0x00-0x08,the resolution will be changed. // 4. If receive 0x15,cameras will capture and buffer the image to FIFO. // 5. Check the CAP_DONE_MASK bit and write datas to Serial port. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM Minicamera // and use Arduino IDE 1.6.8 compiler or above

include

include

include

include "memorysaver.h"

//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform.

if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED

|| defined OV2640_MINI_2MP)

error Please select the hardware platform and camera module in the

../libraries/ArduCAM/memorysaver.h file

endif

if !(defined ESP8266 )

error Please select the ArduCAM ESP8266 UNO board in the Tools/Board

endif

// set pin 4,5,6,7 as the slave select for SPI: const int CS1 = 16; const int CS2 = 0;

//the falgs of camera modules bool cam1=true,cam2=true,cam3=true,cam4=true; //the flag of JEPG data header bool is_header; //the falg data of 4 cameras' data byte flag[5]={0xFF,0xAA,0x01,0xFF,0x55}; int count = 0;

if defined (OV2640_MINI_2MP)

ArduCAM myCAM1(OV2640, CS1); ArduCAM myCAM2(OV2640, CS2);

else

ArduCAM myCAM1(OV5642, CS1); ArduCAM myCAM2(OV5642, CS2);

endif

void setup() { // put your setup code here, to run once: uint8_t vid,pid; uint8_t temp; Wire.begin(); Serial.begin(921600); Serial.println("ArduCAM Start!"); // set the CS output: pinMode(CS1, OUTPUT); pinMode(CS2, OUTPUT);

// initialize SPI: SPI.begin(); while(1){ //Check if the 2 ArduCAM Mini 2MP Cameras' SPI bus is OK myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM1.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI1 interface Error!")); cam1 = false; } myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM2.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI2 interface Error!")); cam2 = false; } if(!(cam1||cam2)){ delay(1000);continue; }else break; }

if defined (OV2640_MINI_2MP)

while(1){ //Check if the camera module type is OV2640 myCAM1.wrSensorReg8_8(0xff, 0x01); myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ Serial.println(F("ACK CMD Can't find OV2640 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV2640 detected."));break; } }

else

while(1){ //Check if the camera module type is OV5642 myCAM1.wrSensorReg16_8(0xff, 0x01); myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); if((vid != 0x56) || (pid != 0x42)){ Serial.println(F("ACK CMD Can't find OV5642 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV5642 detected."));break; } }

endif

myCAM1.set_format(JPEG); myCAM1.InitCAM();

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);

else

myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM1.OV5642_set_JPEG_size(OV5642_320x240);

endif

delay(1000); myCAM1.clear_fifo_flag(); myCAM2.clear_fifo_flag(); }

void loop() { // put your main code here, to run repeatedly: uint8_t temp = 0xff, temp_last = 0; uint8_t start_capture = 0; uint8_t finish_count; if (Serial.available()){ temp = Serial.read(); switch(temp) { case 0:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240"));

endif

temp = 0xff; break; case 1:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480"));

endif

temp = 0xff; break; case 2:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768"));

endif

temp = 0xff; break; case 3: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); Serial.println(F("ACK CMD switch to OV2640_352x288"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960"));

endif

break; case 4: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200"));

endif

break; case 5: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); Serial.println(F("ACK CMD switch to OV2640_800x600"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536"));

endif

break; case 6: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1024x768"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944"));

endif

break;

if defined (OV2640_MINI_2MP)

case 7: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1280x1024")); break; case 8: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1600x1200")); break;

endif

case 0x10: if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } break; case 0x20: while(1){ if (Serial.available()){ temp = Serial.read(); if (temp == 0x21)break; } if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } } break;

} } } uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp,temp_last; uint32_t length;

myCAM.flush_fifo(); myCAM.clear_fifo_flag(); myCAM.start_capture(); while(!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); length = myCAM.read_fifo_length(); myCAM.CS_LOW(); myCAM.set_fifo_burst(); length--; while( length-- ) { temp_last = temp; temp = SPI.transfer(0x00);//read a byte from spi if(is_header == true) { Serial.write(temp); } else if((temp == 0xD8) & (temp_last == 0xFF)) { Serial.println(F("ACK IMG")); is_header = true; Serial.write(temp_last); Serial.write(temp); } if( (temp == 0xD9) && (temp_last == 0xFF) ) break; delayMicroseconds(15); } myCAM.CS_HIGH(); is_header = false; //Clear the capture done flag myCAM.clear_fifo_flag(); }// ArduCAM Mini demo (C)2017 Lee // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with ArduCAM Mini 2MP camera, and can run on any Arduino platform. // // This demo was made for ArduCAM Mini Camera. // It needs to be used in combination with PC software.It can take 4 photos at the same time with 4 cameras. // The demo sketch will do the following tasks: // 1. Set the 4 cameras to JPEG output mode. // 2. Read data from Serial port and deal with it // 3. If receive 0x00-0x08,the resolution will be changed. // 4. If receive 0x15,cameras will capture and buffer the image to FIFO. // 5. Check the CAP_DONE_MASK bit and write datas to Serial port. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM Minicamera // and use Arduino IDE 1.6.8 compiler or above

include

include

include

include "memorysaver.h"

//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform.

if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED

|| defined OV2640_MINI_2MP)

error Please select the hardware platform and camera module in the

../libraries/ArduCAM/memorysaver.h file

endif

if !(defined ESP8266 )

error Please select the ArduCAM ESP8266 UNO board in the Tools/Board

endif

// set pin 4,5,6,7 as the slave select for SPI: const int CS1 = 16; const int CS2 = 0;

//the falgs of camera modules bool cam1=true,cam2=true,cam3=true,cam4=true; //the flag of JEPG data header bool is_header; //the falg data of 4 cameras' data byte flag[5]={0xFF,0xAA,0x01,0xFF,0x55}; int count = 0;

if defined (OV2640_MINI_2MP)

ArduCAM myCAM1(OV2640, CS1); ArduCAM myCAM2(OV2640, CS2);

else

ArduCAM myCAM1(OV5642, CS1); ArduCAM myCAM2(OV5642, CS2);

endif

void setup() { // put your setup code here, to run once: uint8_t vid,pid; uint8_t temp; Wire.begin(); Serial.begin(921600); Serial.println("ArduCAM Start!"); // set the CS output: pinMode(CS1, OUTPUT); pinMode(CS2, OUTPUT);

// initialize SPI: SPI.begin(); while(1){ //Check if the 2 ArduCAM Mini 2MP Cameras' SPI bus is OK myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM1.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI1 interface Error!")); cam1 = false; } myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM2.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { Serial.println(F("ACK CMD SPI2 interface Error!")); cam2 = false; } if(!(cam1||cam2)){ delay(1000);continue; }else break; }

if defined (OV2640_MINI_2MP)

while(1){ //Check if the camera module type is OV2640 myCAM1.wrSensorReg8_8(0xff, 0x01); myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ Serial.println(F("ACK CMD Can't find OV2640 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV2640 detected."));break; } }

else

while(1){ //Check if the camera module type is OV5642 myCAM1.wrSensorReg16_8(0xff, 0x01); myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); if((vid != 0x56) || (pid != 0x42)){ Serial.println(F("ACK CMD Can't find OV5642 module!")); delay(1000);continue; }else{ Serial.println(F("ACK CMD OV5642 detected."));break; } }

endif

myCAM1.set_format(JPEG); myCAM1.InitCAM();

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);

else

myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH myCAM1.OV5642_set_JPEG_size(OV5642_320x240);

endif

delay(1000); myCAM1.clear_fifo_flag(); myCAM2.clear_fifo_flag(); }

void loop() { // put your main code here, to run repeatedly: uint8_t temp = 0xff, temp_last = 0; uint8_t start_capture = 0; uint8_t finish_count; if (Serial.available()){ temp = Serial.read(); switch(temp) { case 0:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240"));

endif

temp = 0xff; break; case 1:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480"));

endif

temp = 0xff; break; case 2:

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768"));

endif

temp = 0xff; break; case 3: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); Serial.println(F("ACK CMD switch to OV2640_352x288"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960"));

endif

break; case 4: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200"));

endif

break; case 5: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); Serial.println(F("ACK CMD switch to OV2640_800x600"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536"));

endif

break; case 6: temp = 0xff;

if defined (OV2640_MINI_2MP)

myCAM1.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1024x768"));

else

myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944"));

endif

break;

if defined (OV2640_MINI_2MP)

case 7: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1280x1024")); break; case 8: temp = 0xff; myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); Serial.println(F("ACK CMD switch to OV2640_1600x1200")); break;

endif

case 0x10: if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } break; case 0x20: while(1){ if (Serial.available()){ temp = Serial.read(); if (temp == 0x21)break; } if(cam1){ flag[2]=0x01;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM1); } if(cam2){ flag[2]=0x02;//flag of cam1 for(int m=0;m<5;m++) { Serial.write(flag[m]); } read_fifo_burst(myCAM2); } } break;

} } } uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp,temp_last; uint32_t length;

myCAM.flush_fifo(); myCAM.clear_fifo_flag(); myCAM.start_capture(); while(!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); length = myCAM.read_fifo_length(); myCAM.CS_LOW(); myCAM.set_fifo_burst(); length--; while( length-- ) { temp_last = temp; temp = SPI.transfer(0x00);//read a byte from spi if(is_header == true) { Serial.write(temp); } else if((temp == 0xD8) & (temp_last == 0xFF)) { Serial.println(F("ACK IMG")); is_header = true; Serial.write(temp_last); Serial.write(temp); } if( (temp == 0xD9) && (temp_last == 0xFF) ) break; delayMicroseconds(15); } myCAM.CS_HIGH(); is_header = false; //Clear the capture done flag myCAM.clear_fifo_flag(); }

Let us now if you need more help. Regards, ArduCAM support team.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ArduCAM/Arduino/issues/179#issuecomment-300037764, or mute the thread https://github.com/notifications/unsubscribe-auth/AbOj3ZIT-l8lX8pkkpl1afRnCHRLKMksks5r38SrgaJpZM4NFw9k .

UCTRONICS commented 7 years ago

@robkwan Hi, please attach us your connection picture. Regards,

robkwan commented 7 years ago

Hello!

Here I attach two photos:-

  1. One working with DupontCables but I didn't really re-connect after I unplugged it.

  2. One not working when I just plug the camera module into the middle pin lot as I captured from the document yesterday.

Thanks & Best Regards, Robert

On Tue, May 9, 2017 at 5:32 PM, UCTRONICS notifications@github.com wrote:

@robkwan https://github.com/robkwan Hi, please attach us your connection picture. Regards,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ArduCAM/Arduino/issues/179#issuecomment-300339693, or mute the thread https://github.com/notifications/unsubscribe-auth/AbOj3YqF9TqxIUAgDTOdXgSkqRoj4CWnks5r4QWxgaJpZM4NFw9k .

UCTRONICS commented 7 years ago

@robkwan We haven't found your hardware connection picture.Please attach it again.

robkwan commented 7 years ago

Does it work this time please in the attachments?!

Thanks & BR, Robert

---------- Forwarded message ---------- From: Robert Kwan robert.kwan@gmail.com Date: Tue, May 9, 2017 at 6:22 PM Subject: Re: [ArduCAM/Arduino] ARDUCAM Mini-2mp (OV2640) connection with Arduino Uno R3 (#179) To: ArduCAM/Arduino < reply@reply.github.com

Cc: ArduCAM/Arduino Arduino@noreply.github.com, Mention < mention@noreply.github.com>

Hello!

Here I attach two photos:-

  1. One working with DupontCables but I didn't really re-connect after I unplugged it.

  2. One not working when I just plug the camera module into the middle pin lot as I captured from the document yesterday.

Thanks & Best Regards, Robert

On Tue, May 9, 2017 at 5:32 PM, UCTRONICS notifications@github.com wrote:

@robkwan https://github.com/robkwan Hi, please attach us your connection picture. Regards,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ArduCAM/Arduino/issues/179#issuecomment-300339693, or mute the thread https://github.com/notifications/unsubscribe-auth/AbOj3YqF9TqxIUAgDTOdXgSkqRoj4CWnks5r4QWxgaJpZM4NFw9k .

robkwan commented 7 years ago

On Tue, May 9, 2017 at 6:26 PM, UCTRONICS notifications@github.com wrote:

@robkwan https://github.com/robkwan We haven't found your hardware connection picture.Please attach it again.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ArduCAM/Arduino/issues/179#issuecomment-300347480, or mute the thread https://github.com/notifications/unsubscribe-auth/AbOj3SmykQzh0CkdOyde8_lKQAyqXgH0ks5r4RJEgaJpZM4NFw9k .

supprot commented 7 years ago

@robkwan image We can't see your picture....

robkwan commented 7 years ago

image

Above is the one not working...!!

image

However, using dupont cable wires, no problem. And the photo was taken after I unplugged the pins only.

Thanks & BR, Robert

robkwan commented 7 years ago

I also created another new issue for my issue as I learned more about the ArduCAM module please.

https://github.com/ArduCAM/Arduino/issues/190

Thanks & BR, Robert

robkwan commented 7 years ago

Hello!

I just found that my Arducam ESP8266 UNO V2 board keeps resetting once I connect the micro-USB to my Windows 10 laptop now. Because I turned on the speaker and the beep sound of driver issue. And so the COM7 port keeps resetting and I cannot even use the Arduino IDE to reflash the ArduCam_ESP8266_Capture.ino anymore.

Not sure if that would explain why I said that the setup would not work when I plugged in the camera module?!

Any way to reset the Arducam ESP8266 UNO V2 board to normal state please?!

Thanks & Best Regards, Robert

Vazrul commented 7 years ago

please , how to connect omnivision camera ov2640 to arduino , and the pin omvision camera ov2640 have 20 pin ???

tharangamuditha commented 7 years ago

Can anybody please give a detailed information or internet sources on programming Arducam ESP8266 UNO with ArduCAM Mini 2MP camera on making a live video streaming into a web page? Thanks & Best regards, Tharanga.

supprot commented 7 years ago

@tharangamuditha Hi, Please refer to this link: http://www.arducam.com/knowledge-base/esp8266-uno-tutorial/

tharangamuditha commented 7 years ago

Thank you for quick reply. But I already gone through it and got the outputs for image. But I could not get the video streaming. when the video.html file is opened, is a live video streaming takes place?

Thanks and Best regards, Tharanga.

On Wed, Sep 6, 2017 at 11:55 AM, supprot notifications@github.com wrote:

@tharangamuditha https://github.com/tharangamuditha Hi, Please refer to this link: http://www.arducam.com/knowledge-base/esp8266-uno-tutorial/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ArduCAM/Arduino/issues/179#issuecomment-327387355, or mute the thread https://github.com/notifications/unsubscribe-auth/AeN1ZClG9C-xqpOeBPRrJSFkS1bB_KFLks5sfjragaJpZM4NFw9k .

tharangamuditha commented 7 years ago

Thank you for quick reply. But I already gone through it and got the outputs for image. But I could not get the video streaming. when the video.html file is opened, is a live video streaming takes place? Thanks and Best regards, Tharanga.

supprot commented 7 years ago

@tharangamuditha Hi, You should choose one resolution.Then the video will be send to the web. Please try it again. Regards.

sohombrg commented 6 years ago

Hi I am have successfully connected Arducam mini module with ESP8266 nodemcu and it works fine. But now I have only 1 digital pin free for other purposes. So I wanted to know if we can modify the default wiring configuration. If so, can any one tell me how to do it.

UCTRONICS commented 6 years ago

@sohombrg ESP8266 nodemcu doesn't have enough pin source. You can use the ESP32 which has enough gpio source. http://www.uctronics.com/arducam-esp32-uno-board-for-arducam-mini-camera-module-compatible-with-arduino-uno-r3.html