views:

171

answers:

6

Is it possible even to do this kind of things?

EDIT

Can someone provide a "hello world" demo to try out?

A: 

It is. Google X10 - a protocol for cumunicating with things like lights and appliances.

Matt Wrock
@Matt Wrock,Any demos?
Shore
+1  A: 

X10 java api. And another.

SmartHome - everything related to home automation.

ChssPly76
Is there a PHP version?In fact I'm not so familiar with JAVA.
Shore
And I'm not that familiar with PHP :-) Seeing as how C / C++ / Java APIs exist I'm sure one can be written for PHP if noone has done it already.
ChssPly76
Have you ever tried X10?Do I need to buy some hardware for it to work?
Shore
What are you going to control if you don't have any hardware? First link I posted provides java API for FireCracker X10 controller kit, you can expand from there.
ChssPly76
+1  A: 

Most if not all digital I/O cards for PCs are controlled through an interface written in C. Then most of those offer a library so you can control the boards through software you've written. Since you are able to make extensions for both of those languages in C, you could indeed write a Java or PHP wrapper around a C library for a digital I/O card and control pretty much anything that can be controlled with a digital signal.

For instance, Google quickly turned up the HW-Group IO Controller with libraries in Java and PHP (among others) and with 8 in, 8 out DIO.

Mark Rushakoff
That's the theory,anything practical?
Shore
PHP communicating with a phone to send out sms and so on. how about that? customized DLL extension written in C working with the GSM modem drivers.
thephpdeveloper
Many industrial applications - this is pretty much the only way to do data acquisition of multiple signals at a very high sampling rate, on a PC. Although robots usually use embedded devices, there's no reason you couldn't have a full-fledged computer with some sort of DIO board controlling it. I think some CNCs fall into this pattern as well.
Mark Rushakoff
+3  A: 

X10/Insteon are good bets. I have seen that both of them have developer kits. You have to at least but some modules for the appliances/outlets you wish to control. I would stay away from the AC unit and just buy a programmable thermostat ;) In the end, you're going to have to do research and buy some interface hardware and control modules. X10/Insteon is probably the cheapest way to get to you goal.

Begin rant: I have personally used X10 and it was pretty easy to use, simple serial port/com port interface to trigger lights. I don't have the code anymore, besides I feel like you're looking for a copy-n-paste solution without thinking about the problem. Even if there is an API in Java/C/C++/Python/etc... you can find a way to invoke it from PHP. Asking a more specific question may get a more specific answer. Also, don't ask for a language you admit that you don't know.

basszero
A: 

X10 devices can be used for example to control Lava Lamps for extreme feedback when doing continuous integration. There is plenty of literature on this subject on the net. Have a look at the X10 CM17A API and Bubble, Bubble, Build's In Trouble for a real world use case.

Pascal Thivent
A: 

Why does everyone who asks these sorts of questions assume that controlling physical hardware from a computer is so easy you can do it in any Godforsaken language like PHP? That is so far removed from anything remotely physical it's not funny.

First off, no: there is no easy way to do this! There are no products you can buy to use PHP to control your house. If there were, they would not be cheap. If there were, they would not be easy.

Here is a list of the skills you will need to have at least a passing familiarity with before you can attempt to intelligently create a home automation system:

Microcontrollers - The Arduino is a good start - AVR microcontroller with a library of functions that makes it easier (but not foolproof) to work with. You'll absolutely have to know about...

C programming - no if's and's or buts. You have to know C. Or assembly, but I don't think you want that. You also have to have the toolchain for the Arduino so you can put your code on it.

Basic electronics - Do you know V=I*R? Do you know why it's important? Can you make a transistor switch? Have you hooked together TTL logic chips to do simple tasks? Do you know the output current capability of a logic port on the Arduino? Will you actually have to do any of this to make your home automation system? Probably not. Will you be back here asking more basic questions like 'Why can't I turn this lightbulb on with a digital logic port?'

Serial protocols - X10 has been mentioned here and it's good. But you need to know about serial protocols or ethernet or anything else low-level. You have to know how to read traffic on the serial lines. You have to know about buses and collisions how to prevent them. You have to know about frames and packets so you can debug what's happening. You have to know how a UART works and the difference between synchronous and asynchronous serial. You should probably also figure out...

TCP/IP Communications - The Arduino can do this! It's great! But have you ever done it? Do you know how to communicate on a port? Have you written a command set for an embedded device (so you can control it via TCP or UDP port)? Have you ever used a TCP port to control test hardware (or any other hardware)?

Home electrical systems - Quick! Which wire is hot? White? Green? Which is ground? How is ground different from neutral? How many amps will kill you? Is your air conditioner 240V or 120? What is the standard amperage in a home circuit? Is it enough? Is it too much? Again, how much of this will you have to do? Maybe none. How dead will you be if you screw up with wall power? Pretty dead.

I hate to be a jerk about this but it's frustrating to see so many code jockeys asking questions like this that assume everything that isn't code has a library to access it or a program that will allow them to flip some bits and do awesome things. News flash: This is difficult! Or it would already be done. Most of the pre-made systems I've seen arent' great. Most of the good ones are entirely home-made. By people who have spent years studying these various subjects so they can create these things and do it safely.

If you want my advice, do this:

Get an Arduino - www.arduino.cc It's fairly cheap, easy and a good way to start with microcontrollers. You will need to use microcontrollers to do this in some form. If you buy the system, you're buying microcontrollers. If you build the system, you'll be building it with microcontrollers.

Get a book on home electrical systems - There's lots of gotchas and I don't want you to get hurt. I tell stories about how when I was working on science projects I forget to unplug it and saw cool sparks. I tell stories about getting shocked by 110 AC in hoghouses. I tell stories because I'm still alive. There is no law that says you'll be so lucky.

Get a basic electronics book - I have 'Microelectronic Circuits' by Sedra/Smith. It's a good book. Might be a little advanced.

Learn C - You have to use C. Or C#. Maybe Java. C is used on microcontrollers. Get 'The C Programming Language' by Kernighan and Ritchie. It's THE C book.

Read up on X10 - Start with wikipedia and move on. You'll probably use it.

Good luck!

Stephen Friederichs