real world interface for ZM

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
W.
Posts: 108
Joined: Tue Apr 10, 2007 5:06 pm
Location: Latvia

real world interface for ZM

Post 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)
if common sense is so uncommon, why is it called common then?
foreverg
Posts: 25
Joined: Fri Jul 04, 2008 4:16 pm

Post by foreverg »

I'm just working on this.. :)
jameswilson
Posts: 5111
Joined: Wed Jun 08, 2005 8:07 pm
Location: Midlands UK

Post by jameswilson »

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
coke
Posts: 518
Joined: Wed Jan 30, 2008 5:53 pm
Location: St. Louis, MO, USA

Post 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.
billn77
Posts: 15
Joined: Mon Dec 08, 2008 12:09 am

Digital data acquisition

Post 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/
ilios
Posts: 20
Joined: Sun Jun 20, 2010 5:28 pm

did it

Post 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 :)
Post Reply