arduinoethernetw5100.pdf

22
8/13/2019 ArduinoEthernetW5100.pdf http://slidepdf.com/reader/full/arduinoethernetw5100pdf 1/22 Arduino Ethernet Shield

Upload: german-correa

Post on 04-Jun-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 1/22

Arduino Ethernet Shield

Page 2: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 2/22

Arduino Ethernet Shield

Arduino + Ethernet

Page 3: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 3/22

Twittering plant

Page 4: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 4/22

Capabilities

! Wiznet W5100 ethernet chip! Client! Server!

TCP! UDP! Four channels

Page 5: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 5/22

The Ethernet library

! All looks like a serial port

! Ethernet: initialise network!

Client: connect to a port on aserver, then read() and write()! Server: waits for a connectionon a port

Page 6: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 6/22

Ethernet limitations

! DHCP needs 3rd-party library! No DNS! DIY for high-level protocols

(no HTTP library, etc) - lots ofprint() statements! Library memory footprint

Page 7: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 7/22Practical 1: on the network

Page 8: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 8/22

Page 9: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 9/22Configuration

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);

Page 10: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 10/22Talking HTTP

Page 11: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 11/22Talking HTTP

$ curl -v http://www.example.com

Page 12: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 12/22Talking HTTP: the request

$ 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)

Page 13: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 13/22Talking HTTP: the request

$ 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: */*>

Page 14: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 14/22Talking HTTP: the response

$ 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

Page 15: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 15/22Talking HTTP: the document

$ 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>..........

Page 16: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 16/22The most important bits

> GET / HTTP/1.1> Host: www.example.com>< HTTP/1.1 200 OK

< Content-Type: text/html; charset=UTF-8<<HTML>..........

Page 17: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 17/22Practical 2: retrieving data

Page 18: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 18/22Practical 2: retrieving data

Page 19: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 19/22Web APIs

! It’s just HTTP! At least, the good ones are

Page 20: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 20/22Web API challenges

! HTTPS! Crypto (e.g. OAuth)! XML parsing!

JSON parsing! Large documents

Page 21: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 21/22Practical 3: serving data

Page 22: ArduinoEthernetW5100.pdf

8/13/2019 ArduinoEthernetW5100.pdf

http://slidepdf.com/reader/full/arduinoethernetw5100pdf 22/22P ti l 3 i g d t