IOT Interface Box, How to connect contacts to BI using an Arduino

eeeeees

Young grasshopper
Joined
Jan 14, 2016
Messages
62
Reaction score
19
Attached is an article on how to connect external devices to and from Blue Iris.

This project is an IOT Box. It will allow BlueIris to control things that may be connected to its relay contacts and respond to contact closures on things like motion sensors. The IOT Box communicates with BI using Ethernet. Central to the Box is an Arduino UNO with an Ethernet shield. The Arduino sketch which determines the personality of the box was contributed by Mattis. The IOT box communicates with BI using command strings rather than using the Digital I/O TAB specified COM port, the same technique that BI utilizes to talk with IP cameras.
View attachment IOT Box.pdf
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
props, nice lil project.. I especially like that housing you found, very slick.

do you have to poll blueiris to get updates or is BI able to trigger your IOT box instantly? Simply curious, I am not a BI user..
 

eeeeees

Young grasshopper
Joined
Jan 14, 2016
Messages
62
Reaction score
19
Hello nayr
Thanks for housing props. In a previous life it was a binary delay line (4 chunks of coax). Wish I had a few more.
No poling used. BI talks and relays move. Contacts close and BI does something useful, like start recording.
I'm looking at your project and sig. Do you do C++ and maybe dotnet? You seem to have time on your hands, I could help.
Eric
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
I can do alot of languages, including of course C++.. but I have never touched dotnet, Ive been out of the Win32 realm for 18 years now. about a year ago I decided to give NodeJS a good vetting and came out so impressed its been my go to language ever since.. I am really fond of how easy it is to thread tasks async and how damn easy it is to trace/debug with some really cool tools that let you edit the code in realtime.

I guess time is a relative thing heh, I have more projects than I have time if thats the question hah, I think it would be really damn cool if you guys could convince the guy who does BI to add a MQTT Module so your NVR becomes an IoT device.. I think Domoticz and BlueIris would work very well together, it does run on windows.
 
Joined
Feb 26, 2016
Messages
23
Reaction score
0
cool,
can you just left the arduino conneted to the server via a usb, is your input.output connection of your box goes to the paralleled port ?

Can you program an arduino to disable a group of camera when the owner is inside home

thank you
 

eeeeees

Young grasshopper
Joined
Jan 14, 2016
Messages
62
Reaction score
19
Hello Filipe
The box has nothing to do with the PC parallel port and the USB port is only used to program the Arduino when the box is initially installed. There after the box monitors four relay contacts and drives two relays based on information sent from/to BI via Ethernet. Actually the information consists of a few ascii characters that can come from anything on the network, its' not just limited to BI.
Eric
 

eeeeees

Young grasshopper
Joined
Jan 14, 2016
Messages
62
Reaction score
19
Hello nayr
Thank you for pointing me to Domoticz. I have been using X-10, since BSR invented it, with a dedicated controller. Since getting started with BI & IP cams I decided that a 24-7 PC wouldn't be so bad and its a good place to put HA stuff and not tie up the work stations.

I checked out your HA project and my eye was drawn to the sprinkler controller. Kinda heavy duty for my taste but I guess that IT guys really go for heavy metal.
Eric
 
Joined
Feb 26, 2016
Messages
23
Reaction score
0
Thank you ,i have read to fast
it is even better , like this
you can put this everywhere

just ordered the ethernet shield, i do have all the rest, so i will give it a try

why do you have implemented manual trigger of the camera with sen1 sen2 ? like a panic push button ?

thank you
 

eeeeees

Young grasshopper
Joined
Jan 14, 2016
Messages
62
Reaction score
19
Hi Filipe
I just call it a button or contact closure for clarity of what the physical input should look like electrically. In real life I use field disturbance sensors (a form of 5.7 Ghz doppler radar) to sense motion in various areas around my property. They are $10 ebay items and very effective. Most people use video motion from their cameras to initiate recording from cameras but I found this to be problematic at my location. Because of the layout of my neighborhood there are too many auto headlights shining around my house and I end up with a lot of useless video to review.
Eric
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
Completely agree, I run domoticz off a quad core 700Mhz arm system along with tons of other stuff and it sits mostly idle.. so I would not expect it to interfere with BI at all, should run side by side very well as long as BI is not hogging up all the resources.

