10
Arduino Ethernet Programming
In this
chapter, you will use an Ethernet shield to enable your Arduino to work over your
home network (see
Figure 10-1
).
Figure 10-1
Arduino with Ethernet
Ethernet Shields
When
buying an Ethernet shield,
you need to take a little care, as you need to use an
“official” shield based on the Wiznet chipset and
not
one of the cheaper but more difficult
to use unofficial boards based on the ENC28J60 Ethernet controller chip.
The Ethernet shields are quite power hungry, so you will also need a 9V or 12V power
supply rated at 1A or more. This supply will be attached to the Arduino power socket.
Communicating with Web Servers
Before looking at how the Arduino deals with communication between a browser and the
web server that it uses, you need some understanding of the HyperText Transfer Protocol
(HTTP) and the HyperText Markup Language (HTML).
HTTP
The HyperText Transport Protocol is the method by which
web browsers communicate
with a web server.
When you go to a page using a web browser, the browser sends a request to the server
hosting
that page, saying what it wants. What the browser
asks for may be simply the
contents of a page in HTML. The web server is always
listening for such requests, and
when it receives one, it processes it. In this simple case, processing the request just means
sending back HTML that you have specified in the Arduino sketch.
HTML
The HyperText Markup Language is a way of adding formatting to ordinary text so that it
looks good when the browser displays it. For example, the following code is HTML that
displays on a browser page as shown in
Figure 10-2
:
The HTML contains tags. Tags have a start and an end and usually contain other tags.
The start of a tag has a
Dostları ilə paylaş: