<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Microduino_ENC_Network_%285%29</id>
		<title>Microduino ENC Network (5) - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Microduino_ENC_Network_%285%29"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Microduino_ENC_Network_(5)&amp;action=history"/>
		<updated>2026-04-21T09:49:26Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Microduino_ENC_Network_(5)&amp;diff=2499&amp;oldid=prev</id>
		<title>Pkj：Created page with &quot;{{Language | Microduino ENC网络（五）}} {| style=&quot;width: 800px;&quot; |- | ==Objective== This tutorial will show you how to make Microduino act like a web server, so you can a...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Microduino_ENC_Network_(5)&amp;diff=2499&amp;oldid=prev"/>
				<updated>2014-05-06T13:27:24Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language | Microduino ENC网络（五）}} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== This tutorial will show you how to make Microduino act like a web server, so you can a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Language | Microduino ENC网络（五）}}&lt;br /&gt;
{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
This tutorial will show you how to make Microduino act like a web server, so you can access it in your home network.&lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
*'''[[Microduino-Core]]'''&lt;br /&gt;
*'''[[Microduino-FT232R]]'''&lt;br /&gt;
*'''[[Microduino-ENC28J60]]'''&lt;br /&gt;
*'''[[Microduino-RJ45]]'''&lt;br /&gt;
&lt;br /&gt;
*Other equipment&lt;br /&gt;
**USB cable  &lt;br /&gt;
&lt;br /&gt;
==World Wide Web==&lt;br /&gt;
Amongs the network services, the most used one is surely the web service: everytime you “surf” on a website, the program you use (named browser) connects to the web server hosting that site using HTTP protocol and gets the content (pages, images, videos…) to show.&lt;br /&gt;
&lt;br /&gt;
Web pages are composed using a markup language named HTML; this language uses tags to describe page content.&lt;br /&gt;
&lt;br /&gt;
The main advantages in using HTTP to talk with Arduino on a network connection are:&lt;br /&gt;
&lt;br /&gt;
*You don’t need to develop a dedicated client, you can use a common internet browser (Internet Explorer, Firefox…);&lt;br /&gt;
*HTTP protocol is textual, you can easily manage it with Arduino’s string functions;&lt;br /&gt;
*HTML language is also textual, you can easily create pages -also dynamic ones- with Arduino.&lt;br /&gt;
&lt;br /&gt;
==Schematic==&lt;br /&gt;
*Microduino-ENC28J60&lt;br /&gt;
*Microduino-RJ45&lt;br /&gt;
*Microduino-Core&lt;br /&gt;
*Microduino-FT232R&lt;br /&gt;
&lt;br /&gt;
Stack all modules and then connect the ethernet cable, as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:MicroduinoENCShow.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Program==&lt;br /&gt;
&lt;br /&gt;
Refer to ENCnetworkfive&lt;br /&gt;
&lt;br /&gt;
==Debug==&lt;br /&gt;
&lt;br /&gt;
Step 1：Download the EtherCard library and copy to your libraries fold of IDE, then restart IDE.&lt;br /&gt;
https://github.com/jcw/ethercard&lt;br /&gt;
&lt;br /&gt;
Step 2：Explain the program:&lt;br /&gt;
I’m going to show you a simple program that prints on serial connection browser‘s requests and answers with a simple HTML page. This program is useful to understand how to use HTTP functions and also to find out which informations a browser sends within the request (you’ll learn how to use those informations in a coming post).&lt;br /&gt;
&lt;br /&gt;
The complete sketch is available on GitHub’s repository, here is the most important code:&lt;br /&gt;
&lt;br /&gt;
  word len = ether.packetReceive();&lt;br /&gt;
  word pos = ether.packetLoop(len);&lt;br /&gt;
In the loop I save in a variable the return value of packetLoop() method: this value is the position, within the rx buffer, where browser’s request starts.&lt;br /&gt;
&lt;br /&gt;
  if(pos) {&lt;br /&gt;
 &lt;br /&gt;
    Serial.println(&amp;quot;---------- NEW PACKET ----------&amp;quot;);&lt;br /&gt;
    Serial.println((char *)Ethernet::buffer + pos);&lt;br /&gt;
    Serial.println(&amp;quot;--------------------------------&amp;quot;);&lt;br /&gt;
    Serial.println();&lt;br /&gt;
If pos is greater than zero, I really received a correct request and I can print it on serial port (buffer + pos is the position to start).&lt;br /&gt;
&lt;br /&gt;
    BufferFiller bfill = ether.tcpOffset();&lt;br /&gt;
To store the response I’m going to send to client’s browser, I use a BufferFiller object. This object inherits from Print class and its constructor gets as parameter the ethernet’s buffer address (tcpOffset) where the response has to be saved.&lt;br /&gt;
&lt;br /&gt;
    bfill.emit_p(PSTR(&amp;quot;HTTP/1.0 200 OK\r\n&amp;quot;&lt;br /&gt;
         &amp;quot;Content-Type: text/html\r\nPragma: no-cache\r\n\r\n&amp;quot;&lt;br /&gt;
         &amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;BasicServer Demo&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;));&lt;br /&gt;
With emit_p() method I can save data in the buffer: for this example I create a simple HTML page that shows BasicServer Demo text. To save RAM memory space, I use PSTR() macro that stores strings in the PROGRAM.&lt;br /&gt;
&lt;br /&gt;
    ether.httpServerReply(bfill.position());&lt;br /&gt;
At last, with httpServerReply() method, I send the response to the browser. This method needs, as a parameter, the number of characters to be sent. I can get the number of characters BufferFiller contains with its method position().&lt;br /&gt;
&lt;br /&gt;
Step 3：Compile the code and download it.&lt;br /&gt;
&lt;br /&gt;
Step 4: Check you ip address by the serial port. Input the Microduino's IP in browser...&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
the result should be like this:&lt;br /&gt;
&lt;br /&gt;
[[File:basicServerDemo.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
And on your serial monitor:&lt;br /&gt;
&lt;br /&gt;
[[File:basicServerSerialCutImage.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
You may ask why the browser sent two requests, one for the page “/” (that is the site’s homepage) and one for the image favicon.ico. That is the icon some sites show next to their address; here’s for example the icon from DangerousPrototypes:&lt;br /&gt;
[[File:yeelinkfavicon.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	</feed>