Microduino W5500 Network (5)

From Microduino Wiki
Jump to: navigation, search

Purpose

The course will show you how to turn your Microduino to a server, enabling you to browse it at home.

Equipment

  • Other hardware equipment
    • USB cable One

World Wide Web

Webpage is consisted of HTML markup language, which adopts mark to describe web content.

The main advantage of using HTTP protocol to communicate with Microduino online is:

  • You can use comment browsers such as ID and Firefox without the need to develop special client.
  • You can use Microduino character string function to manage HTTP protocol.
  • You can also adopt Microduino to create page or even dynamic one.

Schematic

  • Microduino-ENC28J60
  • Microduino-RJ45
  • Microduino-Core
  • Microduino-USBTTL

Stack them and plug in cable.

As follows:

MicroduinoW5500Show.png

Program

[MicroduinoW5500Five]

Debugging

Step 1: First, make sure you have _02_Microduino_Ethernet_WIZ library in your IDE and put it into libraries folder of your IDE.

Step 2: If there still exists the previous Ethernet library in your libraries folder, it needs to be deleted since the previous Ethernet is compiled according to W5100.

Then, you need to change _02_Microduino_Ethernet_WIZ file so that the library function could be corresponding with Microduino-W5500: First find w5100.h of utility in _02_Microduino_Ethernet_WIZ library.

Change #define wiz_cs_pin 8 //CS_PIN of the code to #define wiz_cs_pin 10 //CS_PIN.

Step 3: Interpret the code:

The program will first monitor if service is visited. while (client.connected()) {

If yes, it will send analog values of 0~5 to client analog port:

         // 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("
"); } client.println("</html>"); break;

Step 4: Download code and compile. Step 5: Check your IP address via serial port and enter corresponding IP address of Microduino in the browser.

Result

The result should be:

MicroduinoW5500ShowAnalog0-5.png

Serial port cut figure as follows:

MicroduinoW5500SerialCutImage.png

Video