Monday, February 2, 2015

WIZnet 550 IO Ethernet Module

Today we are working with the WIZnet 550 IO Module. It's a very small and inexpensive ethernet module based on the WIZnet 5500 chip, similar to the 5100 on the official Arduino Shield. It's completely compatible with the code written for the Arduino Ethernet Shield as well. This is a nice addition to a Arduino Nano or Home built Arduino compatible board that does not require the size and expense of a full shield, plus the 550 has some additional features like increased number of connections, faster performance, and a bigger buffer.

Let's get the module connected, download the drivers, and get a sketch running!

First, the connections:



J1.1 - GND (only one needed, all GND connected on module)
J1.2 - GND
J1.3 - MOSI - 11
J1.4 - MISO - 12
J1.5 - SCK - 13
J1.6 - SS - 10
J1.7 - 3.3v
J1.8 - 3.3v

J2.1 - 3.3v - Arduino 3.3v (only one needed, all 3.3v are connected)
J2.2 - RDY - 7
J2.3 - RST - Arduino Reset
J2.4 - N/C
J2.5 - INT - 2
J2.6 - GND - Arduino Gnd

This module is 5V logic friendly, but requires 3.3v input.





Now download zip from https://github.com/Wiznet/WIZ_Ethernet_Library, extract, and copy the Ethernet folder to your Sketchbook libraries folder. Make sure you get the folder for the right version of your IDE. There are instructions for uncommenting the controller you are using. It defaults to the 5500, but if you go back to your 5100 based shield, you will have to edit the 5100.h file as described at GIThub.

Load the example Ethernet WebServer sketch, enter your IP address you want to assign and MAC address as shown on the module (you can use the default IP/MAC as listed in the directions at GIT Hub if appropriate), and you are off and running. Works just like the original Arduino Shield, but better, smaller, and cheaper.
/*
  Web Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 
 */

#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:
byte mac[] = { 
  0x00, 0x08, 0xDC, 0x1D, 0x29, 0x0B };
IPAddress ip(192,168,254,177);

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

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(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) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
   client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");       
          }
          client.println("</html>");
          break;
        }
        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;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}

Here is the output in the browser:


Resources:
http://wizwiki.net/wiki/doku.php?id=products:wiz550io:start


Related Posts Plugin for WordPress, Blogger...