I have much respect for BI even though I am not a user, I think it would be really awesome to see enough of you guys running BI next to Domoticz that you can convince the BI Devs to start adding some native home automation interfaces, such as publishing BI sensor/stat data or triggering recordings via MQTT so other Automation Systems could talk directly to BI using native protocols.. thats why I asked if you had to poll BI or if you managed to push alerts in both directions.. a Pub/Sub strategy works very well for low latency/instant feedback.

Ive found that IPCameras make excellent PoE automation/sensor nodes if you get em with AlarmIO, and while I dont use video motion to trigger recordings its very nice to use it for automation like turning on lights and stuff.. you can tune them in ways that PIR sensors simply cant... (ie, using facial detection instead of pet immunity.. Ive got a 150lb Pyrenees, he is as big as I am and nothing but facial detection is immune to his presence.)
 
Last edited by a moderator:
Joined
Feb 26, 2016
Messages
23
Reaction score
0
Ok , i do understand , very good to avoid motion , take to much process
i must also tried this...much work to come
not sure i did see the one you talking about in ebay, did found stuff around 30usd
any more info about it
 

eeeeees

Young grasshopper
Joined
Jan 14, 2016
Messages
62
Reaction score
19
Hello Filipe
I have tried many of the motion sensing modules of all types that are available on ebay. Mostly bare boards for a few dollars. This one http://www.ebay.com/itm/DC-12V-24V-5-8GHz-Microwave-Radar-Sensor-Body-Motion-HF-Detector-Light-Switch-/311505633607?hash=item48872ec147:g:r0cAAOSwSHZWcThU is far and away the best for my purposes and is completely packaged for indoor use. Outdoors I mount them in a 1 unit plastic switch box the kind used with PVC conduit. Cheap, unobtrusive and weather tight. I shape the 5 Ghz antenna pattern with aluminum AC tape to get the sensitivity profile that I want for that particular sensor. This stuff goes thru walls and you generally want to avoid that hence the tape.

Eric
 
As an eBay Associate IPCamTalk earns from qualifying purchases.

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
very cool, thanks for sharing that.. I'd love to use something like that but my 5GHz WiFi is far to valuable to put those up around here though... heh.

outdoors I use beam sensors like you find for garage doors.. they can be a bitch to align but once you got it setup its hard to find anything more reliable.. sometimes the optics needs a little shield to protect it from rain/snow.. can easily setup 30ft tripwires with em.
 

eeeeees

Young grasshopper
Joined
Jan 14, 2016
Messages
62
Reaction score
19
Hi N
They don't do much bad to Wifi since they are CW and extremely low power. As in no modulation so I don't think that the modems even see it. My big issue with beams (lotsa professional experience with them) is that for me where ever they are appropriate one end is not suitable (as in my neighbor's yard).
My all time favorite sensors are mats that go under the rug (no big dogs in my life) absolutely reliable UL alarm grade stuff. They go for years and years with no issues, at least until something leaks water.
Eric
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
Ive been thinking about a pressure mat for the front door, glad to hear those work as well as I had hoped.. been leaning towards that instead of a doorbell sensor, then I can get the ppl leaving spam on my handle too :)

I could also determine direction of travel using front door contact: door then mat = headed out.. mat then door = headed in.. that could help my PTZ determine if it should stay looking at the door or not..
 
Joined
Feb 26, 2016
Messages
23
Reaction score
0
in the code it doesn pass the line

if (client.connect(BIserver, 80))
i did try remouve it to forcethe info to be send , but the camera still don t want to triger.....
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
you know you can wrap [ code ] tags around all this, maintain formatting, fixed with fonts and generally make it easier to read and copy?
 
Joined
Feb 26, 2016
Messages
23
Reaction score
0
here is goes

so why the client didn t succes to connect in the server for the the triggerBI function

Serial.print(BlueIrisIN3) = 1
Serial.print(stringOne) = Cam3

then

EthernetClient client;
Serial.print("Alive1") ; OK
if (client.connect(BIserver,80))
{
Serial.print("Alive2 ") ; Here nothing

ps windows firewall/defender off, any iddee

thank you

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xFA, 0xCA, 0xE5, 0x4C, 0xE7, 0xE6 }; // CHANGE THIS

