arduino : Perfect controller board for Zoneminder ...

Post here to ask any questions about hardware suitability, configuration in ZoneMinder, or experiences. If you just want to know if something works with ZoneMinder or not, please check the Hardware Compatibility sections in the forum, and the Wiki first. Also search this topic as well.
Post Reply
ktheking
Posts: 70
Joined: Fri Oct 12, 2007 11:53 am

arduino : Perfect controller board for Zoneminder ...

Post by ktheking »

Check this : http://www.arduino.cc/

This board can do very very very much for very low cost : 22€ !!!

The potential is huge.


I'm currently planning to use it for controlling LED's.

Cam 1 : green+red led
Cam 2 : green+red led
...

Backup : green+yellow+red led

Zoneminder status : green led

12V power supply status : green led


Major advantages :
-this board is available in USB and Serial Port
-extensable
-cheap
-multi platform support
- ...

I've ordered one and will see how this turns out ... I'm very hopeful.

Kind regards,

K.
ktheking
Posts: 70
Joined: Fri Oct 12, 2007 11:53 am

Post by ktheking »

My first succesfull test : http://www.arduino.cc/cgi-bin/yabb2/YaB ... 1202054885


Right ! Thanks for all your help. I did here below a little step by step how I managed to get it work.


Preface : Every line starting with 'tux@ubuntu:~$' ,means that this is a command excuted by the command line
Preface : Every reference to $HOME or /home/tux , can be changed to your own home directory.

1. Check if device is recognized by system

-connect usb device to system
Code:

tux@ubuntu~$ dmesg | tail | grep "FTDI USB Serial" | grep -c "now attached"




the result of this must be '1'

If it is 0 , then your device is not recognised. (check if the brtty package is installed)



2. Prepare needed files ,and execute a little test
Code:

tux@ubuntu~$ cd $HOME




-install pre-requisites :

First the downloads out of the box :
Code:

tux@ubuntu~$ sudo apt-get install gcc-avr avr-libc avrdude unzip




Then avrdude ,from arduino itself :
Code:

tux@ubuntu~$ apt-get install gcc yum bison flex
tux@ubuntu~$ wget http://www.arduino.cc/files/avrdude-5.4 ... 10-src.tgz
tux@ubuntu~$ gunzip -c avrdude-5.4-arduino-0010-src.tgz | tar -xvf -
tux@ubuntu~$ cd ./avrdude-5.4-arduino-src
tux@ubuntu~$ ./configure
tux@ubuntu~$ make clean
tux@ubuntu~$ make
tux@ubuntu~$ sudo make install





-Download and unpack the core file in $HOME/arduino
Code:

tux@ubuntu~$ wget http://www.arduino.cc/en/uploads/Hackin ... 7-core.zip
tux@ubuntu~$ unzip arduino-0007-core.zip




-Download and configure the Makefile
Code:

tux@ubuntu~$ mkdir $HOME/arduino_projects
tux@ubuntu~$ cd $HOME/arduino_projects
tux@ubuntu~$ wget http://www.arduino.cc/en/uploads/Hacking/Makefile
tux@ubuntu~$ cp -p $HOME/arduino_projects/Makefile $HOME/arduino_projects/Makefile.original




-Create you testproject file ,connect a led between GND and pin 13 :
Code:

tux@ubuntu~$ vi $HOME/arduino_projects/helloworld.cpp




And enter this :


Quote:
#include <WProgram.h>
/* Blinking LED
* ------------
*
* turns on and off a light emitting diode(LED) connected to a digital
* pin, in intervals of 2 seconds. Ideally we use pin 13 on the Arduino
* board because it has a resistor attached to it, needing only an LED

*
* Created 1 June 2005
* copyleft 2005 DojoDave <http://www.0j0.org>
* http://arduino.berlios.de
*
* based on an orginal by H. Barragan for the Wiring i/o board
*/

int ledPin = 13; // LED connected to digital pin 13

void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}


edit the Makefile and change these lines :

Code:

tux@ubuntu~$ vi $HOME/arduino_projects/Makefile




#<<== First the port on which to connect to ==>>#
#<<== This port can be found in the message log ==>>#
To know the port :
Code:

tux@ubuntu~$ dmesg | tail | grep "FTDI USB Serial" | sed 's/to/\;/g' | awk -F";" '{ print $2 }' | tail -1 | sed 's/ //g'




Edited:
From : PORT = /dev/tty.usbserial*
To : PORT = /dev/ttyUSB0




#<<== Then change the location to the core files ==>>#
Edited:
From : ARDUINO = /Applications/arduino-0007/lib/targets/arduino
To : ARDUINO = /home/tux/arduino



#<<== Specify project loaction ==>>#
Edited:
From : TARGET = foo
To : TARGET = /home/tux/arduino_projects/helloworld



#<<== Change this line ,depending of the version of you arduino ATMEL chip ==>>#
#<<== Out of the box ,the makefile is made for the ATMEGA8 , so I needed to change it to ATMEGA168 ==>>#
Edited:
From : MCU = atmega8
To : MCU = atmega168


