Git Product home page Git Product logo

adafruit-vc0706-serial-camera-library's Introduction

  This is a library for the Adafruit TTL JPEG Camera (VC0706 chipset)

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/products/397

  These displays use Serial to communicate, 2 pins are required to interface

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution


To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_VC0706. Check that the Adafruit_VC0706 folder contains Adafruit_VC0706.cpp and Adafruit_VC0706.h

Place the Adafruit_VC0706 library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.

adafruit-vc0706-serial-camera-library's People

Contributors

astuder avatar driverblock avatar evaherrada avatar ladyada avatar paintyourdragon avatar siddacious avatar tdicola avatar tyeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit-vc0706-serial-camera-library's Issues

GetVersion() command is incorrect

I noticed when using this library, that when starting up, the getVersion() command (after begin) actually returns the power up string, not the version number.

Looking into it, I found a couple of bugs.

Begin() actually does a reset, but does not flush the serial buffer -that's why getVersion() after begin() returns the power on text.

GetVersion() itself is broken, you just get "v" and some hex from it (which probably means something). The solution for getVersion is to change the arg 0x01 to 0x00 (this is the correct value), and the return (char *) camerabuf should be camerabuf+5. I'm actually not sure what 0x01 in getVersion does (documentation says it should be 0x00).

This gives the correct version string.

You can then use this to find what baud rate the camera is running at. If you don't use begin() you can set the camera to whatever baud rate you want.

As to the begin/reset issue -don't use begin, just use the underlying serial commands (swser.begun(baud)), swser.flush() etc.) that's all begin does anyway. Use cam.reset() if you want a reset - no need to hide one in begin.

Oh, no header guards either.

Real time communication to Matlab

Using this library and an Arduino Mega, how can we serially transfer a picture to Maltab?

Meaning: This library presupposes the existence of an SD card. However, I should be able to Serial.print the data from buffer = cam.readPicture(BytesToRead). When I try that, only the first of the 32 values actually gets transferred (I also tried reading only 1 byte at a time and in that case each value got printed 8 times which is weird.)

Is there any function that supports direct serial communication?

I can't record video and store on sd card

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: INSERT ARDUINO BOARD NAME/TYPE HERE

  • Arduino IDE version (found in Arduino -> About Arduino menu): INSERT ARDUINO
    VERSION HERE

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

I can't record video through serial communication and store it on a micro SD card

Not working with Arduino Nano and 5V-ready microSD Breakout Board+

  • Arduino board: Nano

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.6.5

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

    Our camera module worked perfectly with an Arduino Uno, but as soon as we moved the wiring to a Nano, the images we capture started to show severe corruption. Some are completely empty. Here are a few of the captured images:
    image02
    image04
    image06

And here is our code:

#include <OneWire.h>
#include <DallasTemperature.h>
// This is a motion-detect camera sketch using the Adafruit VC0706 library.
// On start, the Arduino will find the camera and SD card and turn
// on motion detection.  If motion is detected, the camera will
// 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.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 Adafruit_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(2, 3);
// On Mega: camera TX connected to pin 69 (A15), camera RX to pin 3:
//SoftwareSerial cameraconnection = SoftwareSerial(69, 3);
#else
NewSoftSerial cameraconnection = NewSoftSerial(2, 3);
#endif
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);
OneWire oneWire(7);
DallasTemperature sensors(&oneWire);
bool cameraOK = false;

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
  sensors.begin();
  Serial.begin(9600);
  Serial.println("VC0706 Camera 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;
    Serial.println("Continuing without SD");
  }  

  // Try to locate the camera
  if (cam.begin()) {
    Serial.println("Camera Found:");
    cameraOK = true;
  } 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");


  //  Motion detection system can alert you when the camera 'sees' motion!
  cam.setMotionDetect(true);           // turn it on
  //cam.setMotionDetect(false);        // turn it off   (default)

  // You can also verify whether motion detection is active!
  Serial.print("Motion detection is ");
  if (cam.getMotionDetect()) 
    Serial.println("ON");
  else 
    Serial.println("OFF");
}




void loop() {

  if (!cameraOK) {
    delay(500);
    if (cam.begin()) {
      Serial.println("Camera Found:");
      cameraOK = true;
    } else {
      Serial.println("No camera found?");
      return;
    }
  }


  //---------------sense temperature here------------------
  sensors.requestTemperatures();

  float val = sensors.getTempCByIndex(0);

  val = sensors.getTempFByIndex(0);

  Serial.println(val);

  //-------------------------------------------------------


 if (val >= 78) {
   Serial.println("Owwie!");   
   //cam.setMotionDetect(false);

  if (! cam.takePicture()) {
    Serial.println("Failed to snap!");
    cameraOK = false;
  }
  else 
    Serial.println("Picture taken!");



  //----------------------save to SD------------------------------
  //---------------------------------------------------------------------

  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;
    }
  }

  File imgFile = SD.open(filename, FILE_WRITE);

  uint16_t jpglen = cam.frameLength();
  Serial.print(jpglen, DEC);
  Serial.println(" byte image");

  Serial.print("Writing image to "); Serial.print(filename);

  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);

    //Serial.print("Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");

    jpglen -= bytesToRead;
  }
  imgFile.close();
  Serial.println("...Done!");
  cam.resumeVideo();
  cam.setMotionDetect(true);
 }
}

PS thanks for this awesome set of hardware and libraries!!!

Picture data

Thank you for the library. I am wondering if it is possible to know the properties of the picture taken, like shutter speed and exposure value, etc.. Thank you

VC0706 library

I have uploaded the code and it recognizes the card but says that no camera is found. Upon looking into the code i noticed that the VC0706.h was not correctly recognized. It did not show an error but it did not show in orange like the other libraries. If anyone can think of a solution please help. Thanks

Change resolution

I send
cam.setImageSize(VC0706_320x240);

But the cam remain in the prior resolution 640x480 also if in

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");

Return me 320x200 but the size remain 640x480.

N

Begin response confuses getVersion

This issue started when I noticed an intermittent failure of the camera getVersion() command. Adding some debug I found the verifyResponse was failing. In my case it was reading the string ‘Init end’ instead of the expected command response. The problem turned out to be the reset in begin() which triggers the camera to respond with:

VC0703 1.00
Ctrl infr exist
User-defined sensor
525
Init end

For anyone that is seeing a similar problem, as a work-around, I have found that running CamSerial.find("Init end") or just a 1 second delay after calling begin() will allow that output to be flushed out.

