Arduino & Blue Iris Integration

Kevern

n3wb
Joined
Jun 27, 2015
Messages
28
Reaction score
12
Blue Iris and IOT ( Internet of things)

Hi All.

After a few months of work I have finally put together a www.iiot.co.za website containing all promised below.

Having also sent Ken an email about enabling Blue Iris for MQTT to aid development in the IOT and home automation space I have in the interim kicked off a Email 2 MQTT gateway product.
The product will allow alerts sent by general email clients and Blue Iris software to be published to MQTT topics for further execution by IOT devices and applications.

There are also many other solutions for IOT and home automation on the website.
Please see this solution and more here http://www.iiot.co.za

email2mqtt_Arduinor3_mqtt_cover.png
eBook: How to setup Email to MQTT gateway with Arduino UNO R3

For all of you who register from IPCAMTalk please apply a discount code of IPCAM to your carts on checkout for a 20% discount on all products (if purchasing anything.)
This coupon is valid for March 2016.

Thank you all, chat soon.

-------------------
Hi Everyone.

Firstly a big thank you to IP CamTalk for having such a rich and open platform, ... thanks you guys are amazing!

OK, in my last "FreeBee" post far below I hinted that I was working on a new wireless solution......................

Further below you will find my "FreeBee" post on integrating Arduino and Blue Iris, If you want to plug a Arduino in with a Serial cable, well that's good and fine but for some of you, you will rather want to integrate Blue Iris with limitless cross-functional IOT (Internet of things).
So.. I have started a new post called Blue IRIS and the IOT ( Internet of things), again donations are welcome to keep up the R&D and you are welcome to PM me on iot1@kldtechnologies.co.za with subject BI-IOT if you are interested in purchasing detailed document ($10 for +- 60 pages) practical real-world working code, professionally laid out PCB build, how to's for setting up Arduino UNO, Ethernet Shield, OpenHAB, MQTT and the wireless IOT chips the ESP8266-01 and ESP8266-12 (Firmware, locked loops, coding etc.)
For those of you who purchase the documentation will be able to download all code and reference material.

O.K, so let's get started.
We are NOT going to connect Blue Iris alerts via a serial cable to an Arduino anymore but we will still be using the following components.

for ..BLUE IRIS BITS:
Arduino UNO
W5100 series Ethernet Shield

for..IOT BITS:
OpenHAB
MQTT Mosquitto
Ubuntu Server
ESP8266-12

In this post I will cover the general concept of what we are doing and stop at the point after the Arduino with Ethernet Shield setups.

CONCEPT:
Blue Iris Camera Alerts are setup to send and alert email to a POP mail server with a specific subject (this is not your Arduino), you can setup these in you BI software on the fly.
The Arduino is powered on and connected to the network constantly checking for emails.
The Arduino has an attached Ethernet Shield Board and the Arduino is setup to retrieve the email and publish a message to a MQTT broker(the MQTT could be your own or something like thingspeak etc.).

The IOT bit....
The MQTT broker service in turn updates OpenHAB and controls the GPIO pins on the ESP8266-12.(7 switchable GPIO's per ESP-12, unlimited ESP-12's)
Basically if you can switch a GPIO/LED either ON/OFF or PULSE (ON then OFF) then you can integrate it into anything you like.

So here is a demonstration of this in action using OpenHAB, however as Blue Iris emails are converted to MQTT messages the alerts from BLue IRIS will have the same effect as me switching on and off the LED's using OpenHAB as I did in the video.
Please note I have thoroughly tested the working EMAIL -> MQTT conversion.
Additionally any MQTT client or application be it Linux, Windows, or Mobile devices IOS, Android of WindowsMobile that has an app that can publish to a MQTT broker service will also be able to control your devices.... no absolute dependency on Openhab!!!
You can also run a small MQTT broker service on your Windows PC.


A lot of thought time and coding went into this project and I will gladly share all I have for a donation, I have displayed the technical abilities in my first "freebee" post so here is the link below and if you would like to get all my designs, builds and working code for all components please donate and PM me on iot1@kldtechnologies.co.za.

Additionally, I would ask that Blue Iris consider adding MQTT subscription capability to the software set which will further enhance its capability.
Ken, any thoughts or insights from your side?

Bye for now.

----------------------------------------------------------------- Older "FreeBee" Post --------------------------------------------------------------------------
Hello.

