Pages: [1]   Go Down
Author Topic: Zoneminder and arduino  (Read 6388 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear, all

In my home I use a Zoneminder surveillance (linux based security and surveillance opensource system).
I have the necessity to start to recording on some camera in case of external events.... with arduino (+ arduino ethernet) is very simple!
Now I want to share my solution with you.

On Zonemineder:
On ZM is necessary to enable the external trigger; it is possible to start recording on external event using serial comunication, network comunication or file in a folder "comunication" (ZM check for a file in a specific folder); I have chosen the networdk comunication.

1 Enable external trigger:
Edit the file zmtrigger.pl:
Check for the some comunication system row definition and comment the not used (put # at the start of the lines):
[cut]
my @connections;
push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan1", channel=>ZoneMinder::Trigger::Channel::Inet->new( port=>6802 ), mode=>"rw" ) );
#push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan2", channel=>ZoneMinder::Trigger::Channel::Unix->new( path=>ZM_PATH_SOCKS.'/zmtrigger.sock' ), mode=>"rw" ) );
#push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan3", channel=>ZoneMinder::Trigger::Channel::File->new( path=>'/tmp/zmtrigger.out' ), mode=>"w" ) );
#push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan4", channel=>ZoneMinder::Trigger::Channel::Serial->new( path=>'/dev/ttyS0' ), mode=>"rw" ) );
[cut]

This procedure enable ZM to listen on udp port 6082 for external command.... (in case you can change this port...)
From the web interface of ZM:
2 Take a camera, put "Nodect" for function type (instead of motion detection, recording,...)
3 In the ZM options (System Page/TAB) put the check on "OPT_TRIGGERS" (enable zm to check for external triggers)

Ok, zm configuration is finish!; now on arduino...
Is necessary to create a program that connect ZM on port 6802 (UPD using ethernet) and send the command...
Command format:
6|on+60|255|Arduino alarm

Synstax:
6 is the ID (in the database of ZM), you can find it on the web interface of ZM moving the mouse on the camera (in the link you can see the ID; eg: ...../index.php?view=watch&mid=6)
on+60 Start recording and stop it after 60 seconds
255 the amount of the point for the motion detection (fixed to 255; is the top)
Arduino allarm comment of the alarm
All parameters must be separate with pipe char (|)

another eg
6|on
Start to recording without end (is necessary to send the command 6|off for stop the recording)

Send this type of command for each camera needed (changing the ID of the camera)

At the moment I cant send a sample of the code of arduino... but using the sample in the ide is very simple to implement; in my case a pin of the arduino is conneceted to a switch, when I close it, ZM start to recording...

Zoneminder info on www.zoneminder.org

I love Opensource!

Pier


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi pier71,

First of all, thank you for sharing this idea.

Can you share the arduino code?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 228
Posts: 14053
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Bookmarked the site - was not familiar with it.

Are there plans to port this ZoneMinder to the Rapspberry Pi Platform? 
Arduino + Pi + few cams  ...
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Bookmarked the site - was not familiar with it.

Are there plans to port this ZoneMinder to the Rapspberry Pi Platform? 
Arduino + Pi + few cams  ...

I don't know.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi to all,

sorry for the delay of the answer.

I will post the arduino code asap (I hope tomorrow...)!!!

Pier
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi again,
this is the code of arduino.
Take note1: I have stored the configuration on a sd card of the ethernet shield... in this way it's possibile to change it without change the code.
(Arduino network cfg, zoneminder ip & port, message to send to ZM,...)
Take note2: the message for start recording, it's necessary to know th unique id of the camera (is an ID of the record in the ZM database); to find it, open zm web interface, move the mouse on the first camera and check the link on the bottom of the browser, you will find a link like:
http://192.168.0.4/zm/index.php?view=watch&mid=6 -> the last number is the ID of the camera, you must use this id for dispatch the message

Pier

* arduino.txt (10.4 KB - downloaded 73 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much!

I'm just waiting for my ethernet shield to arrive from ebay to test with Zoneminder  smiley

I have multiple cameras which are very susceptible to cause false alarms by shadows of trees when using motion detection. With PIR sensors I can generate alarms in specific cameras. Also, I can connect these alarms via PIR sensors to a siren controlled by Arduino and a relay board.

I will put also the Zoneminder to start and stop via remote control connected to Arduino.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have make the same... but only for play with ZM and Arduino; in fact the code is not very clean... because is a test for "play" during the winter night...
I have tried to use also the X10 serial protocol... but nothing... it dont work; and is not very simple to implement in arduino

With arduino (and network message) you can start and stop recording (the message can be on for start and off for stop recordinig, on+15 for timing), you can trigger the recording using an input pin... very simple!

Check also this web site, https://sites.google.com/site/arduinozoneminder/ (only Italian language  smiley-sad) for connect arduino, zoneminder and a electic gate; I have take some ideas form their.... but there is not shared codes...

For any other info (if you need) contact me using arduino forum message... in case I will give you my email in a personal message...

good luck and fun with arduino and ZM!!!!
Pier
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you!
I will post new developments as they happen.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Finally my ethernet shield arrived  smiley

I tested your code but it didn't compile when I tried to upload to arduino.

I wrote a very simple code just to test the communication between arduino and zoneminder (based in the Telnet example). The code is in attachement. It just sends the alarm string to zoneminder in 50 seconds interval.

It works fine until I have an error in zoneminder:
"zmtrigger.pl ' exited abnormally exit status 9"

At that point zmtrigger restarts and the camera doesn't leave the alarm state.

In zmtrigger.pl I just have activated the "Chan1" as you did.

Do you had any similar problem?

* arduino.txt (1.12 KB - downloaded 49 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have check your code... and seems correct; also my code is correct, the problem is only the version of the arduino compliler; at the moment I dont remember the version that I use... but you can try with a older version... (It is the declarion of the client that is different...)

The error 9, I dont know why your zm give this error, try to send a "alarm" sessage only one time.
Also, try to send and alarm form the zm consolle (web interface) and check the result (could be a disk space problem, or video recording format problem...)

Pier
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Pier71,
Other people are having this problem. I couldn't solve mine yet.
http://www.zoneminder.com/forums/viewtopic.php?f=29&t=19223
Logged

Pages: [1]   Go Up
Jump to: