Arduino Ethernet Shield
Arduino + Ethernet
Twittering plant
★Wiznet W5100 ethernet chip
★Client
★Server
★TCP
★UDP
★Four channels



Capabilities
★All looks like a serial port


★Ethernet: initialise network
★Client: connect to a port on a
server, then read() and writ...
★DHCP needs 3rd-party library
★No DNS
★DIY for high-level protocols
(no HTTP library, etc) - lots of
print() statements
★L...
Practical 1: on the network
Example file:
         ChatServer



Practical 1: on the network
byte   mac[] = { 0xDE,0xAD,0xBE,0xEF,0xFE,
0xED   };
byte   ip[] = { 10, 0, 0, 177 };
byte   gateway[] = { 10, 0, 0, 1 };
...
Talking HTTP
$ curl -v http://www.example.com




Talking HTTP
$ curl -v http://www.example.com
* About to connect() to www.example.com port 80 (#0)
*   Trying 208.77.188.166... connect...
$   curl -v http://www.example.com
*   About to connect() to www.example.com port 80 (#0)
*     Trying 208.77.188.166... c...
$   curl -v http://www.example.com
*   About to connect() to www.example.com port 80 (#0)
*     Trying 208.77.188.166... c...
$ curl -v http://www.example.com
* About to connect() to www.example.com port 80 (#0)
*   Trying 208.77.188.166... connect...
> GET / HTTP/1.1
> Host: www.example.com
>
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
<
<HTML>
..........
...
Practical 2: retrieving data
Example file:
         WebClient



Practical 2: retrieving data
★It’s just HTTP
★At least, the good ones are




Web APIs
★HTTPS
★Crypto (e.g. OAuth)
★XML parsing
★JSON parsing
★Large documents




Web API challenges
Practical 3: serving data
Example file:
         WebServer



Practical 3: serving data
Upcoming SlideShare
Loading in …5
×

Ethernet Shield

2,406 views

Published on

Part of Tinker.it!'s Internet of Things master class at dconstruct 9, covering networking using the Arduino ethernet shield.

Published in: Technology, Business
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total views
2,406
On SlideShare
0
From Embeds
0
Number of Embeds
19
Actions
Shares
0
Downloads
63
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

Ethernet Shield

  1. 1. Arduino Ethernet Shield
  2. 2. Arduino + Ethernet
  3. 3. Twittering plant
  4. 4. ★Wiznet W5100 ethernet chip ★Client ★Server ★TCP ★UDP ★Four channels Capabilities
  5. 5. ★All looks like a serial port ★Ethernet: initialise network ★Client: connect to a port on a server, then read() and write() ★Server: waits for a connection on a port The Ethernet library
  6. 6. ★DHCP needs 3rd-party library ★No DNS ★DIY for high-level protocols (no HTTP library, etc) - lots of print() statements ★Library memory footprint Ethernet limitations
  7. 7. Practical 1: on the network
  8. 8. Example file: ChatServer Practical 1: on the network
  9. 9. byte mac[] = { 0xDE,0xAD,0xBE,0xEF,0xFE, 0xED }; byte ip[] = { 10, 0, 0, 177 }; byte gateway[] = { 10, 0, 0, 1 }; byte subnet[] = { 255, 255, 0, 0 }; ... Ethernet.begin(mac,ip,gateway,subnet); Configuration
  10. 10. Talking HTTP
  11. 11. $ curl -v http://www.example.com Talking HTTP
  12. 12. $ curl -v http://www.example.com * About to connect() to www.example.com port 80 (#0) * Trying 208.77.188.166... connected * Connected to www.example.com (208.77.188.166) port 80 (#0) Talking HTTP: the request
  13. 13. $ curl -v http://www.example.com * About to connect() to www.example.com port 80 (#0) * Trying 208.77.188.166... connected * Connected to www.example.com (208.77.188.166) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.16.3 > Host: www.example.com > Accept: */* > Talking HTTP: the request
  14. 14. $ curl -v http://www.example.com * About to connect() to www.example.com port 80 (#0) * Trying 208.77.188.166... connected * Connected to www.example.com (208.77.188.166) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.16.3 > Host: www.example.com > Accept: */* > < HTTP/1.1 200 OK < Date: Sun, 16 Aug 2009 16:05:42 GMT < Server: Apache/2.2.3 (Red Hat) < Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT < ETag: "b80f4-1b6-80bfd280" < Accept-Ranges: bytes < Content-Length: 438 < Connection: close < Content-Type: text/html; charset=UTF-8 Talking HTTP: the response
  15. 15. $ curl -v http://www.example.com * About to connect() to www.example.com port 80 (#0) * Trying 208.77.188.166... connected * Connected to www.example.com (208.77.188.166) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.16.3 > Host: www.example.com > Accept: */* > < HTTP/1.1 200 OK < Date: Sun, 16 Aug 2009 16:05:42 GMT < Server: Apache/2.2.3 (Red Hat) < Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT < ETag: "b80f4-1b6-80bfd280" < Accept-Ranges: bytes < Content-Length: 438 < Connection: close < Content-Type: text/html; charset=UTF-8 < <HTML> .......... Talking HTTP: the document
  16. 16. > GET / HTTP/1.1 > Host: www.example.com > < HTTP/1.1 200 OK < Content-Type: text/html; charset=UTF-8 < <HTML> .......... The most important bits
  17. 17. Practical 2: retrieving data
  18. 18. Example file: WebClient Practical 2: retrieving data
  19. 19. ★It’s just HTTP ★At least, the good ones are Web APIs
  20. 20. ★HTTPS ★Crypto (e.g. OAuth) ★XML parsing ★JSON parsing ★Large documents Web API challenges
  21. 21. Practical 3: serving data
  22. 22. Example file: WebServer Practical 3: serving data

×