My application is for a trip wire to make a digital input go high, then send a GET (I think this is what it is but really not so sure about this) request to Blue Iris on my PC that triggers a camera to record. Bonus of doing it this way is I also believe I will also be able to talk to tasker in the same manner (on a separate android box) to turn lights on etc.
I have seen post around but they are either using the serial trigger, or using IOT, or sending commands/triggers each way which complicates things over what I require..
I should note I am using just a Nodemcu for this task, where I used an arduino/esp8266 combo for my last project.
I really don't understand much depth in what I am trying to do, so the following code could be completely wrong.
I used another example of where they were using an ethernet shield and communicating both ways, but I copied (and modified) the components I thought where relevant to triggering motion on my camera's when a digital input goes high.
I believe the command to send to the Blue Iris server is (and is what the function at the end of my code does, but with more details ??required??)
http://110.146.%%%.%%:818/admin?camera=Car&trigger&user=admin&pw=password
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Social networks: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example runs directly on NodeMCU.
Note: This requires ESP8266 support package:
https://github.com/esp8266/Arduino
Please be sure to select the right NodeMCU module
in the Tools -> Board menu!
For advanced settings please follow ESP examples :
- ESP8266_Standalone_Manual_IP.ino
- ESP8266_Standalone_SmartConfig.ino
- ESP8266_Standalone_SSL.ino
Change WiFi ssid, pass, and Blynk auth token to run :)
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
int sideGate = 0;
int drivewayGate = 0;
int triggerDrivewayGate = 0;
int triggerSideGate = 0;
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "###";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "###";
char pass[] = "###";
// BlueIris
WiFiClient client;
char BIserver[] = "###.###.###.###"; // IP Adres of Blue Iris Server. // CHANGE THIS
char user[] = "###"; //Username for Blue Iris Server // CHANGE THIS
char pass2[] = "###"; //Password for Blue Iris Server // CHANGE THIS
String stringOne = "camera";
void setup()
{
// Debug console
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
// digitial pin states
pinMode(5, INPUT); // box led switch
pinMode(4, INPUT); // onboard led switch
}
void loop()
{
Blynk.run();
//read digital switch pins
sideGate = digitalRead(5); // read push button switch
drivewayGate = digitalRead(4); // read pedal switch
if (sideGate == 1)
{
if (triggerSideGate == 0) // stops multiple triggers while high
{
Blynk.email("#######", "Side Gate triggered", " ");
triggerSideGate = 1;
stringOne = "Car"; //"Cam1" = Short camera name in blue iris
triggerBI();
}
}
else
{
triggerSideGate = 0;
}
if (drivewayGate == 1)
{
if (triggerDrivewayGate == 0)
{
Blynk.email("####", "Driveway Gate triggered", " ");
triggerDrivewayGate = 1;
stringOne = "BackPatio"; //"Cam1" = Short camera name in blue iris, this will be triggered if digital input 2 is high // CHANGE THIS
triggerBI();
}
}
else
{
triggerDrivewayGate = 0;
}
}
void triggerBI() { // sending the trigger to Blue Iris web-server
WiFiClient client;
if (client.connect(BIserver, 818)) { // (81) Port number of the Blue Iris web server //CHANGE THIS if you don't use port 81.
// Make a HTTP request:
client.print( "GET /admin?camera=");
client.print(stringOne);
client.print( "&trigger&user=");
client.print( user);
client.print( "&pw=");
client.print( pass2);
client.println( " HTTP/1.1");
client.print( "Host: " );
client.println(BIserver);
client.println( "Connection: close" );
client.println();
client.println();
client.stop();
}
}