Exhibition / Gallery
Home automation made easy
Topic: Home automation made easy
(Read 2205 times)
Home automation made easy
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"
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..
In the above example I simply:
Upload the web server program to the webserver dedicated Arduino (changing the IP address in the code to suit my network)
Upload the "configurator" to a board and connect to the serial monitor
Wipe the board memory with option 1
Configure the boards name as "lightwave"
Configure function number 0 called "lght-up" as a "lightwave function" that uses channel number "1"
Upload the "listener" program to the same board and boot it
Configure my phone (out of scope for this topic) to send the POST command that contains the sensorname, target function, and the on / off or numberical value
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!
main_unit_HTTP_v2 = Web server
Receiver_with_EEPROM_writer_v3 = The configurator program for prior listener
Receiver_with_EEPROM_listener_v3 = The listener program for post configurator
downloaded 105 times
downloaded 80 times
downloaded 85 times
Re: Home automation made easy
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:
Without this library, I'd still be trying to decode the LightwaveRF protocol...