-
February 11th, 2014, 04:21 AM
#1
Wireless Surveillance System using Arduino and Zigbee
I am trying to implement same thing as given in following image
i m working on "Wireless surveillance system using zigbee".
But i want to add external PIR motion sensor and wireless zigbee module with Arduino.
The images are stored in SD card. but my goal is when the PIR detects any motion the image should be stored in memory card (Done in attached code)and then that image should be transferred through zigbee (Zigbee Tx is connected with Rx Pin0 and zigbee Rx is connected with Tx Pin1). PIR sensor output is connected with Pin7 of arduino.
So what are the additions/modifications do i require for transmitting image on Pin1 in following code.
I am using this code
Code:
I am trying to implement same thing as given in following link
http://learn.adafruit.com/system/assets/assets/000/000/214/medium800/cameraduino.jpeg?1340249015
i m working on "Wireless surveillance system using zigbee".
But i want to add external PIR motion sensor and wireless zigbee module with Arduino.
The images are stored in SD card. but my goal is when the PIR detects any motion the image should be stored in memory card (Done in attached code)and then that image should be transferred through zigbee (Zigbee Tx is connected with Rx Pin0 and zigbee Rx is connected with Tx Pin1). PIR sensor output is connected with Pin7 of arduino.
So what are the additions/modifications do i require for transmitting image on Pin1 in following code.
I am using this code
// 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.
#include <Adafruit_VC0706.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>
// Adafruit SD shields and modules: pin 10
#define chipSelect 10
// 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);
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 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");
// 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 (cam.motionDetected()) {
Serial.println("Motion!");
cam.setMotionDetect(false);
if (! cam.takePicture())
Serial.println("Failed to snap!");
else
Serial.println("Picture taken!");
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);
}
}
-
February 11th, 2014, 11:42 AM
#2
Re: Wireless Surveillance System using Arduino and Zigbee
Search bing for "arduino light sensor tutorial"
-
February 12th, 2014, 08:02 AM
#3
Re: Wireless Surveillance System using Arduino and Zigbee
Also. Wrong forum.
the Arduino programming typically happens in C (or rather C modules ("sketches") on top of the arduino framework).
- you make mention of memory card, but none of your "hardware" seems to have any of this.
- I'm not entirely up to spec on all the arduino compatible modules, but it doesn't look like that particular camera module has a data-interface, rather, it outputs the video on the RCA jack (composite video).
- also, it appears you're using digital pin 13. Note you can't use this particular pin like the others, since it's usually got a built in resistor and led.
Build up your arduino sketch in steps.
write code to test the individual modules and to make sure you understand how to program them, then tie them all together.
It's important to do it this way to make sure you haven't made a wiring problem.
don't remove your test code, keep it in there but comment it out so you have it handy if you need to test again.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|