8 Replies Latest reply on Jul 28, 2015 6:30 PM by elwolv

    camera module serial

    Heshamnouby

      hello I want before I buy a camera for tiff photos I want to ask which camera is the best for intel galielo iot image

       

      and cai I connect it with pins 0-1 cause 2-3 are buzy

       

      I want to take a pic only !

       

      thank u

        • 1. Re: camera module serial
          Intel_Peter

          Hello Heshamnouby,

           

          Unfortunately I can't recommend you any cameras because we haven't verified any. This doesn't mean that it won't work, just that there are no official tests using a camera.

          Regarding your second question, yes, as long as the camera complies with the requirement of communicating through UART, you should be able to use pins 0 and 1 of the Galileo. So, I'd suggest you to search for a camera that uses the UART interface.

           

          Peter.

          • 3. Re: camera module serial
            Intel_Peter

            Well, by taking a quick look at the overview of the camera, I don't see why it wouldn't work with the Galileo. However this doesn't mean that it is validated. You'll have to test it to see if it works. Also, another important point that you have to keep in mind is whether or not the Arduino libraries are compatible with the Galileo's x86 architecture.

             

            As I mentioned, my best suggestion for you would be, first to check the compatibility of the libraries and then test it to see if it works.

             

            Peter.

            • 4. Re: camera module serial
              Heshamnouby

              @Intel_Peter

               

              this code compiles well but can I use it on pins 0-1 ?

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

              // If using an Arduino Mega (1280, 2560 or ADK) in conjunction
              // with an SD card shield designed for conventional Arduinos
              // (Uno, etc.), it's necessary to edit the library file:
              //   libraries/SD/utility/Sd2Card.h
              // Look for this line:
              //   #define MEGA_SOFT_SPI 0
              // change to:
              //   #define MEGA_SOFT_SPI 1
              // This is NOT required if using an SD card breakout interfaced
              // directly to the SPI bus of the Mega (pins 50-53), or if using
              // a non-Mega, Uno-style board.

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


              // comment out this line if using Arduino V23 or earlier
              #include <SoftwareSerial_class.h>        

              // uncomment this line if using Arduino V23 or earlier
              // #include <NewSoftSerial.h>      

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

              // Pins for camera connection are configurable.
              // With the Arduino Uno, etc., most pins can be used, except for
              // those already in use for the SD card (10 through 13 plus
              // chipSelect, if other than pin 10).
              // With the Arduino Mega, the choices are a bit more involved:
              // 1) You can still use SoftwareSerial and connect the camera to
              //    a variety of pins...BUT the selection is limited.  The TX
              //    pin from the camera (RX on the Arduino, and the first
              //    argument to SoftwareSerial()) MUST be one of: 62, 63, 64,
              //    65, 66, 67, 68, or 69.  If MEGA_SOFT_SPI is set (and using
              //    a conventional Arduino SD shield), pins 50, 51, 52 and 53
              //    are also available.  The RX pin from the camera (TX on
              //    Arduino, second argument to SoftwareSerial()) can be any
              //    pin, again excepting those used by the SD card.
              // 2) You can use any of the additional three hardware UARTs on
              //    the Mega board (labeled as RX1/TX1, RX2/TX2, RX3,TX3),
              //    but must specifically use the two pins defined by that
              //    UART; they are not configurable.  In this case, pass the
              //    desired Serial object (rather than a SoftwareSerial
              //    object) to the VC0706 constructor.

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

              Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);

              // Using hardware serial on Mega: camera TX conn. to RX1,
              // camera RX to TX1, no SoftwareSerial object is required:
              //Adafruit_VC0706 cam = Adafruit_VC0706(&Serial1);
              int min(int num1, int num2)

              {

                   if(num1 < num2)

                   {

                        return num1;

                   }else{

                        return num2;

                   }

              }

              void setup() {

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

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

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

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

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

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

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

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

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

              void loop() {
              }

              • 5. Re: camera module serial
                Intel_Peter

                Hi Heshamnouby,

                 

                I can see that it includes the SotwareSerial library. It is not compatible with the Galileo. So, no I don't think this code will work without any modifications. However you may be able to make it work, if you change the software serial for the Galileo's UART ports. This shouldn't be so hard, however it may take a couple of hours of work.

                 

                Peter.

                • 6. Re: camera module serial
                  elwolv

                  hello;

                   

                  i see you comment in passing about camera, i am trying to get EMIC2 to work !

                   

                  since i could not get SoftwareSerial to work (recognize the .h file location)

                  working on serial library for camera in Galileo, may be good idea

                   

                       "if you change the software serial for the Galileo's UART ports"

                  could we be specific and simple, in answering simple questions for that aspect

                  1-  how do we change, what do you means by modify for example the SoftwareSerial

                  2-  waht about the existing softwareSerial on Galileo, why this library a mystery

                  what that make not working, the interrupt nature or technically why they different, regardless of hardware

                  difference that has to be taken care of, but the calls has the same name, even if wrong and give error

                  then we know the function code wrong for the hardware and fix accordingly.  in this case 2 hour possible task!!!

                   

                  thank for the enlighten us !!

                   

                  can you give us the first few steps to start !!

                  • 7. Re: camera module serial
                    Intel_Peter

                    Hello elwolv,

                     

                    The reason why SoftwareSerial is not compatible with the Galileo is because this library is dependent of the Arduino's AVR architecture.

                    What I meant by modifying the library was that  it could be changed to be compatible with the Galileo's x86 architecture, however that is not a simple task, it may take a lot of time actually; nevertheless it is possible.

                    Now, you could eliminate the SofwareSerial library entirely from your code and adjust it to use the Galileo's serial port, found on pins 0 and 1 as stated on Intel® Galileo Datasheet.

                    I hope I've cleared out your doubts, if otherwise, feel free to ask me I'll try to be clearer :).

                    By the way; as I mentioned, this library is not supported on the Galileo but I believe this workaround may interest you: Galileo/Arduino-Examples/SoftwareSerial at master · MakersTeam/Galileo · GitHub

                     

                    Peter.

                    • 8. Re: camera module serial
                      elwolv

                      thank you for clarity !!

                      it should be, prudent, on us to remember this fact at hat all Arduino libraries based on AVR, and has to be changed to x86 assembly structure

                      to be functional and Intel did the best they can so far.

                       

                      correct building a serial communication from our experience in x86 not trivial and very delicate in information understanding and programming

                      correctness to just build the UART communication module code and its assembly code in absence of some language targeted I/O commands.

                       

                      For back ground clarity: one yes enough

                      Q:   Arduino uses 2,3 pins means UART 1 on Gelileo?  yes

                      Q:  Galileo uses its native serial library which in this case what present in Arduino IDE (1.6.5 version, we should be able to get the correct

                      library API from there. 

                      Next revise an Arduino based code to these correct include and reference and API calls with caution of difference error)?   yes

                      Q:  Galileo plans for UART 0 and 1, should not be confused with Adruino UNO native plans.

                      in Galileo we use UART 1 = pin 2,3 for serial monitor communication to be the head of the program development as in PuTTY and Eclipse? yes

                      then we should not attempt to use UART 1 = pin 2,3 in any serial communication using any program in this case using C/C++ Eclipse IDE? yes

                      Q:  we use pins 0,1 for UART zero then we be able to access one free TTL UART with the outside device?  yes

                      Q:  the fact that Arduino using USB client VCP communication does not mean the UART 1 pin 2,3 should be treated in typical manner

                      as they mapped by the OS Linux toward the communication task of serial monitor program, hence Arduino IDE not able to communicate

                      with OS shell unless we use  {Galileo Getting Started Guide - learn.sparkfun.com}  custom made Arduino sketch to communicate through

                      this channel in OS.

                      we find that Arduino UNO mapped differently form Arduino Galileo: yes

                      Arduino Galileo Compiler/Flash OS image, mapped to UART 0 for external communication between Arduino program and external

                      devices with TTL communication.  however, Arduino UNO uses also VCP for communication, can use UART 1, in devices communication

                      like the one in EMIC2 then we try to make software serial to talk through pin 2,3 in manner that Galileo will not allow as we see in sparkfun demo.

                       

                      if all that correct one yes,

                      last question:

                       

                      can we have some articles discussing how to include a .ccp and .h to Galileo library of Arduino IDE, since most of the current users migrating

                      like me from Arduino to Galileo.  we understand that language command has to be based on any API exists in Galileo version only

                      'and not to be mixed with codes coming for UNO, we should not migrate except using the current library on 1.6.5-r2 or latter library? yes

                       

                      if that the case Arduino web page libraries based on API made for Arduino, not for Gelileo, even if they the same? no they represent only the same

                      but mapped ti Intel Galileo version, however, there difference, subtle and we should test on Galileo, to make sure we addressing the correct pins

                      for the correct function on Galileo, not on UNO.  then how do we find those differences listed, if any other than the not-obvious serial?

                       

                      why we can not access a .h/.cpp code as we we experiencing with the current       #include <sofrwareserial.h>,  the error could not find the file, not not bale to read or compile the file?  this question running around and not answered?

                       

                      thank you for your help, sincerely;

                      elwolv