Show Posts
Pages: [1]
1  Topics / Home Automation and Networked Objects / Re: Arduino domotics - house under construction on: May 20, 2013, 01:32:48 pm
Thanks kyngston. I´ll check the vid later cause I am at work now.

Just to keep this updated: I ended up using openHab as the main software controller (running on xubuntu), I really recommend it to all trying to do stuff like this.
There is an event bus and where you can bind lots of types of connectos, in my case, mainly http ones. I was able to parse arduino output (json) from openHab easily.
Also added a little RFC controller interface (look up on, wich has 4 buttons wich turn on off 4 different lights. For the record, this is a big improvement because opening chrome and navigating to openHab interface took long enough from my cellphone/pc. It is now my preffered method, cost is low and works perfect with arduino.
2  Topics / Home Automation and Networked Objects / Re: Simple arduino ethernet communication for beginner on: February 18, 2013, 09:43:57 pm
Thanks a lot for your help spatula & zoomkat.

But I can't see why one would want to send POST requests to the Arduino server, instead of using GET.

The reason of this is that I need to send a large amount of data +20 parameters, I did not find nice to send that amount of data via GET request. Not saying that it is a bad thing to do.

zoomkat, what about reading POSTed parameters, that´s what I need to do.

Server test code that will echo posted data to the serial monitor.

A simple web server using an Arduino Wiznet Ethernet shield.
For Arduino IDE V1.0 only. Previous IDE versions require mods to this code.

Original code created 18 Dec 2009
 by David A. Mellis
 modified 4 Sep 2010
 by Tom Igoe
 modified 18 Jan 2012
 by Tim Dicus

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
//address will look like when submited
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip( 192,168,1,102 );
IPAddress gateway( 192,168,1,1 );
IPAddress subnet( 255,255,255,0 );
//IPAddress dns( 192,168,1,1 );

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(84);

void setup()

  // set SPI SS pins on w5100 and SD

  // start the SD interface here if you want.
  // Add the SD.h library above
  // SD.begin(4);

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip, dns, gateway, subnet);
  // disable w5100 SPI so SD SPI can work with it

  Serial.println("setup finished");

