Hey Guys,
I am new to arduino, and brand new to this forum so I am hoping that I am posting in the correct category. We have had some security issues and as a result I installed a couple of IP cameras made by foscam and turned one of my PCs into a camera server with a program called BlueIris. Some of you may be familiar with this but the story goes that for a while now I have been using it's video based motion detection with good results but a massive amount of false alarms. These false alarms are very annoying and I am beginning to not notice them as much (BlueIris sends push alerts to my cell). However BlueIris has support for digital I/O boards, one of which being our favorite uno R3. Unfortunately it will only recognize one uno, and it must be on a com port (IE attached via USB). So here is my end goal:
I bought a batch of Arduino goodies that included an R3 uno, and a Yun. I bought a LAN shield for the Uno and a couple of PIR sensors.
Idea is, I have the Uno attached to my PC via USB, and it also has a PIR sensor on it. I then will place the Yun outside in a custom built box (yet to be designed but not a big deal) with several PIR sensors to watch over our vehicle. The Uno will activate my indoor cameras, and the Yun my outdoor along with all the alarms and push alerts. The Uno must be able to check the Yun for sensor highs and lows. This should be very reliable, and also more efficient as the PC will not have to sit there and crunch numbers on the pixels for the motion detection day and night.
I have been learning the language on my own, and looking at some other guys who did something similar (my situation is much different, though). Right now, I have the Uno with the LAN shield in a situation where it works successfully with the indoor cameras and I can see it on the network. I also have the Yun attached to the network via Wifi, however I cannot get the two to talk to each other.
I started off with the Uno and no LAN shield just to put it into service on the indoor cameras. The following code works perfectly and I have had zero false alarms this week:
//second attempt at making a PIR activate onboard LED as well as BI trigger
//THIS SKETCH IS SUCCESSFUL WITH TRIGGERING INDOOR CAMERA
//USE ARDUINO UNO R3 WITH CHINESE ADJUSTABLE PIR ON COM3 AND SERIAL BIT 2 IN CAMERA OPTIONS
//vars
int calibrationTime = 60;
int ledPin = 9; //led pin number
int pirPin1 = 2;//digital pin connected to primary PIR out
long unsigned int lowIn; //time the sensor outputs a low impulse
long unsigned int pause = 5000;//amount of millis the sensor has to be low before we assume all motion has stopped
boolean lockLow = true;
boolean takeLowTime;
void setup() {
Serial.begin(9600);
pinMode(pirPin1,INPUT);
pinMode(ledPin,OUTPUT);
//sensor calibration
for(int i = 0; i<calibrationTime; i++){
digitalWrite(ledPin,HIGH);
delay(30);
digitalWrite(ledPin,LOW);
delay(970); //flashes LED until calibration over
}
Serial.print(0);
}
void loop() {
//Primary PIR sensor
if(digitalRead(pirPin1) == HIGH){
digitalWrite(ledPin,HIGH); //turn on the LED when motion sensed
if(lockLow){
//makes sure we wait for transition to LOW before any further output is made
lockLow = false;
}
takeLowTime = true;
Serial.print(2); //send ASCii signal to BI to start recording
}
if(digitalRead(pirPin1) == LOW){
digitalWrite(ledPin, LOW);//LED turns off or stays off
if(takeLowTime){
lowIn = millis(); //save the time of the transtion high->low
takeLowTime = false;
}
//if the sensor is low for more than the given pause,
//we assumee that no more motion is going to happen
if(!lockLow && millis() - lowIn > pause){
//makes sure this block of code is only executed again
//after a new motion sequence has been detected
lockLow = true;
}
Serial.print(0);//triggers off on BI
}
}
I was very happy with this and feeling pretty professional about it too. However, moving on to modifying this code to work on and with the Yun has completely stumped me. Following is my current attempt.