Page 1 of 1
real world interface for ZM
Posted: Wed Sep 10, 2008 2:23 pm
by W.
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)
Posted: Thu Sep 11, 2008 7:30 pm
by foreverg
I'm just working on this..
Posted: Thu Sep 11, 2008 9:11 pm
by jameswilson
yes most definetly, what you thinking.... either of you lol
Posted: Fri Sep 12, 2008 7:51 am
by coke
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.
Digital data acquisition
Posted: Sat Feb 28, 2009 12:45 am
by billn77
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/
did it
Posted: Thu Jul 15, 2010 10:52 am
by ilios
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