DIO Questions / Support

okubricko

n3wb
Joined
Sep 20, 2017
Messages
7
Reaction score
5
I'm not having any luck trying to read BI output when and alarm is triggered. I'm trying to use the GE electronics protocol using the program in the following thread.

ARDUINO & BLUE IRIS SERIAL digital i/o DIO

But, I don't know if the Arduino is actually seeing any output. The COM ports are configured correctly to match with a baud of 9600. Arduino is connected to PC through a USB cable. I can access the Arduino through the Arduino software so I know it's communicating.

So basically, what I would like help with is writing a basic sketch that captures the output of BI and displays it in the Serial Monitor.

void setup(){
Serial.begin(9600);
int Byte1; // incomming data value "S" will be read into this variable:
int Byte2; // incomming data value "0","1","2" or "3" will be read into this variable:
int Byte3; // incomming data value "0" or "1" will be read into this variable:
}
void loop(){
Serial.println(Byte1);
Serial.println(Byte2);
Serial.println(Byte3);
}

I know that sketch isn't complete by any means, but I'm just looking for something for testing.

Also, is there any guidance on the other option of Arduino Single Byte I/O?

Thanks.
 

Craig0101

n3wb
Joined
Jul 2, 2017
Messages
2
Reaction score
0
Did you find a solution? I can get the code to work when one DIO input is assigned. When multiple DIO inputs are assigned two or more cameras are triggered when only one should be triggered. Seems issue is that specs for timing & what is transmitted via serial have changed for newer versions of BI? Be sure to reboot pc after Arduino is connected to get BI to recognize it.
This is the code I'm using:


#include <elapsedMillis.h>
#define Debug

//elapse time
elapsedMillis timeElapsed; //declare global if you don't want it reset every time loop runs
unsigned int interval = 500; // delay in milliseconds

void DioInTransmitStatus(); //DIO input transmit status function prototype

//Set off & on with pull up resistors
#define ON 0
#define OFF 1
#define SIGNAL 0
#define MOTION 0

//pins
#define cam1_pin 10
#define cam2_pin 11
#define cam3_pin 12

//Serial port definition
//
#ifdef Debug
#define SERIALBAUDRATE 115200 //Serial baud rate at 115200 if in debug mode
#else
#define SERIALBAUDRATE 9600 //Serial baud rate at 9600 if not in release mode
#endif

byte DIOStatus; //DIO input status buffer with bit3 assigned to DIO input status 4 down to bit0 DIO input status 1
byte next_DIOStatus = 0;
byte saved_DIOStatus = 0;

bool saved_cam1 = 1;
bool saved_cam2 = 1;
bool saved_cam3 = 1;

bool DIO1;
bool DIO2;
bool DIO3;

void setup()
{
//Initialize all input pins
pinMode(cam1_pin, INPUT_PULLUP);
pinMode(cam2_pin, INPUT_PULLUP);
pinMode(cam3_pin, INPUT_PULLUP);

//Initialize serial communication and receive buffer
//
Serial.begin(SERIALBAUDRATE);
}

void loop()
{
//set output to default
DIO1=OFF;
DIO2=OFF;
DIO3=OFF;

//check inputs
bool cam1_state = digitalRead(cam1_pin);
bool cam2_state = digitalRead(cam2_pin);
bool cam3_state = digitalRead(cam3_pin);


if( (cam1_state == MOTION) && (saved_cam1_state != cam1_state) ){DIO1= ON;}
if( (cam1_state == MOTION) && (saved_cam2_state != cam2_state) ){DIO2= ON;}
if( (cam1_state == MOTION) && (saved_cam3_state != cam3_state) ){DIO3= ON;}


//Transmit DIO Status
DIOStatus = 0;
if( (DIO1==OFF) && (DIO2==OFF) && (DIO3==OFF) ){DIOStatus = 0;}
if( (DIO1==ON) && (DIO2==OFF) && (DIO3==OFF) ){DIOStatus = 1;}
if( (DIO1==OFF) && (DIO2==ON) && (DIO3==OFF) ){DIOStatus = 2;}
if( (DIO1==ON) && (DIO2==ON) && (DIO3==OFF) ){DIOStatus = 3;}
if( (DIO1==OFF) && (DIO2==OFF) && (DIO3==ON) ){DIOStatus = 4;}
if( (DIO1==ON) && (DIO2==OFF) && (DIO3==ON) ){DIOStatus = 5;}
if( (DIO1==OFF) && (DIO2==ON) && (DIO3==ON) ){DIOStatus = 6;}
if( (DIO1==ON) && (DIO2==ON) && (DIO3==ON) ){DIOStatus = 7;}


if( ((DIO1==ON) || (DIO2==ON) || (DIO3==ON)) && (timeElapsed < interval) )
{
next_DIOStatus = DIOStatus;
}


if( (next_DIOStatus != 0) && (timeElapsed > interval) )
{
DIOStatus = saved_DIOStatus;
DioInTransmitStatus();
next_DIOStatus = 0;
timeElapsed = 0; // reset the counter to 0 so the counting starts over...
}


if( (next_DIOStatus == 0) && (timeElapsed > interval) )
{
DioInTransmitStatus();
timeElapsed = 0; // reset the counter to 0 so the counting starts over...
}



//save input states to compare for change later
saved_cam1_state = cam1_state;
saved_cam2_state = cam2_state;
saved_cam3_state = cam3_state;

saved_DIOStatus = DIOStatus;
}


//Transmit DIO input status on serial port after a DIO input status change detected or at the end of DIO input status retransmission delay
void DioInTransmitStatus()
{
#ifdef Debug
Serial.print(DIOStatus, HEX); //Print DIO input status to serial port if in debug mode
delay(10);
Serial.print(13, HEX); //Print DIO input status to serial port if in debug mode
#else
Serial.write(DIOStatus); //Send DIO input status to serial port if in release mode
delay(10);
Serial.write(13); //Send DIO input status to serial port if in release mode
#endif
}
 

okubricko

n3wb
Joined
Sep 20, 2017
Messages
7
Reaction score
5
Craig0101, I stopped pursuing using an Arduino as a trigger and went with a different solution. >>>See this thread>>> Blue Iris and IFTTT

Overall I decided it would be more difficult trying to wire outlets from a relay driven by the Arduino then adding a Philips Hue bulb and using IFTTT.

The problem I had was that i could never verify that the Arduino was receiving a DIO signal. I may get back to this during my Thanksgiving time off, I still may want to drive something else in the future. Thanks for the code to review.
 
Top