• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Arduino Ethernet Shield and Internet of Things

    Blog entry posted in 'Electronics and Other Ramblings...', May 26, 2014.

    A while ago I acquired a WIZ110SR with the goal to be able to monitor devices around the house through the Web. At first I thought that all I would have to do was to map directly to the WIZ110SR address through Tenet. Though this worked well within my Intranet, it did not work through the Ethernet. I've been playing with this on and off through the last year; but with very limited success.

    Summer is coming again and the kids are off. Which means I get to do little house projects and engage the kids on the projects. I have a few sensors around the house which are ready to be connected; IF I could read them from the outside world. As luck would have it Sparkfun just opened the doors to their new data server. Boy, that was sweet music to my ears. A free server, with a very simple interface, which can serve almost any kind of simple data. What is not to love. Only problem; I still cannot get my darn WIZ110SR to work as a web client.

    Answer: Move away from WIZ110SR and into the Arduino Ethernet Shield. Days after I saw the announcement I decided to jump into this one. I got and Arduino Uno and the Ethernet Shield from SEEED Studios. And I got them both for $35 at one of the local RS stores.

    It took me a few nights to get used to the Arduino environment and yet another to get the Ethernet shield working. But in less than a week I got it to talk to Sparkfun's Data Server. How sweet is that. I posted the code below for any one who may be interested on a similar setup.

    Next, I need to get familiar with the VirtualWire and OneWire libraries; and link them to my DS18B20 sensors and OOK systems.

    Code:
    /*
    Sparkfun Date Web client
    This sketch connects to the Sparkfun Data feed (http://data.sparkfun.com) using an Arduino Wiznet Ethernet shield.
    Circuit:
    * Ethernet shield attached to pins 10, 11, 12, 13
    created 24 May 2014 by @languer

    */

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

    // Enter a MAC address for your controller below.
    byte mac = {0xDE, 0xAD, 0xBE, 0xEF, 0xFF, 0x01};
    char server = "data.sparkfun.com";
    char publicKey = "/input/Jxyjr7DmxwTD5dG1D1Kv";
    char privateKey = "?private_key=gzgnB4VazkIg7GN1g1qA";
    char vars = "&brewTemp=Live%20From%20Arduino";

    // Initialize the Ethernet client library
    EthernetClient client;

    void setup()
    {
    Serial.begin(9600);
    delay(2500);
    Serial.println("Sparkfun Web Client");
    // Open serial communications and wait for port to open:
    Ethernet.begin(mac);
    }

    void display_ethernet()
    {
    Serial.print("My IP: ");
    Serial.println(Ethernet.localIP());
    delay(1000);
    }

    void loop()
    {
    // if connection was successful, send data to display
    if (client.connect(server, 80))
    {
    Serial.println("sending data...");
    client.print("GET ");
    client.print(publicKey);
    client.print(privateKey);
    client.println(vars);
    client.println("Host: data.sparkfun.com");
    client.println("Connection: close");
    client.println();
    Serial.println("data sent...");
    }
    if (client.available())
    {
    Serial.println("reading data...");
    do
    {
    char c = client.read();
    Serial.print(c);
    } while (client.available());
    Serial.println("data read...");
    }
    // if the server's disconnected, stop the client:
    if (!client.connected())
    {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    // do nothing forevermore - remove to continuously send data
    while(true);
    }
    delay(5000);
    }

    Comments
    languer, May 31, 2014
    posted follow-up on [url]http://www.electro-tech-online.com/blog-entries/arduino-internet-of-things-continued.748/[/url]
    languer, June 08, 2014
    I attempted to do a quick VirtualWire implementation to the sensors I had available which already contain a PIC controller. This resulted in much more work than I was anticipating. So instead I am translating the code I already have working on my OOK Sensors ( [url]http://www.electro-tech-online.com/blog-entries/ook-wireless-transmit-receive-pair-%E2%80%93-simple-pro.266/[/url] ) into the Arduino which is providing the Web interface. So far a direct interface between PIC and Arduino (no special encoding just yet) is working quite good.
 

EE World Online Articles

Loading

 
Top