Blue Iris/Arduino Integration

ALL11

n3wb
Joined
Jul 24, 2022
Messages
1
Reaction score
0
Location
New Zealand
Hi there all. First post here so hopefully it get it right.
Im currently running Blue iris on my home server with 4 cameras and im trying to add a Arduino board (and relay board) so that i can operate some relays with BI. I am fairly new to Arduino programing so am not 100% sure what part of the process is not working. Ideally i would like to be able to control the remote control tap on the App to control these relays. The relays would be for things like a Siren, lights etc.

In BI in the Digital I/O DIO page ive set it to Arduino and COM3 and under control (Execute on input=1 Set= 1,2,4,8 Reset=0). I have also read somewhere that maybe Set needs to be S01,S02,S04,S08 but i briefly tired it and still no luck.

As for the Arduino code ive been looking over old threads and found a couple of bits of code that ive tried to add and adjust to make it work. (code Below)

Any help or tips would be much appreciated as ive been trying for a while now and just cant figure it.


int incByte1,incByte2,incByte3 = 0;
int BlueIrisOUT1,BlueIrisOUT2,BlueIrisOUT4,BlueIrisOUT8 = 0;
int BlueIrisOUT16,BlueIrisOUT32,BlueIrisOUT64,BlueIrisOUT128 = 0;
int ArduinoOUT1,ArduinoOUT2,ArduinoOUT3,ArduinoOUT4 = 0;
int ArduinoOUT5,ArduinoOUT6,ArduinoOUT7,ArduinoOUT8 = 0;
int serialwrote =0;
int input = 0;
long prevmill =0;
long interval = 1000;



void setup() {
Serial.begin(9600);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}



void loop() {
unsigned long curmil = millis();
if (curmil - prevmill > interval) {
prevmill = curmil;
output_logic();
digital_write();

digital_read();
input_logic();
serial_write();

}

serial_read();


}

void output_logic(){
ArduinoOUT1 = BlueIrisOUT1;
ArduinoOUT2 = BlueIrisOUT2;
ArduinoOUT3 = BlueIrisOUT4;
ArduinoOUT4 = BlueIrisOUT8;
ArduinoOUT5 = BlueIrisOUT16;
ArduinoOUT6 = BlueIrisOUT32;
ArduinoOUT7 = BlueIrisOUT64;
ArduinoOUT8 = BlueIrisOUT128;
}




void digital_write() {
if (ArduinoOUT1 == 1) {
digitalWrite(10, HIGH);
}
else {
digitalWrite(10, LOW);
}
if (ArduinoOUT2 == 1) {
digitalWrite(11, HIGH);
}
else {
digitalWrite(11, LOW);
}
if (ArduinoOUT3 == 1) {
digitalWrite(12, HIGH);
}
else {
digitalWrite(12, LOW);
}
if (ArduinoOUT4 == 1) {
digitalWrite(13, HIGH);
}
else {
digitalWrite(13, LOW);
}
}


void serial_read() {
if (Serial.available() > 2) {
incByte1 = Serial.read();
incByte2 = Serial.read();
incByte3 = Serial.read();
if (incByte1 == 'S'){
if (incByte2 == '0' && incByte3 == '1')
BlueIrisOUT1 = 1;
}
if (incByte2 == '0' && incByte3 == '0')
BlueIrisOUT1 = 0;
}

if (incByte2 == '1' && incByte3 == '1') {
BlueIrisOUT2 = 1;
}
if (incByte2 == '1' && incByte3 == '0') {
BlueIrisOUT2 = 0;
}

if (incByte2 == '2' && incByte3 == '1') {
BlueIrisOUT4 = 1;
}
if (incByte2 == '2' && incByte3 == '0') {
BlueIrisOUT4 = 0;
}

if (incByte2 == '3' && incByte3 == '1') {
BlueIrisOUT8 = 1;
}
if (incByte2 == '3' && incByte3 == '0') {
BlueIrisOUT8 = 0;
}

if (incByte2 == '4' && incByte3 == '1') {
BlueIrisOUT16 = 1;
}
if (incByte2 == '4' && incByte3 == '0') {
BlueIrisOUT16 = 0;
}

if (incByte2 == '5' && incByte3 == '1') {
BlueIrisOUT32 = 1;
}
if (incByte2 == '5' && incByte3 == '0') {
BlueIrisOUT32 = 0;
}

if (incByte2 == '6' && incByte3 == '1') {
BlueIrisOUT64 = 1;
}
if (incByte2 == '6' && incByte3 == '0') {
BlueIrisOUT64 = 0;
}

if (incByte2 == '7' && incByte3 == '1') {
BlueIrisOUT128 = 1;
}
if (incByte2 == '7' && incByte3 == '0') {
BlueIrisOUT128 = 0;
}
}
}
}
 
Top