DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-11-19 17:10:48

Zdai
New member
Registered: 2009-10-26
Posts: 4

Home Automation with DNS-323, CUL and FHEM

Hello,

I finally succeeded to run my home automation system on the DNS-323. As I haven't found any other 'finished' tutorial to do so on our little NAS, I will share my experience with you.

The main idea is to be able to plug a CUL device and to run the FHEM software on the NAS, to control all your device which communicate at the 868MHZ frequency with  certain protocol and take full advantages of the DNS with a full internet connection. With this system, you will be able to : turn on/off heating from work, to close the windows shutter 30 min after the sun set, monitore your power consumtion etc.

To do so you need :
    * a NAS with the 2.6.12.6 kernel (firmware version 1.08 and 1.09 ok)
    * a CUL dongle
    * some 868MHZ devices (as a FHT-80 set to control the heating system in a room)

Warning :
This topic is not here to :
    * explain how ffp works
    * explain you how to design your home automation system
    * discuss about the better communication protocol
    * explain how to use linux command
    * explain how to use FHEM

I. Flashing the CUL device (On a windows PC)

Download FLIP software at ATMEL website:
   

http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3886

Install it. Plug your CUL device in the pc usb port. When prompt for driver install, do not install windows default driver.
Choose the driver from FLIP's '/usb' directories
Download the good firmware from :
   

http://culfw.de/culfw.html

Follow this tutorial to flash the device :
   

http://code.google.com/p/micropendous/wiki/LoadingFirmwareWithFLIP

Refer to this page to choose the proper Atmel references :
   

http://busware.de/tiki-index.php?page=CUL

The firmware should be in the Device folder of the downloaded archive.


II. Install Fonz' fun_plug

Install Fonz_Plug :
   

http://www.inreto.de/dns323/fun-plug/0.5/

or
   

http://nas-tweaks.net/40/installation-of-the-fonz-funplug-0-5-for-ch3snas-ch3mnas-dns-323-and-many-more/

Connect to the NAS by ssh or telnet. Get all the fun_plug base packages, needed to build program later (source)
   

Code:

mkdir /ffp/packages
cd /ffp/packages
/ffp/bin/rsync -av inreto.de::dns323/fun-plug/0.5/packages .

Get also all the perl packages

Code:

mkdir /ffp/packages/perl
cd /ffp/packages
/ffp/bin/rsync -aLv inreto.de::dns323/fun-plug/0.5/extra-packages/perl .

(note the 'L' in the last command line, to resolve symbolic link)

Before installing the packages, you need to first update the packages which are already installed with fun_plug
   

Code:

cd /ffp/packages
funpkg -u packages/funpkg*.tgz
funpkg -u packages/*.tgz
funpkg -u perl/*.tgz

Install then install all the remaining packages
   

Code:

funpkg -i packages/*.tgz
funpkg -i perl/*.tgz

III. Configure PERL

Now we will check if the perl packages is correctly set-upsource
   

Code:

 /ffp/bin/perl -MCPAN -e shell

Say yes the first time. Then we are going to change all the directories to point to ffp directories. Type
   

Code:

o conf init

Put everything directories in /ffp/. I.E. replace /.cpan/prefs with /ffp/.cpan/pref etc.
When prompt for 'YAML' enter 'YAML::Syck' to point to the installed version of YAML. Put also the 'YAML deserialisation' option ON

Then install the 'Device::SerialPort' for FHEM (that can take up to 5 hour). This is required as the CUL dongle contain is in fact a serial device.
   

Code:

sudo cpan Device::SerialPort

IV. Load driver for CUL device
Then we need 3 drivers to be able to plug the CUL into the NAS.

First create the folder to store those drivers
   

Code:

mkdir /ffp/lib/modules
mkdir /ffp/lib/modules/2.6.12.6-arm1
mkdir /ffp/lib/modules/2.6.12.6-arm1/kernel
mkdir /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers
mkdir /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers/usb
mkdir /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers/usb/serial/

then download them:
   

Code:

cd /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers/usb/serial/
wget http://dev.skcserver.de/dns323/modules_v1.03/kernel/drivers/usb/serial/usbserial.ko
wget http://dev.skcserver.de/dns323/modules_v1.03/kernel/drivers/usb/serial/ftdi_sio.ko
wget http://dev.skcserver.de/dns323/modules_v1.03/kernel/drivers/usb/serial/pl2303.ko

and copy also the dependencies files:
   

Code:

cd /ffp/lib/modules/2.6.12.6-arm1

V. Install FHEM on the NAS
Then we install FHEM on the NAS. Unpack http://fhem.de/fhem-5.1.tar.gz on the NAS. Modify the 6 first lines of the Makefile to point to ffp directories, as follow :
   

Code:

BINDIR=/ffp/usr/bin
MODDIR=/ffp/usr/share/fhem
VARDIR=/ffp/var/log/fhem
DOCDIR=/ffp/usr/share/doc/fhem
MANDIR=/ffp/usr/share/man/man1
ETCDIR=/ffp/etc

And then install FHEM with the pgm2 interface source :
   

Code:

cd /mnt/YOUR_DISK/FHEM_FOLDERS/
    make install-pgm2

V. Install the USB serial drivers on the NAS
Now load the drivers for the CUL dongle on the NAS source :
   

Code:

insmod /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers/usb/serial/usbserial.ko  vendor=0x03eb product=0x204b
insmod /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers/usb/serial/ftdi_sio.ko
insmod /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers/usb/serial/pl2303.ko

Plug the CUL dongle on the NAS. If he doesn't show up int /dev/, you can force it source :
   

Code:

mknod /dev/ttyUSB0 c 188 0
ls -l /dev/ttyUSB0

VI. Launch FHEM
To start fhem server then :
   

Code:

perl /ffp/usr/bin/fhem.pl /ffp/etc/fhem.cfg

And add the CUL device in FHEM command line:
   

Code:

define CUL1 CUL /dev/ttyUSB0@9600 1422

VII. Enjoy your system !
Enjoy!
http://fhem.de/pgm2-3.png

VIII. Annex
To still have everything working at reboot, you should add the last 6 command to our /ffp/etc/fun_plug.local file :
   

Code:

insmod /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers/usb/serial/usbserial.ko  vendor=0x03eb product=0x204b
insmod /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers/usb/serial/ftdi_sio.ko
insmod /ffp/lib/modules/2.6.12.6-arm1/kernel/drivers/usb/serial/pl2303.ko

mknod /dev/ttyUSB0 c 188 0
ls -l /dev/ttyUSB0

perl /ffp/usr/bin/fhem.pl /ffp/etc/fhem.cfg

Last edited by Zdai (2011-12-11 14:15:05)

Offline

 

#2 2011-11-26 04:15:19

bound4h
Member
Registered: 2010-04-12
Posts: 209

Re: Home Automation with DNS-323, CUL and FHEM

Very cool man. Excellent tutorial and a brilliant use of material to make life a little easier.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB