Sunday, June 1, 2008

HOME AUTOMATION OVER TCP IP


We can control home appliances from a computer through a device control card connected to parallel port or serial port.

Here we have the project with which a user can monitor his home through a normal webpage on the internet. No need to install softwares at the user end.

N.B.-All the softwares used are opensource except the OS (WIN XP)

Before going deep into the subject I would explain some words I have used here.

q INTERNET

q FIREWALL

q HTML

q WEBSERVER

q APACHE

q CGI

q PHP

q PARALLEL PORT

q SERIAL PORT

q TERMINAL SOFTWARES

q MICROCONTROLLER

q SENSORS

Inetface to the real world

I have started with a DCC(Device Control Card) project, it was my interface to the real world from world of bytes and bits. I have used a 25-pin parallel port connector, transistors, diodes and relays for this.

Insert a heperlink to parallel port.( www.electrosofts.com )

Insert the parallel port interfacing code for DCC.

With this project I can toggle (ON/OFF) a device from a PC keyboard. Here I can programme to schedule a device to ON/OFF at a given time. However that project wasn’t a useful one, but can be used as a learner kit.

The DCC can be done with serial port,which will make it more complex and more effiecient. The DCC with parallel port has a limitation of 8 devices, but with serial port it can be 24. we can use a LCD to monitor it. This system need a microcontroller which acts as a gateway. The devices remain connected to the microcontroller and the microcontroller to the PC serial port. Command from the PC comes through serial port connected to Tx Rx pin of micro. The micro in turn

Sets its pin high or low as the command.

INTERNET

Internet is a network of networks. Every computer connected to intranet(LAN) geta unique local IP address which general form 192.168.xxx.xxx . Every computer connected to internet gets a unique IP address assigned(incase of direct connection only i.e. not through gateway or proxy) . The computer can be called with that address from the network.

Servers

A user cannot view files on another client on the same network. He can access the files if the other computer shares these files through a file sharing application or through a file/ftp/web server. This is due to the firewalls. Firewalls give access through special holes called ports. These are the special paths through the firewall, which is application specific.

Application and resource (hardware) acess from remote

A remote user (user from another client of the network) can’t use its resources directly. For this we hav a programme called telnet in both linux & WIN NT. Which is opened through port 21. It gives way to other programmes be accessible on the network. In newer versions of windows (xp..) & linux(Redhat ws v2.4) there is a advanced software Remote desktop . this application provides a easy GUI (graphic user interface). It gives acess to the hole computer remotely i.e. all of its files, resources,applications ant desktop also.

Insert screenshots of remote desktop and telnet in both linux and xp.

These programmes can be used for a automation project ,as it gives acess to the resources like parallel port & serial port . we have to run a parallel port device control application at the remote PC through telnet or remote desktop.

There is another method for remote operation of PC applications called CGI(common gateway interface). It can be accessed through webpage served by a webserver(CGI enabled ) at the remote PC.

CGI

I have started with C executables as my CGI. Here I hav to write port control programmes in C language and link them directly through a webpage. Before this I have to set a folder to be executable web folder(CGI foder) in my webserver(IIS and apache I have used). The c progrmme should get the inputs through arguments, which was a problem as c programmings takes argument as a continious string.

However I failed to do it with C, it may be due to strong security in XP.

I have to search for a easy CGI interface . I have tried with pearl, first cgi ,asp, php and I got the last one best for me. PHP has a direct port interface, but it was not easy and it may slow down execution speed.

Programmings

Here I hav used

q HTML as user interface,

q PHP as Gateway interface,

q C as Hardware interface.

q Codevision C & Assembly for microcontroller to device interface

Hardware Requirements

q A connection to a network(LAN/Internet)

q A parallel port or serial port

q A microcontroller

q A DCC circuit(given circuit)

q Relays(which is connected to the device…the last interface)

Software Requirements

q A web server (CGI Supported)

q A CGI Software(here I hav used PHP)

q A Turbo C compiler

q A html designer(Optional)

q Code Vision C (To build hex code and burn it)

q AVR Studio (Simulation of Microcontroller)

The webserver

The apache is a free opensource software registered to GCC(General …). A no. of versions available at its website www.apache.org . I hav used a version 2.34 that comes in a package with Easy PHP www.easyphp.net . Apache was first developed for linux later extended to windows. But the operation is same u have to edit some configuration files to run it. It support CGI’s like perl and PHP. U have to configure it for the CGI environment.

You can use IIS(Internet Information Service) comes as a component in windows. The IIS has a HTTP/HTTPS/FTP/SMTP server in a pack.

HTTP Server-To host normal pages

HTTPS Server-To host secured pages

FTP Server- File Server

SMTP Server-Mail Server

Configuring & Running Apache

Apache configure itself from a configuration file apache.conf in the conf folder of the installed directory. You hav to edit some lines to your need.

q Assign a IP ,Name and Port Address

q Make website public.

q Make a CGI folder.

q Add execute permissions from the folder.

q Add PHP environment to it.

Explain all these above points.

The CGI(PHP)

PHP was started as Personal Home Page later is definition changed as PreHeader Preprocessor. It is also a opensource software. It is available for free download at its webportal www.php.net . after installation it adds a environment path to the OS, and adds a file extension .php execution path.

My Computer->Properties->Advanced->Environment variables

Check if the path set or not.

Folder->Tools->Folder Options->File Types

Check if the extension added or not.

Xtronix