Arduino Forum

Community => Exhibition / Gallery => Topic started by: adam_burt on Aug 15, 2013, 02:34 pm

Title: Home automation made easy
Post by: adam_burt on Aug 15, 2013, 02:34 pm
Good morning everyone,

I'm fairly new to the forums (1 day old  :)) and considering that the Arduino project is open source, I wanted to share my existing code with everyone for home automation.

I shall explain a bit about the project, prior to just dumping code.

Objectives for the project

To control lights, TV / audio equipment and other external devices that would respond to "current"

SIMPLE configuration

Globally accessible



OK, so there are not MANY requirements that I decided on. However, it is the "simplicity" side of things that I wanted to focus on.

The aim was to create a program that, once loaded to the Arduino, asked me for config settings. This results in the user being able to program functions from 1-30. Each function has a name and a designated pin or "integer" assigned to it. For example: Function 1 named "hose" is assigned to pin 8 and is of type "digital". Function 2 is named "curt1" and is of type "analogue" and assigned to pin A2. Function 5 is named "dwn-light" and is assigned to LightwaveRF channel number 13.

Now, to trigger these separate functions, each board is also given a "name". This name is sent in the commands (that we'll get to in a moment) and therefore only the correct Arduino board responds to the commands designated for itself. The commands are sent via HTML POST to an Arduino running a web server. This web server code is simply "change the IP address in the first few lines of code" then apply code to board and voila, it's running. The commands are then distributed via RF (XBee modules) to all the Arduinos in range.

For those who like visuals (like me) below is a quick and dirty representation of a command being sent from my phone to the web server, and what happens to it..

(https://drive.google.com/uc?export=view&id=0B8zbbGy6DrxuUC1pUTNMWTdDbGs)

In the above example I simply:



The web server receives my request, broadcasts via XBee module, the Arduino who's name is "lightwave" receives via XBee module and only processes the command if it's name matches. Then checks EEPROM memory for a function called "lght-up" (which is a lightwave function) and sends the command via lightwave protocol from ID number 2.

I have not yet commented the code, which I will be working on in my spare time.

Any thoughts and comments are welcomed. I only studied Pascal (10 years ago) and had to adapt my knowledge to C++ (very similar) so my coding might not be optimal!

Regards

Adam

p.s
Title: Re: Home automation made easy
Post by: adam_burt on Aug 15, 2013, 02:38 pm
..and as an edition, there are uses of other libraries in the code.

HUGE thanks to "Geek Grandad" for producing the LightwaveRF library here: http://geekgrandad.wordpress.com/2013/01/03/lightwaverf-arduino-library/ (http://geekgrandad.wordpress.com/2013/01/03/lightwaverf-arduino-library/)

Without this library, I'd still be trying to decode the LightwaveRF protocol...