BI and external I/Os

vincenttor

Getting the hang of it
Joined
Oct 2, 2014
Messages
210
Reaction score
47
I actually already ordered a uno arduino for a couple of dollars, but what i like to achieve is just use a port to trigger the recording in blueiris.
Since we have some "cheaters" putting false coins in the coin acceptor machine and we mounted a small IP cam in the box so we see what kind of coin is dropped in and in the corner of the room a cam so we can see who ;)
When a coin is dropped and everything in motion is set on high it does not always see the coins fall in so i like to connect the wire to the arduino when it accepts a coin the arduino gets 5V for example and starts recording.

Is blueiris compatible with a usb connected board as well, it does not have to be fancy like the yun.

Foto800-PIUL7UM8.jpgFoto800-USHUNTD7.jpgcoin.jpg
 
Last edited by a moderator:

vincenttor

Getting the hang of it
Joined
Oct 2, 2014
Messages
210
Reaction score
47
Thanks Nayr,
i will look into it when the arduino arrives .
Hope to get such a thing working and if i don't get it up and running i think i have to order a ethershield then.
 

bigcheese

n3wb
Joined
Oct 14, 2014
Messages
7
Reaction score
0
#include <Ethernet.h>
#include <SPI.h>

byte mac [] = {0X90,0xA2,0xDA,0xDE,0xD4,0x7E};
IPAddress ip(192,168,1,151);
EthernetServer server(8151);

void setup()
{
Ethernet.begin(mac,ip);
server.begin();
}
void loop()
{
EthernetClient client = server.available();

{
if(client){
boolean currentLineIsBlank = true;
while (client.connected()){
if(client.available()){
char c = client.read();

if(c == '\n' && currentLineIsBlank) {

if (digitalRead(4) == 0)
{client.print(1);}
else
{client.print(0);}

if (digitalRead(5) == 0)
{client.print(2);}
else
{client.print(0);}


break;
}
if (c == '\n'){
currentLineIsBlank = false;
}
}
}
delay(10);
client.stop();
}
}



}
Hello everyone,
I am using BI for over a year and now I decided to use Arduino to handle a sensor OFF / ON to trigger a camera, but frankly speaking I do not know where to begin.
Stonewatch I saw your codes webclient and webserver and I would like to go this route.
I uploded the sckech on Arduino but I honestly do not know how to use them in connection with BI-DIO.
Kindly I ask you if you can draw a block diagram summary of how your project, such as Arduino Arduino Client Server and interact with BI-DIO
Thank you very much
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
ok so that code creates a telnet server listening on port 8151, looks like you connect and send it an empty line (hit enter) it then returns the status of digital pins 4&5, if gpio4 is triggered it returns: 1, if gpio5 is triggered it returns 2, other-words it returns zero and waits for you to send another empty line.

how that hooks into BI i dunno, it must have something running that waits for those zero's to change and then trigger something.


found this w/a lil googling, looks right.
Blue Iris also monitors for incoming serial data, and interprets each incoming byte as the 8-bits representing digital input numbers 0-7, which may be used to trigger the Motion detector.
looks like you need to tell BI to connect to the Arduino over ethernet and watch for events pertaining to a BI trigger you have setup.

 

stonewatch

Young grasshopper
Joined
Apr 1, 2014
Messages
31
Reaction score
8
This basic Arduino-client is connected to the BI-PC via USB and monitors one remote server. If this server shows 1 it writes 1 otherwise 0.



camsetting.PNG

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF7, 0xF8 };
IPAddress server1(192,168,1,161);
IPAddress ip(192,168,1,170);
EthernetClient client;

void setup() {

Ethernet.begin(mac, ip);
Serial.begin(9600);
Serial.print(0);
}

void loop(){

Serial.print(0);

if(client.connect(server1,8161)){
client.println();
}
delay(100);
if (client.available())
{
char c = client.read();
if(int(c) == 49)
{
Serial.print(1);
}
delay(100);

Serial.print(0);
}

client.stop();

}
 

