This is a “how to guide” for the Viknet's project to powerlink for powermax alarms.
The goal is to control our powermax alarm from a web interface via a smartphone or a computer. We can have the basic control of our alarm and the status of every sensor connected on it (open/close). The buttons that we can control are : ARM AWAY,ARM HOME,DISARM,STATUS.
The whole project, exept from the hardware, uses a C daemon which handling all the messages from the powermax alarm and a web inteface (designed with jQuery for iOS/Android) in C/cgi, which “talk” with the daemon over the xpl protocol.
Hardware installation:
What we will need :
An USB to Serial adapter PL2303
A TP-Link TL-WR703N router
A cable for connect the WR703 with the PC port of our Powermax (DIY)
This cable is a Micro-B usb to serial. Its quite easy to make it. Below you can see the pinouts to make the cable .
Micro USB pinout
PL2303
10 pin serial for the Powermax
Pinout for the 10pin serial
Powemax pinout

The pins that connected here are (rightaway from the USB-TTL) :
1 +5V USB CABLE FOR POWER
2-
3 BLACK TX TTL USB
4 GND USB CABLE FOR POWER
5 GREEN RX TTL USB
6
7 WHITE GND TTL USB
8
9
10
When you will finish the cabling and if you make the project without usb hub (you will read later for that), you will have a something like this :
and this is will be your working web interface :
Software installation :
The first thing you should do, is to install the Openwrt firmware at the TP-Link router :
http://wiki.openwrt.org/toh/tp-link/tl-wr703n
**You can install a “trunk” image (without luci interface) or a normal image (with luci interface).
If you install a trunk image, you can try to “fit” all the needed files inside it. If not, you can connect a USB flash to the tp-link via a USB Hub. With this way, you will expand the tp-link ram, so you will not have problem to install anything you like. Also consider that if you use a usb hub, maybe you will not be able to fit the hole projet inside the case of the powermax. I make it this way and my hub was no powered from external psu, but from the tplink via its usb port. So, if you make it with usb hub, you will connect :
your DIY cable from the powemax to the pl2303.
The pl2303 to the usb hub
The usb flash to the usb hub
The usb hub to the usb port of the tp-link
The psu of the tp-link to the power port of the tp-link
Then you will need to make the usb flash the expandable memory of the tp-link. This is how you can do it:
http://xathrya.web.id/blog/2012/12/16/openwrt-extroot/ (try to go to link 2 times)
When you will finish with the openwrt stuff, you will continue with the files from Viknet.
There are 3 basic files that you will start to install to the tp-link. For installation, you will need for a windows based pc, a telnet client (like putty) and an ssh client (like winscp). The procedure is simple. After you connect the tp-link to your pc via lan, you will connect with telnet and with ssh.
You can install packages with telnet and you can transfer files from pc to tp-link (and to edit them) with the ssh client.
When you connect with telnet (while you have transfer already the files at the /tmp folder of the tp-link), you can do “opkg update”, “cd /tmp”, opkg install the_file_you_want_to_install.ipk”. If you want to install openwrt libraries etc, you will only need to do “install filename_you_want")
So lets start installing :
libxpl_1_ar71xx.ipk (this is viknet file)
xPLLibexample_1_ar71xx.ipk (this is viknet file)
pmaxd_1_ar71xx.ipk (this is viknet file)
lighttpd
kmod-usb-serial-pl2303
libconfig
Now we need to do some configuration at :
pmaxd.conf :
Here we are change our pin for our alarm and the name of our each zone (the names are inside the “”).. If we have 10 zones, we will have 10 namezones.
Lighttpd (this is the server for connect to the web interface):
Here we have to change (if we want) the default port : server.port = 8080 (or whatever we want)
So we will hit : XXX.XXX.XXX.XXX:port_number/alarm.html to see our web interface when we will finish the whole job.
Also, for the server to be working, we would add/change at the /etc/lighttpd/lighttpd.conf:
Code: Select all
server.modules = (
"mod_auth",
"mod_cgi"
)
server.network-backend = "write"
server.document-root = "/www/"
index-file.names = ( "index.html", "default.html", "index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".class" => "application/octet-stream",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".svg" => "image/svg+xml",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml"
)
$HTTP["url"] =~ "\.pdf$" {
server.range-requests = "disable"
}
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
server.port = 8080
server.pid-file = "/var/run/lighttpd.pid"
server.upload-dirs = ( "/tmp" )
cgi.assign = ( ".cgi" => "" )
auth.backend = "plain"
auth.backend.plain.userfile = "/etc/lighttpd/lighttpd.user"
auth.require = (
"/" => (
"method" => "basic",
"realm" => "download archiv",
"require" => "user=admin"
)
)
You are almost ready ..
After the lighttpd.conf file, you should install some pluggins for the lighttpd. You can do it via command prompt from telnet (opkg install XXXXX) or via luci web interface ..
You will probably need to install the "mod-auth" and "mod-cgi". Also you should make a simple file (lighttpd.user)for the username/password for the web interface and put it at the "/etc/lighttpd/"..Inside you have to write only one line :"Admin:a_password_you_like"..
Finally you should just enable the programms you like for autostart, every time your tp-link restart..
You will need to have running the programms :
pmaxd
lighttpd
xPL_Hub
Just do from telnet prompt :
Code: Select all
/etc/init.d/pmaxd enable
/etc/init.d/lighttpd enable
/etc/init.d/xPL_Hub enable
Thats it !!!
With the above configuration, when you hit :
http://XXX.XXX.XXX.XXX:8080/alarm.html , you will be prompted to type your Username/Pass and then you should talk with your web interface !!!
For all the above information, I would like to say a big
THANKS to my friend
Viknet, for his support and his huge help and the domoticaforum of course. Without you, I would give it up for sure
***.. You can read the older posts, to see how to check your DIY cable or the xpl commands over your network if something doesnt work.