IPAddress ip(192, 168, 1, 157); // IP address, may need to change depending on network
byte subnet[] = { 255, 255, 255, 0 }; // subnet address, may need to change depending on network
EthernetServer server(80); // Port 80 is HTTP port for POST commands from Blue Iris.

char new_state[512];
EthernetClient client;

char BIserver[] = "192.168.1.12"; // IP Adres of Blue Iris Server. // CHANGE THIS
char user[]= "admin";
char pass[]= "VeniseLab";

String stringOne = "Camera";
long prevmill = 0;
long interval = 500; //Time between check for checking Digital Inputs
long prevmill2 = 0;
//long interval2 = 10000; //Time to zero triggers from arduino to Blue Iris, this time will be a form of re-trigger time.
long interval2 = 1000; //Time to zero triggers from arduino to Blue Iris, this time will be a form of re-trigger time.


int DI03 =0;
int BlueIrisIN3=0;
int tmp03 =0;


const int buttonPin = 3; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
int buttonState = 0; // variable for reading the pushbutton status
#define RELAY1 7

void setup()
{

pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(4, OUTPUT);


digitalWrite(4, HIGH); // disable the SD card by switching pin 4 high
Ethernet.begin(mac, ip, subnet); // initialize Ethernet device
server.begin();
Serial.begin(9600); //Used for debuging
pinMode(3, INPUT);
pinMode(7, OUTPUT);
digitalWrite(7, LOW);
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);

pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(RELAY1, OUTPUT);

}

void loop()
{

unsigned long curmil = millis();
if (curmil - prevmill > interval) { //Checking everything every xxx milisecond.
prevmill = curmil;
digital_read();
HTTP_write();
}
unsigned long curmil2 = millis();
if (curmil2 - prevmill2 > interval2) { //Checking everything every xxx milisecond.
prevmill2 = curmil2;
tmp03=0;


}

EthernetClient client = server.available();
if (client) {
while (client.connected()) {
int i = 0;
int head = 1;
int body = 0;
while(client.available()) {
char c = client.read();
if (c == '\n') {
if ( i <= 2 ) {
// an http request ends with a blank line
sendPage(client);
if ( head == 1 ) {
body = 1;
head = 0;
}
}
i = -1;
}
if ( body == 1 ) {
new_state = c;
}
i++;
new_state = '\0';
}
i = 0;
}
writedigital();
}
}

void writedigital(){
if ( strncmp( new_state, "Out07=On", 8) == 0 ) {
digitalWrite(7, HIGH);
}
else if ( strncmp( new_state, "Out07=Off", 9) == 0 ) {
digitalWrite(7,LOW );
}
}

void sendPage(EthernetClient client)
{
client.println("HTTP/1.0 200 OK\Content-Type: text/html\n\n<html>\n<head>");
client.stop();
}

void digital_read() {
int input=0;
input = digitalRead(3);
if (input == LOW) {
DI03 = 0;
}
else {
DI03 = 1;
digitalWrite(ledPin, HIGH);
digitalWrite(RELAY1,HIGH); // Turns ON Relays 1
//delay(100); // Wait 1 seconds
//digitalWrite(RELAY1,LOW); // Turns Relay Off

}

}

void HTTP_write(){
BlueIrisIN3 = DI03;
if (BlueIrisIN3 == 1 && tmp03 == 0) {
// if (BlueIrisIN3 == 1 ) {
stringOne = "Cam3";
Serial.print(BlueIrisIN3)
Serial.print(stringOne)
triggerBI();
tmp03=1;
}
}

EthernetClient client = server.available();
if (client) {
while (client.connected()) {


void triggerBI(){ // sending the trigger to Blue Iris web-server

//EthernetClient client;
EthernetClient client = server.available();



Serial.print("Alive1") ;
if (client.connect(BIserver,80))
{
Serial.print("Alive2 ") ;
client.print( "GET /admin?camera=");
client.print(stringOne);
client.print( "&trigger&user=");
client.print(user);
client.print( "&pw=");
client.print(pass);
client.println( " HTTP/1.1");
client.print( "Host: " );
client.println(BIserver);
client.println( "Connection: close" );
client.println();
client.println();
client.stop();
}
}
 
Top