stonewatch

Young grasshopper
Joined
Apr 1, 2014
Messages
31
Reaction score
8
And the basic server mounted close to the PIR motion detector: If pin 4 of this Arduino-ethernet is switched to ground by the MD then "1" is displayed on the webpage of this board otherwise "0".

The client periodically checks this number and acts accordingly.

noevent.PNG


#include <Ethernet.h>
#include <SPI.h>

byte mac [] = {0X90,0xA2,0xDA,0xDE,0xD4,0x7E};
IPAddress ip(192,168,1,161);
EthernetServer server(8161);

void setup()
{
Ethernet.begin(mac,ip);
server.begin();
}
void loop()
{
EthernetClient client = server.available();

{
if(client){
boolean currentLineIsBlank = true;
while (client.connected()){
if(client.available()){
char c = client.read();

if(c == '\n' && currentLineIsBlank) {

if (digitalRead(4) == 0)
{client.print(1);}
else
{client.print(0);}



break;
}
if (c == '\n'){
currentLineIsBlank = false;
}
}
}
delay(10);
client.stop();
}
}



}
 

bigcheese

n3wb
Joined
Oct 14, 2014
Messages
7
Reaction score
0
Thank you, I'm tryng to understend the sketch.. :) the above sketch is it complete as it is? I mean, may I upload to the Arduino+Ethernet shield? (sorry for my english I speak better italian!! ) :)
I understand that the trigger is done via Arduino USB and not via Ethernet shield, is that right?
 
Last edited by a moderator:

bigcheese

n3wb
Joined
Oct 14, 2014
Messages
7
Reaction score
0
No, I'm sorry, I did all the above tests but nothing happen on the BI cam. One question: port 8161 is the port assigned to the cam? May my mistake is that!!
 

bigcheese

n3wb
Joined
Oct 14, 2014
Messages
7
Reaction score
0
I still do not have positive results.
Maybe I'd better explain what I want to accomplish, hoping you can help me in drafting the Arduino sketch. (I've never edited Arduino skech, normally I use Flowcode much easier for me, but unfortunately Flowcode did not manage Arduino Ethernet Shield)
I want to check a sensor anti-flooding and if the sensor is activated by the presence of water it should trigger the cam in BI that it will immediately place an e-mail alert. That's all!

I hope to have better explained my project.
Thank you very much for your help
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
he is using two arduino's, one plugged into BI server and another remote on network and they talk to eachother..
 

stonewatch

Young grasshopper
Joined
Apr 1, 2014
Messages
31
Reaction score
8
To make it even simpler 1 input 1 arduino no network. Input signal here on Pin 4 is converted to serial 1 or 0. Interval is 1 second delay set 1000ms.

#include <SPI.h>

int Input = 4;

void setup()
{
pinMode (Input,INPUT);
Serial.begin(9600);
}
void loop()
{
Serial.print(0);
if (digitalRead(Input) == HIGH){
Serial.print(1);

}
delay(1000);
}

sufficiente ?
 

bigcheese

n3wb
Joined
Oct 14, 2014
Messages
7
Reaction score
0
To make it even simpler 1 input 1 arduino no network. Input signal here on Pin 4 is converted to serial 1 or 0. Interval is 1 second delay set 1000ms.

#include <SPI.h>

int Input = 4;

void setup()
{
pinMode (Input,INPUT);
Serial.begin(9600);
}
void loop()
{
Serial.print(0);
if (digitalRead(Input) == HIGH){
Serial.print(1);

}
delay(1000);
}

sufficiente ?
Hello stonewatch, with yours simple codes now I can see on the serial monitor Com4 the value of the sensor switch 1 and 0 (I used a small switch connected on pin 4 of Arduino without Ethernet shield), but BI does not detect anything, of course I configured BI to detect the signal on port COM4. There are other configurations to be made? In the tab Camera Property I set to detect 1 to make the trigger, I also tried to set the detection on bit 4, but nothing at all!
Some more helps?
Thank you!!!
 