void loop()
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      while(client.available()) {
        char c =;
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {

// Here is where the POST data is. 

          Serial.println("Sending response");
          // send a standard http response header
          client.println("HTTP/1.0 200 OK");
          client.println("Content-Type: text/html");
          client.println("<HTML><BODY>TEST OK!");
//form added to send data from browser and view received data in serial monitor         
client.println("<FORM ACTION=\"\" METHOD=\"post\">");
client.println("Name: <INPUT TYPE=\"TEXT\" NAME=\"Name\" VALUE=\"\" SIZE=\"25\" MAXLENGTH=\"50\"><BR>");
client.println("Email: <INPUT TYPE=\"TEXT\" NAME=\"Email\" VALUE=\"\" SIZE=\"25\" MAXLENGTH=\"50\"><BR>");
client.println("<INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Sign Me Up!\">");
        else if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;

That worked perfectly! Getting params as expected inside the request:
3  Topics / Home Automation and Networked Objects / Re: Simple arduino ethernet communication for beginner on: February 14, 2013, 09:01:34 pm
I would  appreciate some sample code to read /convert the http value (string?)  to  control the arduino analogue pin. Keep searching but can seem to find what I am looking for so any help guidance would be appreciated.

Get your code working with the serial monitor first, then the ethernet part should be easy.

zoomkat, what about reading POSTed parameters, that´s what I need to do.

4  Topics / Home Automation and Networked Objects / Re: Arduino domotics - house under construction on: February 08, 2013, 07:57:22 am
I am curious to see your code for the computer side. I'm not a programmer at all, I'm looking for a way to control the outputs of the arduino from windows using C#. I have the serial port figured out. I am looking a C# code I can copy and paste, then change the pin numbers to the correct pin I want to control. I want to build/compile the code to be exe files for each pin I want to control. I don't want a form application, I'd rather work with console apps.

Dan, I haven´t got any computer side code yet.
You could, as I did, use RESTduino (, that way you can control output pins using only urls, for example, running "curl http://arduinoip/8/LOW" from console you would set pin 8 to low. I am not sure if this would be the best way given your requirements, but it can be done and works.
If doing it from C#, I supose that creating an http request should not be so hard.
But first, are you going to do this by the serial port or through ethernet shield?

since low voltage wire (smaller gauge) is less expensive than higher voltage wire, I would suggest putting the relays next to the component being controlled. That way you dont have to run expensive wire across your home to the relay board.

Rob, thanks for your reply. What do you think about wich cable type to use? In this case a relay uses 3 wires, what about connection port?
5  Topics / Home Automation and Networked Objects / Arduino domotics - house under construction on: February 07, 2013, 01:41:49 pm
Hey guys, I am new in the forum.

Background data:
My idea of this thread is to share my project and maybe get your opinion or experiences and also to help you out if anyone wants the code I am working on, etc.

As my house is under construction, I got really excited of being able to apply some domotics on it, after being a Java programmer for 3 years, I finally got the chance to play with hardware. The first version I am working on consists on Lighting + Security handling.

My project relies on:
-Arduino uno
-Ethernet shield
-Server Machine
-IP cameras

I have planned to install an arduino + eth. shield per one or two rooms (when possible).
All this black boxes (uno + eth. shield) will be connected to a router or switch (I like the idea of the switch because I find better to separate the domotic´s net from my actual wifi + internet net), but this can also be done via software so I still don´t know if it is necessary. Below I will add a question about power sourcing this "boxes".
I expect that I´ll be installing 3 to 5 of this "boxes" in total.

The server machine role will be hosting a web page to manage the house remotely, also bring access to the ip cameras (I took a look at zone minder and found it very powerfull, zone handling, alerts, etc). One idea I like is having zoneminder watching the cameras and being able to talk to the arduino boards through ethernet (for example: turn on a light for a while) if something strange has been detected, "House alone" style haha. Server machine will be storing camera´s images and maybe media center (future plan).

Technical stuff:
From the beggining of this project I had in mind that the system I used had to be able to work (normal use + soft configuration) regardless of the server availability.
What I have done to achieve this is storing an array of structs on Arduino´s eproom wich (each struct) consists of an input pin, output pin, a name and a type. This config can be read through ethernet by accessing http://arduinoip/CONFIG, the response is JSON formatted (did it without a parser because of its simplicity). This config purpose is to map inputs to outputs for the lighting adjustment, acting like a flip flop with multiple inputs for each light.

The next thing after being able to read this configuration is how to write it remotely, I am actually working on this having in mind what I said before, that It must be done regardless of the server availability. To achieve this I am planning to host a web page on the arduino displaying this configuration in a form, being able to modify it and saving it (the form will be submitted to the arduino). IP + MAC address will also be displayed for modifications if needed.
If needed, this same web page will be hosted on the server, maybe with extended functionality, or at least nicer smiley.

Finally, the server communicates to the boards using RESTduino library. As the server is able to read each "box" configuration, it can handle events that affect more than one board (for example turn all the lights off), just by accessing http://arduinoip/8/LOW will turn the 8 pin output off.

The lighting on/off control will be done using the 5v Relay available on

1. What do you recommend, having a power source for each arduino or having only one (more powerfull) all of them (with the advantage of having 9v through all he house for future)?
2. Relays, I don´t know where to install them, near the arduino or near the controlled object. I like that having it near the object (for example a lamp) will separate my arduino from 220v being safer to do maintenance on the board.

Feel free to leave any comment of opinion about any of the ideas I have.
Sory for my english and the extension of this thread, it got large.

6  Topics / Home Automation and Networked Objects / Re: Simple arduino ethernet communication for beginner on: February 07, 2013, 12:35:19 pm
It seems pretty simple, and I've been reading and searching how to do it, but I'm just not really getting it

Thank you very much for creating this thread smiley-grin, havent tested the solution yet, but I was on the same situation, every time I searched for "arduino receive data through ethernet" I found arduino hosting pages or accessing them, but never reading data from the request (POST and GET parameters).

Although, I found this very interesting library called RESTduino wich I am using on my project, it´s really awesome and works like a charm.
Pages: [1]