real world interface for ZM
real world interface for ZM
Is there any interest in ZM community in device that would interface real world (switches, pir sensors etc) to ZM? I am toying with an idea to build simple box that could react to external events (switch turned on/off, pir sensor activated etc) and send event notification to ZM over usb/serial and could as well be configured to switch something on or off depending on alarm state of specific monitor (turn on extra lights on event etc)
if common sense is so uncommon, why is it called common then?
-
- Posts: 5111
- Joined: Wed Jun 08, 2005 8:07 pm
- Location: Midlands UK
yes most definetly, what you thinking.... either of you lol
James Wilson
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
I haven't done much (ok, any) real hardware hacking since I made my own RS-232 cable out of separate wires 20 years ago, but from what I've seen a parallell port is often a good way to control things.
Also, check out what your cameras support. The axis cameras I use all have extra pins in the back for input & output, so a door opening could send it an event, and you could have it turn on a light. Varying models have varying amounts of ins/outs, but I'd check with your camera specs and see if they have anything similar. It'd be easier to wire, also, as you'd only need to wire whatever you were controlling/sensing from the camera to whererver it was going, instead of having everything have to wire back to the zoneminder box.
One of these days I'll have the time to do some stuff like that, and I'm already excited by it. I got some laser motion sensors with outputs a few weeks ago, and they're fun to play with. Mine, unfortunately, are just going to be controlling a stoplight at the top of a slide, so we know when the path's clear, but it's still fun. If we ever stick a camera up there (the slide's on the roof, which isn't opening until next year, and requires outdoor housing, I can have the outputs on the lasers also tell a nearby camera to tell zoneminder to start recording, with a decent buffer size, so it can record everyone's slide start to finish.
Also, check out what your cameras support. The axis cameras I use all have extra pins in the back for input & output, so a door opening could send it an event, and you could have it turn on a light. Varying models have varying amounts of ins/outs, but I'd check with your camera specs and see if they have anything similar. It'd be easier to wire, also, as you'd only need to wire whatever you were controlling/sensing from the camera to whererver it was going, instead of having everything have to wire back to the zoneminder box.
One of these days I'll have the time to do some stuff like that, and I'm already excited by it. I got some laser motion sensors with outputs a few weeks ago, and they're fun to play with. Mine, unfortunately, are just going to be controlling a stoplight at the top of a slide, so we know when the path's clear, but it's still fun. If we ever stick a camera up there (the slide's on the roof, which isn't opening until next year, and requires outdoor housing, I can have the outputs on the lasers also tell a nearby camera to tell zoneminder to start recording, with a decent buffer size, so it can record everyone's slide start to finish.
Digital data acquisition
I've thought about this too.
Anyone here worked with an Arduino board? It can read digital inputs (and flip digital outputs, which would be kinda cool to have also, for turning on/off lights, sensors,...)
I've just started myself for a future, not-well-defined-yet project. Maybe this is a good app for it.
http://www.arduino.cc/
Anyone here worked with an Arduino board? It can read digital inputs (and flip digital outputs, which would be kinda cool to have also, for turning on/off lights, sensors,...)
I've just started myself for a future, not-well-defined-yet project. Maybe this is a good app for it.
http://www.arduino.cc/
did it
The script work with this board:
http://www.progetti-hw-sw.it/relays_ethernet_board.htm and react with a motion detection.
here's the script put it ina file call it motion.pl and run on a shell sudo per motion.pl
-------------------------------------------
Ecco lo script
-------------------------------------------
#!/usr/bin/perl -w
use strict;
use ZoneMinder;
use LWP::Simple;
$| = 1;
zmDbgInit( "myscript", level=>0, to_log=>0, to_syslog=>0, to_term=>1 );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $sql = "select M.*, max(E.Id) as LastEventId from Monitors as M left join Events as E on M.Id = E.MonitorId where M.Function != 'None' group by (M.Id)"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or die( "Can't execute '$sql': ".$sth->errstr() ); my @monitors; while ( my $monitor = $sth->fetchrow_hashref() ) {
push( @monitors, $monitor );
}
while( 1 )
{
foreach my $monitor ( @monitors )
{
next if ( !zmMemVerify( $monitor ) );
if ( my $last_event_id = zmHasAlarmed( $monitor, $monitor->{LastEventId} ) )
{
$monitor->{LastEventId} = $last_event_id;
print( "Monitor ".$monitor->{Name}." has alarmed\n" );
my $url='http://your-ip-adress/forms.htm?led0=1';
my $content = get $url;
print $content;
}
}
sleep( 1 );
}
---------------------------------------
replace my $url, near the end with your board ip
enjoy
http://www.progetti-hw-sw.it/relays_ethernet_board.htm and react with a motion detection.
here's the script put it ina file call it motion.pl and run on a shell sudo per motion.pl
-------------------------------------------
Ecco lo script
-------------------------------------------
#!/usr/bin/perl -w
use strict;
use ZoneMinder;
use LWP::Simple;
$| = 1;
zmDbgInit( "myscript", level=>0, to_log=>0, to_syslog=>0, to_term=>1 );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $sql = "select M.*, max(E.Id) as LastEventId from Monitors as M left join Events as E on M.Id = E.MonitorId where M.Function != 'None' group by (M.Id)"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or die( "Can't execute '$sql': ".$sth->errstr() ); my @monitors; while ( my $monitor = $sth->fetchrow_hashref() ) {
push( @monitors, $monitor );
}
while( 1 )
{
foreach my $monitor ( @monitors )
{
next if ( !zmMemVerify( $monitor ) );
if ( my $last_event_id = zmHasAlarmed( $monitor, $monitor->{LastEventId} ) )
{
$monitor->{LastEventId} = $last_event_id;
print( "Monitor ".$monitor->{Name}." has alarmed\n" );
my $url='http://your-ip-adress/forms.htm?led0=1';
my $content = get $url;
print $content;
}
}
sleep( 1 );
}
---------------------------------------
replace my $url, near the end with your board ip
enjoy