bigcheese

n3wb
Joined
Oct 14, 2014
Messages
7
Reaction score
0
Finally it works !!
The problem was that the serial monitor of the Arduino IDE kept busy Com4 and therefore was not detected the activation of the switch by the BI!!
Next step, to check the sensor remotely. On this step I will apply your codes as server and client with ethernet shield! is that correct?
Thanks
 

mrnevitt

n3wb
Joined
Nov 13, 2014
Messages
1
Reaction score
0
Ok so I set up something similar using an Adafruit Trinket (mini version of an Ardunio) and the Bluefruit EZ-Link (bluetooth). I can see on my computer using the serial monitor that every time the PIR is tripped, I get a "1". When I reset everything and make sure the Blue Iris has control of the com port, I get nothing when the PIR is tripped. I have one of the cameras set to trigger with DIO bits 1 and am using the following code:

/*
* PIR sensor
*/


#define SerialPin 0


#include <SoftwareSerial.h> // Software serial library (standard in Arduino 1.x +)
SoftwareSerial Serial(2,0); // Serial transmission on Trinket Pin 0, receive pin 2 (not used)

int ledPin = 1; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected


void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input

Serial.begin(9600);
Serial.println("Alarm System"); // Initialize message (can read to determine reset)
}

void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
Serial.println(1);
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
Serial.println(0);
// We only want to print on the output change, not state
pirState = LOW;
}
}
}

Any help would be greatly appreciated. Thanks!
 
Joined
Apr 21, 2015
Messages
6
Reaction score
0
I have the same problem.
I tried anything, like you can read on my post, but nobody help me.

I can not trig only 1 camera. Please help me.
 

stonewatch

Young grasshopper
Joined
Apr 1, 2014
Messages
31
Reaction score
8
The command is Serial.print(0) not Serial.println(0)

perhaps this helps.

BTW my Aduino-ethernet based BI-systems work very well.
 
Joined
Apr 21, 2015
Messages
6
Reaction score
0
Thank for reply but i try again for to be sure, but nothing change: serial.print(1) activate camera 1-3-5-7 serial.print(4) activate camera 4-5-6-7..... I tried also serial.print(n,BIN)
 
Joined
Apr 21, 2015
Messages
6
Reaction score
0
I don,t know if can help some one

I have no problem to receive digital i/o DIO from arduino, i regular receive 48,49,50 when dio option is set in camera alert panel. Arduino must be connected direcly to the pc.
For to check transmission on monitor, and send BYTE,
(and easy try many number and sketch) , i have used another arduino connected whit serial on D2 AND D3 and used this sketch(in this way the distance of the pc is not a problem anymore)


#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only (?)
}
// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
}

void loop() // run over and over
{

if (Serial.available()>0){

int IncomingByte = Serial.read();
Serial.flush();
mySerial.write(IncomingByte); // transmit BYTE to other arduino
delay(300);
Serial.flush();

}
if (mySerial.available()){
int myByte = mySerial.read();
mySerial.flush();
///// MY TROUBLE i try whit all serial(n,BIN) println(n),
/////// whit all number 1234..8..64..128... 48,49.... ecc ecc
Serial.print((char)myByte); /// NOT ONLY ONE camera is TRIG see my post

delay(200); //??
Serial.print((char)0); reset alarm to blue iris same that Serial.print(0);
}}

****************
in the pc that you connect the monitor you put a similar scketch and reverse the wire on D2 AND D3 (+ ground between 2 arduinos; ask me if you need help)

Maybe many people waiting DIO out from blue iris whit manual trig alert, but not work in this way, you mast use motion or other trig, for receive output from blue iris.

My problem is to trig. just one camera only.

You don't have this problem? Can you trig just one camera?
 
Last edited by a moderator:
Top