#<<== I also needed to change this line ,which I think is due to version of the board ==>>#
Edited:
From : AVRDUDE_PROGRAMMER = stk500
To : AVRDUDE_PROGRAMMER = stk500v1





FINAL STEP

Now clean out the make ,perform a make ,and upload it.

Code: Select all

tux@ubuntu~$ cd $HOME/arduino_projects
tux@ubuntu~$ make clean
tux@ubuntu~$ make
tux@ubuntu~$ make upload 




Now wait a few seconds and the led should start to blink. (If not check if polarity of the connected led is ok)

And voila , pfwoeih ... not straight forward. But hey ; IT never is (luckely for us)
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Thanks very much for this. it would be really neat if you could add it to the Wiki so people can find it more easily.
Phil
ktheking
Posts: 70
Joined: Fri Oct 12, 2007 11:53 am

Post by ktheking »

No problem ,but first I'd like to achieve some applicable example.
Right now all tests haven been done without zoneminder.

Some more tests are yet to come.

But here are some features who will be come VERY interesting :

Perl communication to Arduino over serial USB
http://www.windmeadow.com/node/38

Interface from Perl to an Arduino driving an LCD
http://search.cpan.org/~montuori/Device ... -LCD-1.02/

Arduino Tutorial: Read Button and Send Data to PC
http://dma.ucla.edu/senselab/node/350

Control Arduino remotely with HTML forms
http://blog.datasingularity.com/?p=50


More neat stuff over here : http://www.freeduino.org/
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

That does look like it has a lot of potential. I notice the card is based on an Ateml chip. I have done quite a bit of embedded work on Atmel chips and boards lately.
Phil
ktheking
Posts: 70
Joined: Fri Oct 12, 2007 11:53 am

Post by ktheking »

Yes indeed , the first project will be a perl script that will enable me to light up , flicker or power off a led ,from a led matrix .

It will be something like :

ledmatrix -matrix 1 -led 11 -flicker 1 .

Purpose is to output zoneminder events to the ledmatrix. So that the zoneminder status is transferred to a led board.

Using the combination of these articles :
Arduino Tutorial: Read Button and Send Data to PC
http://dma.ucla.edu/senselab/node/350

Perl communication to Arduino over serial USB
http://www.windmeadow.com/node/38

LED Driver - Serial to Parallel Shifting-Out with a 74HC595
http://www.arduino.cc/en/Tutorial/LEDDriver
http://www.arduino.cc/en/Tutorial/ShiftOut







The next project will be to send out zoneminder detailed status messages to an LCD screen.


Then the final one ,will be the ability to send electronic messages to zoneminder. For example a simple one : the detection of a camera connection/disconnection of a camera input. So that a green/red led will light whether or not a camera is connected or disconnected.

Surely more possibilities exist ,but this will already be a challenge for me. Morever that I don't know anything about C language or Perl. But I am obstinate and determined.

Strange that I'm the first one to think about combining arduino and zoneminder.
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Good luck with that. Hopefully you have started to tap into a gold mine of interoperability with other applications and bits of hardware.

Please keep us up-to-date and feel free to ask any questions here.
Phil
ktheking
Posts: 70
Joined: Fri Oct 12, 2007 11:53 am

Post by ktheking »

Bloody hell , this C is a nightmare ... :evil:

Even the demo code needs debugging and error correcting.
Difficult to understand if you don't have C knowledge whatsoever ...

But I did manage to run some code already ,but nothing usable for zoneminder.

I came altough trough a very usefull link for all you pcb builders : http://www.batchpcb.com/

example : http://dotmatrixdesign.tumblr.com/rss

They can create for you a real pro pcb ,based on your design.

Once I can make this stuff work , I actually can order and create a PCB from here.

I am still convinced however that this device is imperative for a proper implementation of Zoneminder.
technicavolous
Posts: 56
Joined: Sun Nov 11, 2007 12:10 am
Location: Howey In The Hills, FL

Post by technicavolous »

I have been thinking about using something like LCD4Linux or LCDProc to display data about ZM on an LCD for our 1-up servers. (1 up servers are tiny and what a pain in the butt to get the capture cards in! but I digress ...)

THere is a series of Motorola chips (now Freescale) called the 'Nitron' series that have 8 or 16 pins. I bring this up because Freescales 'CodeWarrior' c compiler is free for those chips and their C coding is very straightforward.

LCD4Linux and lcdproc both use the parallel port to interface to a character or graphic lcd. Might be an option to making boards, etc.

Your idea however also lends the option of having a few buttons on the front panel that could provide basic functions like reboot, start / stop zm, etc. I think the combination of the two would be awesome.
Tracy Markham

If you take the path of least resistance, you're probably on a downhill journey ...
ktheking
Posts: 70
Joined: Fri Oct 12, 2007 11:53 am

Post by ktheking »

I gotta give forfeit on this ...
I need help from some more experienced people on this.
If anyone with arduino experience -and time-,please feel free to shout.
The thing I want to accomplish :

Send with signals from perl script to the arduino controller so that a specific led hooked with some matrix setup on the arduino will light up or stop lighting up.
Post Reply