Zoneminder and arduino

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 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" ) );


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

I love Opensource!


Hi pier71,

First of all, thank you for sharing this idea.

Can you share the arduino code?

Bookmarked the site - was not familiar with it.

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

robtillaart: 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.

Hi to all,

sorry for the delay of the answer.

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


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: → the last number is the ID of the camera, you must use this id for dispatch the message


arduino.txt (10.4 KB)

Thank you very much!

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

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.

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, (only Italian language :() 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

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

Finally my ethernet shield arrived :slight_smile:

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:
“ ’ exited abnormally exit status 9”

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

In I just have activated the “Chan1” as you did.

Do you had any similar problem?

arduino.txt (1.12 KB)


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...)


Other people are having this problem. I couldn’t solve mine yet.

I know this post is pretty old, but I tried the code and get an error on line 44, I don't know arduino well enough to troubleshoot, can anyone help?