Before we begin it is important to note that all pictures, links, attachments and videos may not be visible in this post if you are not logged in.

Most posts are aimed at asking question but this post is aimed at contributing some successful R&D and helping users to integrate Arduino with Blue Iris outputs.

The post also describes the connection and integration of an Arduino UNO R3 to Blue Iris ver 4.0.9.xx which will enable the DIO output control found in the latest Blue Iris mobile application to control or operate mechanical output relays.
Additionally it will cover how to set per camera digital output bit's also enabling the control of mechanical relays from alert events on cameras, whether triggered through motion or manually on the camera video/dialog screen.

The post includes the working and tested Arduino sketches as well as project simulation sketches that can be used in virtual bread board for Arduino (VBB4 Arduino), available as attachments further below.
The code was also tested on a fail safe basis, in other words if you have a power failure or you connect your Arduino you do not want things switching on and off.

This post will be followed by more posts covering the DIO input aspects to activate cameras using PIR/Sensor/etc. from the Arduino itself and culminate in further posts outlining the IoT development where wireless ESP and Xbee distributed IO will be possible.
The use of Arduino, a simple conversion circuit and a standard off the shelf opto isolated relay board works out at around 1/3 the price of a Open Sealevel SeaDAC device and can provide more flexibility and function, I am sure that the SeaDAC devices add a lot of convenience and simplicity but were a little pricey for my pocket.

A lot of work went into developing the material covered in this post possibly saving you money in having to buy more shrink wrapped solutions and any donations would be welcome to assist me in further R&D.

The Architectural and design Diagram.
Arduino & Blue Iris Integration

Please note the "GCE Electronics" Protocol under "Serial Port" for "Digital I/O" was used within "Blue Iris Options" for the development below.





The Arduino UNO R3 working sketch: attachment "BlueIris_v2.0.txt" , just rename the extension to .ino



The Arduino UNO R3 working project: attachment "BlueIris_v2.0.zip.txt", just remove the .txt and import it into Virtual Bread Board for Arduino, VBB4Adruino Simulator can be found here:


Version Notes and General Comments:

On Blue Iris versions 4.0.3.1 the Alert(output) to serial , set in bits 1,2,3,4,5,6,7,8 produce a ASCII output of S01,S11,S21,S31,S41,S51,S61,S71 for ON and for OFF the corresponding, S00, S10, S20,S30,S40,S50, S60,S70
so the serial read if loop should read in the first three bytes, then process. "if (Serial.available() > 2) {}"

In Blue Iris versions 4.0.9.x, the outputs for DIO Trigger Output and Alerts trigger output changed, the full map is in my posted code.
essentially Alert bit's 16, 32, 64, 128 produce an corresponding ASCII output to serial of S41,S51,S61,S71 for ON and correspondingly S40,S50,S60, S70 for OFF.
The DIO output triggers in the app generate S01,S11,S21,S31 for ON and correspondingly a S00,S10,S20, S30 for OFF.

I have written my serial.read Arduino code to look at three bytes " > 2", but if you want to do some other funky stuff I suggest you run a serial port monitor, observe the serial outputs from Blue Iris and then write your code to suit.
Any decent serial port monitor will do, in my case I found Eltima Serial port monitor to be quite useful, you can find them here:
I also found the serial port drivers bundled in the Arduino IDE (Integrated Development Environment) to work fine for the serial port monitor and the Blue Iris application, you can download the Arduino IDE here:

I have also made two small demonstration videos available on you tube if you would like to see it all in action.

Video 01: TheSetup - This small video shows the setup of the 8 relayboard connected via intermediate PCB circuit to Arduino Uno R3


Video 02: TestingAlertThenDIOOutput - This small video demonstrates the Arduino code in action with Blue Iris, here we first setup the alerts with 16,32,64,128 bits and trigger an alert manually for each setting thus operating relays 5-6 each at a time demonstrating each relay in succession switching with each setting, then the video demonstrates the switching of relays 1-4 using the Blue Iris IOS app on a Apple iPad air, and then the video finales with the alert being triggered from the camera view on the iPad.
The activating and deactivating mechanical relays are visible by the red LED's on the 8 Relay module in the top right of the video.


I do apologise for the quality of the video but it is the best I can do with the video kit I have at my disposal.



If you have found this useful and would like to donate to further my R&D posts please do so on the donate button below (Any amount would be most appreciated)

18-07-2015

A 2 Channel Relay Board Shield can be plugged directly into the Arduino UNO, serial.write data S61, S71 for ON and S60,S70 for OFF from my downloadable code work right out of the box with the two relays, see picture below.

Not advertising for the company, but if you want the spec, you can find it here.http://www.dx.com/p/2-channel-relay-shield-module-for-arduino-w-xbee-btbee-interface-141544#.VaoASGYaLIU
No need for external power supply, just the serial cable connected to the Arduino UNO is sufficient to power the relays.


 

Attachments

Last edited by a moderator:

KC8DKT

Getting the hang of it
Joined
Jul 5, 2015
Messages
80
Reaction score
70
Location
Moundsville, WV
Thanks for all the work

I have a Propeller pic board that is connected to my PCs usb for power with a set of supper caps to run the board for about 5 to 7 min with out usb power.
It is connected to the PCs PowerSwitch / ResetSwitch / HDDLed / PowerLed.

The board would wait a set interval for the HDDLed (before arduino/io was added to BI) to change state an if not assume BI or the PC locked-up/crashed.

It would try and do a graceful windows shutdown (1sec pwr switch) incase it was a BI crash.
If the power led did not go out after 1min it would assume the PC was locked-up and hold the power switch till the power led was off.
After 5sec it would 1sec PwrSwitch to power the pc back on.

Looking at your code I think I could get my Prop (PBasic) coded to work wih BIs arduino option.

With your code I am hoping to get a Ping/Pong going to check for BI crash instead of the HDD Led checking system I use now.

Thanks again for the example code. Who knows what options I will be adding next. Hope to see ALOT more ideas from other users in this thread!

(sry about the English spelling)
 

Kevern

n3wb
Joined
Jun 27, 2015
Messages
28
Reaction score
12
You are welcome.

yes, you can setup a "ping/pong" by sending BI a suitably timed serial.write which is set in BI as an input bit to trigger an alert and the resulting alert set with a alert bit as a BI alert serial.write response to your Arduino code.
the Arduino can then, based on the results in turn control your PC's PowerSwitch / Reset Switch.
Complimenting your existing Propeller PIC board or even simplifying your setup by replacing it.

I am also waiting to see the interest in this thread as I am building a IOT wireless version of my initial post to extend a redundant automation system using both ESP and Xbee/Zbee versions.
I am sure Ken will consider Ethernet code additions and extensions to compliment the serial connection if there is enough demand following the next iteration above.

Regards,
Kevern


Thanks for all the work

I have a Propeller pic board that is connected to my PCs usb for power with a set of supper caps to run the board for about 5 to 7 min with out usb power.
It is connected to the PCs PowerSwitch / ResetSwitch / HDDLed / PowerLed.

The board would wait a set interval for the HDDLed (before arduino/io was added to BI) to change state an if not assume BI or the PC locked-up/crashed.

It would try and do a graceful windows shutdown (1sec pwr switch) incase it was a BI crash.
If the power led did not go out after 1min it would assume the PC was locked-up and hold the power switch till the power led was off.
After 5sec it would 1sec PwrSwitch to power the pc back on.

Looking at your code I think I could get my Prop (PBasic) coded to work wih BIs arduino option.

With your code I am hoping to get a Ping/Pong going to check for BI crash instead of the HDD Led checking system I use now.

Thanks again for the example code. Who knows what options I will be adding next. Hope to see ALOT more ideas from other users in this thread!

(sry about the English spelling)
 
Last edited by a moderator:

Kevern

n3wb
Joined
Jun 27, 2015
Messages
28
Reaction score
12
Updated - 2 Channel Relay Board Shield added - 18-07-2015
 

dolby

n3wb
Joined
Sep 18, 2015
Messages
2
Reaction score
4
Hi, I done few changes to the posted original firmware forthe Arduino (attached zip file). I have 4 DIO outputs that can be trigged fromthe Blue Iris motion detection and 4 DIO inputs that can be driven externallyto trigger the camera motion detection (attached PDF schematic). The onboardLED acts as a heartbeat vital LED. Few timings were added through the use oftimer one interrupts, receive buffer and the index will be cleared if there is morethan five seconds occurs between two bytes on received command. This resynchronizeto insure correct reception from the Blue Iris on the next transmitted command.The four zone inputs are scanned and debounced for 500 mSec, status is sent to the Blue Iris each times a status froman input change occurs. The zone inputs status is also automatically sent every 20 seconds. Regards.
 