While exploring this issue I also realized that the getVersion() command only appeared to be working for me because it was returning the output of the begin() call before it. The problem was, as NickWaterton (https://github.com/NickWaterton) pointed out in his ticket ##12, the arg value for GEN_VERSION command should be 0x00 not 0x01. Also, the returned string needs to skip over the standard response header in order to return the version string.

Rather than use the work-around above, I have added the code to consume the "basic configuration information" to the reset() function itself. I have created a pull request to make these changes here: ##31

This is what my test code looks like:

  CamSerial.begin(38400, SERIAL_8N1, CAM1_RX, CAM1_TX, false, 20000UL);    
  delay(500);

  if (Cam.begin()) {
    Serial.println("Camera Found");
  } else {
    Serial.println("No camera found?");
    HACF();
    return false;
  }

  char *reply = Cam.getVersion();
  if (reply == 0) {
    Serial.print("Failed to get version");
  } else {
    Serial.printf("Version: %s\n", reply);
  }

the variable "baud", a uint16_t, is too small to hold values > 65535 preventing 115200 bps

the variable "baud", a uint16_t, is too small to hold values > 65535 preventing 115200 bps

because of that, a call to cam.begin(115200) will not correctly set the variable "baud".
The uint16_t variable "baud" will only hold values up to 65535 (2^16-1).
I recommend converting that variable to a uint32_t.

Now if only I could get the actual baud rate to change! The camera is slow at 38400.

Error Upon Running the program

Traceback (most recent call last):
File "C:\Users\Benson\Desktop\Python33\pyserial-2.7\serial\Pyhton Arduino Camera sketch.py", line 120, in
if (not getversion()):
File "C:\Users\Benson\Desktop\Python33\pyserial-2.7\serial\Pyhton Arduino Camera sketch.py", line 54, in getversion
if checkreply(r, CMD_GETVERSION):
File "C:\Users\Benson\Desktop\Python33\pyserial-2.7\serial\Pyhton Arduino Camera sketch.py", line 36, in checkreply
if (r[0] == 0x76 and r[1] == SERIALNUM and r[2] == b and r[3] == 0x00):
IndexError: list index out of range

Thank you for any help on this matter I have double checked all of my code and believe that it is the exact same as what you have posted, I am running python 3.3.4 and can't come to a conclusion why I am getting an out of range error.

python code for interfacing to VC0706 cameras and grabbing a photo

pretty basic stuff

written by ladyada. MIT license

import serial

BAUD = 38400
PORT = "COM4" # change this to your com port!
TIMEOUT = 0.2

SERIALNUM = 0 # start with 0

COMMANDSEND = 0x56
COMMANDREPLY = 0x76
COMMANDEND = 0x00

CMD_GETVERSION = 0x11
CMD_RESET = 0x26
CMD_TAKEPHOTO = 0x36
CMD_READBUFF = 0x32
CMD_GETBUFFLEN = 0x34

FBUF_CURRENTFRAME = 0x00
FBUF_NEXTFRAME = 0x01
FBUF_STOPCURRENTFRAME = 0x00

getversioncommand = [COMMANDSEND, SERIALNUM, CMD_GETVERSION, COMMANDEND]
resetcommand = [COMMANDSEND, SERIALNUM, CMD_RESET, COMMANDEND]
takephotocommand = [COMMANDSEND, SERIALNUM, CMD_TAKEPHOTO, 0x01, FBUF_STOPCURRENTFRAME]
getbufflencommand = [COMMANDSEND, SERIALNUM, CMD_GETBUFFLEN, 0x01, FBUF_CURRENTFRAME]

def checkreply(r, b):
r = map (ord, r)
if (r[0] == 0x76 and r[1] == SERIALNUM and r[2] == b and r[3] == 0x00):
return True
return False

def reset():
cmd = ''.join (map (chr, resetcommand))
s.write(cmd)
reply = s.read(100)
r = list(reply)
if checkreply(r, CMD_RESET):
return True
return False

def getversion():
cmd = ''.join (map (chr, getversioncommand))
s.write(cmd)
reply = s.read(16)
r = list(reply);
if checkreply(r, CMD_GETVERSION):
print r
return True
return False

def takephoto():
cmd = ''.join (map (chr, takephotocommand))
s.write(cmd)
reply = s.read(5)
r = list(reply);
if (checkreply(r, CMD_TAKEPHOTO) and r[3] == chr(0x0)):
return True
return False

def getbufferlength():
cmd = ''.join (map (chr, getbufflencommand))
s.write(cmd)
reply = s.read(9)
r = list(reply);
if (checkreply(r, CMD_GETBUFFLEN) and r[4] == chr(0x4)):
l = ord(r[5])
l <<= 8
l += ord(r[6])
l <<= 8
l += ord(r[7])
l <<= 8
l += ord(r[8])
return l

return 0

readphotocommand = [COMMANDSEND, SERIALNUM, CMD_READBUFF, 0x0c, FBUF_CURRENTFRAME, 0x0a]

def readbuffer(bytes):
addr = 0
photo = []

while (addr < bytes + 32):
    command = readphotocommand + [(addr >> 24) & 0xFF, (addr >> 16) & 0xFF,
                                  (addr >> 8) & 0xFF, addr & 0xFF]
    command +=  [0, 0, 0, 32]   # 32 bytes at a time
    command +=  [1,0]         # delay of 10ms
    #print map(hex, command)
    cmd = ''.join(map (chr, command))
    s.write(cmd)
    reply = s.read(32+5)
    r = list(reply)
    if (len(r) != 37):
        continue
    if (not checkreply(r, CMD_READBUFF)):
        print "ERROR READING PHOTO"
        return
    photo += r[5:]
    addr += 32
return photo
## main

s = serial.Serial(PORT, baudrate=BAUD, timeout=TIMEOUT)

reset()

if (not getversion()):
print "Camera not found"
exit
print "VC0706 Camera found"

if takephoto():
print "Snap!"

bytes = getbufferlength()

print bytes, "bytes to read"

photo = readbuffer(bytes)

photo = readbuffer(5024)

f = open("photo.jpg", 'w')
print photo
photodata = ''.join(photo)
f.write(photodata)
f.close()

print len(photo)

VC0706 with node mcu

can we use node mcu instead of arduino board to capture image through vc0706 and send it to server ?

Make it Mega compatible

SoftwareSerial isnt supported so we need to make it so you can also alternately use a Mega Serial port

SoftwareSerial should be optional for some boards

  • Arduino board: Feather M0

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.1

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

The library does not build without SoftwareSerial support.

There should be preprocessor guards around all the SoftwareSerial functions similar to the Adafruit_BluefruitLE_nRF51 Library:

#define SOFTWARE_SERIAL_AVAILABLE   ( ! (defined (_VARIANT_ARDUINO_DUE_X_) || defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_STM32_FEATHER)) )

A reference commit from the Adafruit_BluefruitLE_nRF51 repo: adafruit/Adafruit_BluefruitLE_nRF51@bdad611

Crashing on file write using ESP-01 w/SPIFFS

I am trying to convert the use of the example to write to a file in SPIFFS on an esp8266 instead of an SD card. I would really like to see if I could get the serial camera working on an ESP-01 due to it's small size and the fact the camera only needs the two data pins.

I'm using the ESPSoftwareSerial which appears to work fine as the code recognizes my camera. I changed the file open command to the SPIFFS variation, adding '/' in front of the filename and replacing the FILE_WRITE with "w". But when the .write(buffer, len) is called, it crashes. I think this is to do with the fact the buffer is unbounded. (is not a fixed length array)
This got me to examining how the adafruit code worked and they seem to be passing a pointer to an internal unbounded array out of the code. Isn't that a no-no in C++? i.e. shouldn't you accept a pointer 'into' the function then populate it locally so that the 'buffer' is sure to be memory resident when it returns to the main program?

Any suggestions or help to get this working would be appreciated. As written, I can't seem to get it to to work.

My relevant code:

    // Create an image with the name Image.jpg
    String filename = "/Image.jpg";
    Serial.println("Writing file to SPIFFS: " + filename);
    if (!SPIFFS.exists(filename))
        SPIFFS.remove(filename);

    // Open the file for writing
    File imgFile = SPIFFS.open(filename, "w");

    // Get the size of the image (frame) taken
    uint16_t jpglen = cam.frameLength();
    byte wCount = 0; // For counting # of writes
    // read 64 bytes at a time;
    uint16_t minByte = 64;

    Serial.print("Storing ");
    Serial.print(jpglen, DEC);
    Serial.print(" byte image.");

    int32_t time = millis();

    // Read all the data up to # bytes!
    while (jpglen > 0) {
        uint8_t *buffer;
        uint8_t bytesToRead = min(minByte, jpglen);
        // reads data from a jpeg camera on SoftwareSerial 64 bytes at a time
        buffer = cam.readPicture(bytesToRead);
        Serial.print("-> Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");
        // **** ------>>>>  throwing exception at the following line <<<<------ ****
        imgFile.write(buffer, bytesToRead);
        Serial.print("Wrote -> ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");
        jpglen -= bytesToRead;
    }
    imgFile.close();

No "Stop taking pictures" function

Although there is a function that does send the Stop taking pictures command (boolean resumeVideo(void)) it is not a very user friendly way of resetting the picture. Also, the name of the function boolean takePicture(void) indicates that a new picture is taken, which is only the case for the first picture.

I would suggest that the Stop taking pictures command is sent inside the boolean takePicture(void) function before a new picture is taken.

begin(baud) might not work

begin(baud) does not work for a baud value other than 38400. (This is assuming you haven't done anything to change the camera's Flash or E2PROM values.)

The begin function sets the serial communication rate to the baud argument. It then issues a reset command over the serial interface.

There are two problems with this :

  1. if the baud argument does not match the rate the camera is currently set at then there can be no communication and the reset command will not be seen by the camera.

  2. Even if the baud argument does match the camera's current setting the 'reset' will change the camera to its default value of 38400 ensuring a mismatch between the serial interface and the camera thus preventing any further commands from working.

I ran into these problems when I had a sketch that did a begin() and later did a setBaud115200(). If I let the sketch run following a power-up it worked fine. But if I did a MCU reset (by pressing the MCU's reset button or simply by uploading a new sketch) the begin() failed. This is because when the sketch started to rerun the camera knew nothing about the reset hence it was still set at 115200 and the begin() command could not talk to the camera. If I changed the begin() to begin(115200) it could communicate and reset the camera, but as explained in 2), it was then mismatched after a complete power-up.

I solved my problem by 'searching' for the camera's baud setting by first trying a begin() and if not successful trying begin(115200). Once I had a successful begin() I knew the camera was at 38400 so I could set the serial rate also to 38400 and then could manually set my desired communication rate :

cam.setBaud115200();
Serial1.end(); // not sure this is needed
Serial1.begin(115200);

I wonder if the begin function should either not be used to set the baud rate or perhaps do something like I did...

Not receiving a response from the camera - RasPi

I am trying to use the raspi_camera.py script and I am not receiving any messages. The motion detection is working, as I can see the LEDs turn on. After hours of searching and trying many different changes, I have nothing and always come up with the same IndexError because I am not receiving a response.

Any help would be greatly appreciated. Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.