Attachments

Joined
Mar 9, 2015
Messages
12
Reaction score
0
Kevern, can you post a higher-res version of the integration diagram JPG? I'm having trouble reading the text. Also, the video links seem to be broken. Can you repost?

Thanks,
-R
 

lotusandy7

n3wb
Joined
Nov 13, 2015
Messages
7
Reaction score
1
Dolby,

Thanks for the Arduino code, I have installed it on a UNO and it's working great, however there seem to be an issue when trying to use the BI app to control the UNOs digital outputs.
I can switch them all on for 5 secs with the Trigger buttons, and the Force buttons work, but only to switch them off, the force buttons don't switch the DIOs off again?
I have sniffed the serial data stream & it looks like BI sends for e.g. "S01" for force on & then also "S01" for force off when it should send "S00" as the trigger buttons correctly do.
Have you tried this on your setup? looks like a BI issues to me

Many thanks Andy
 

KC8DKT

Getting the hang of it
Joined
Jul 5, 2015
Messages
80
Reaction score
70
Location
Moundsville, WV
Ello all, asked Ken to check into an Ethernet "IP" connection for the arduino tab. I am using the Propeller so I have limited info I can give him on this. If you have any Arduino with Ethernet info please post here and why you think it would be a Good or Bad idea adding it to BI please.


I use a USB cable with ZigBees now but some of my projects are long range and I would like to see an Ethernet option. I got a setup now that's getting its power from my POE switch and acts as a switch so my DogDoor Cam and RF-sensor works (shows up on the network with an IP DIO-IP "Door-Lock and RF-sensor", Cam-IP) and powers over the same Ethernet cable. For now I can only use telnet or a web browser to watch the serial data working but this seems to be working and would only need an IP option for BI to find it. This could lead to multiple DIO units I hope. The ZigBee was just too flakey for this project.


(sry about the English)
 

RCflyer

n3wb
Joined
Dec 8, 2016
Messages
1
Reaction score
0
Dolby,
Thank you for posting your code. This was my first experience with Arduino, and I'd never have been successful without it. I modified the code to run on a UNO R3 clone (Elegoo Board), using a Velleman VMA05 shield for the I/O card. This shield has 6 inputs and 6 outputs. Also some analog inputs that are currently unused. The code was modified to use all 6 I/O ins and outs. It took me a while to realize that Blue Iris accessed them as 1,2,4,8,16, etc. as opposed to 1,2,3,4..... The inputs were set up as pull to ground for true. If anyone wants high inputs, use pulldown resistors on the inputs, and take the ! out of this statement in the code. "if (! digitalRead (myIndex + DIOIN1)) //Read input status and test if it is in normal condition ?"

Again - Thank You to Dolby for the original code!! This was a perfect/inexpensive solution for me. Less than $50 total on Amazon.
 

Attachments

dolby

n3wb
Joined
Sep 18, 2015
Messages
2
Reaction score
4
Dolby,
Thank you for posting your code. This was my first experience with Arduino, and I'd never have been successful without it. I modified the code to run on a UNO R3 clone (Elegoo Board), using a Velleman VMA05 shield for the I/O card. This shield has 6 inputs and 6 outputs. Also some analog inputs that are currently unused. The code was modified to use all 6 I/O ins and outs. It took me a while to realize that Blue Iris accessed them as 1,2,4,8,16, etc. as opposed to 1,2,3,4..... The inputs were set up as pull to ground for true. If anyone wants high inputs, use pulldown resistors on the inputs, and take the ! out of this statement in the code. "if (! digitalRead (myIndex + DIOIN1)) //Read input status and test if it is in normal condition ?"

Again - Thank You to Dolby for the original code!! This was a perfect/inexpensive solution for me. Less than $50 total on Amazon.
It's a pleasure.
 

kiwibird

n3wb
Joined
Dec 21, 2016
Messages
26
Reaction score
2
How do I get a arduino to trigger a bi camera? There is an option for a com port, but no baud rate specified.
Does anyone have sample arduino code?
 
Top