SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
Creating an Arduino Web
         Server
  From scratch hardware and software
Web Servers

Simpler than you think

A web server

  Listens for connections

  Parses requests

  Send back status messages and resource
  requested
Arduino Overview

Open source physical computing platform

Multiple form factors

Easy to code (C/C++ like) and use (USB)

Low cost

Great for prototypes, wearable computers,
sensor networks etc
Arduino Hardware
ATMega 8 bit microcontroller

32K program memory, 2K SRAM, 1K EEPROM

Dual purpose digital inputs and outputs

Analog inputs

High performance (16 MIPS)

Low power (3.3V or 5V)
Arduino IDE/Software

Open source

Cross platform (Mac, PC and Linux)

Alpha but stable

Simple to use

Includes documentation, help, samples and
library for common tasks
Arduino Shields

Hardware can be easily extended

Shields plug in on top of standard boards

Build your own or buy off the shelf (lots
available)

Stackable, can use more than one
Ethernet Shields

Several shields available

Two main types DHCP and non DHCP

Some configuration required

Non DHCP you set IP and MAC address in
code
IP and MAC address

Set IP address and MAC address in your
code

Need to be careful with duplicates

Set up like so:
Ethernet.begin(mac, ip);
Ethernet Library

Standard ethernet library

Includes Client and Server classes

Create server like so:
Server server(80);
server.begin();

Bare bones web server about 20 lines of
code and 5K compiled
HTTP Protocol


HyperText Transfer Protocol

Used by web servers to transfer web pages
to be displayed in your web browser

Connection (usually) on port 80
TCP Connections

TCP three way connection handshake

Client sends SYN with random number (A)

Server replies with SYN-ACK containing A+1
and random number (B)

Client replies with ACK containing B+1

Luckily ethernet library does this for you!
Connection Code

Create a client
Client client = server.available();

Connected
while (client.connected()
{
....
}
HTTP Requests

Start with request “GET index.html HTTP/1.1”

Optional headers “Accept-Language: en”

Empty line

Optional message body (POST and other
requests)
HTTP Request Hack


Standard GET request have request followed
by blank line

So just ignore what is requested and check
for blank line
Request Code
Read characters
char c = client.read();

If newline and last character was newline
if (c == 'n' && blankline) {
  ...
}
if (c == 'n') {
      blankline = true;
}
HTTP Response

Send back status line "HTTP/1.1 200 OK"

Send back content type "Content-Type: text/
html"

Send blank line

Send (HTML) content
Response Code

Send status and content type
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();

Send content
for (int i =0; i < nolines; i++) {
   client.println(content[i]);
}
Close Connections


Clear up after you
client.flush();
client.stop();
Arduiono Web Server
       Demo


Aruino IDE

Web browser

Weitere ähnliche Inhalte

Was ist angesagt?

Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopyayaria
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transportsEleanor McHugh
 
Network programming Using Python
Network programming Using PythonNetwork programming Using Python
Network programming Using PythonKarim Sonbol
 
Python Network Programming – Course Applications Guide
Python Network Programming – Course Applications GuidePython Network Programming – Course Applications Guide
Python Network Programming – Course Applications GuideMihai Catalin Teodosiu
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programmingAnung Ariwibowo
 
Socket programming
Socket programmingSocket programming
Socket programmingAnurag Tomar
 
Advanced Sockets Programming
Advanced Sockets ProgrammingAdvanced Sockets Programming
Advanced Sockets Programmingelliando dias
 
maXbox Starter 39 GEO Maps Tutorial
maXbox Starter 39 GEO Maps TutorialmaXbox Starter 39 GEO Maps Tutorial
maXbox Starter 39 GEO Maps TutorialMax Kleiner
 
Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Gene Leybzon
 
[4] 아두이노와 인터넷
[4] 아두이노와 인터넷[4] 아두이노와 인터넷
[4] 아두이노와 인터넷Chiwon Song
 
sbt-ethereum: a terminal for the world computer
sbt-ethereum: a terminal for the world computersbt-ethereum: a terminal for the world computer
sbt-ethereum: a terminal for the world computerSteve Waldman
 
Poker, packets, pipes and Python
Poker, packets, pipes and PythonPoker, packets, pipes and Python
Poker, packets, pipes and PythonRoger Barnes
 
Application Layer and Socket Programming
Application Layer and Socket ProgrammingApplication Layer and Socket Programming
Application Layer and Socket Programmingelliando dias
 
Opentalk at Large - StS 2005
Opentalk at Large - StS 2005Opentalk at Large - StS 2005
Opentalk at Large - StS 2005Martin Kobetic
 

Was ist angesagt? (20)

Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptop
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transports
 
Network programming Using Python
Network programming Using PythonNetwork programming Using Python
Network programming Using Python
 
Python Network Programming – Course Applications Guide
Python Network Programming – Course Applications GuidePython Network Programming – Course Applications Guide
Python Network Programming – Course Applications Guide
 
Whispered secrets
Whispered secretsWhispered secrets
Whispered secrets
 
Socket System Calls
Socket System CallsSocket System Calls
Socket System Calls
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
 
Socket programming
Socket programmingSocket programming
Socket programming
 
Ppt of socket
Ppt of socketPpt of socket
Ppt of socket
 
Advanced Sockets Programming
Advanced Sockets ProgrammingAdvanced Sockets Programming
Advanced Sockets Programming
 
maXbox Starter 39 GEO Maps Tutorial
maXbox Starter 39 GEO Maps TutorialmaXbox Starter 39 GEO Maps Tutorial
maXbox Starter 39 GEO Maps Tutorial
 
Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3
 
[4] 아두이노와 인터넷
[4] 아두이노와 인터넷[4] 아두이노와 인터넷
[4] 아두이노와 인터넷
 
sbt-ethereum: a terminal for the world computer
sbt-ethereum: a terminal for the world computersbt-ethereum: a terminal for the world computer
sbt-ethereum: a terminal for the world computer
 
Poker, packets, pipes and Python
Poker, packets, pipes and PythonPoker, packets, pipes and Python
Poker, packets, pipes and Python
 
Application Layer and Socket Programming
Application Layer and Socket ProgrammingApplication Layer and Socket Programming
Application Layer and Socket Programming
 
Introduction to Rust
Introduction to RustIntroduction to Rust
Introduction to Rust
 
iCloud keychain
iCloud keychainiCloud keychain
iCloud keychain
 
Opentalk at Large - StS 2005
Opentalk at Large - StS 2005Opentalk at Large - StS 2005
Opentalk at Large - StS 2005
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 

Ähnlich wie Create an Arduino Web Server

Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in javaAmol Gaikwad
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in JavaTushar B Kute
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 
Lan chat system
Lan chat systemLan chat system
Lan chat systemWipro
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developersWim Godden
 
Raspberry pi Part 23
Raspberry pi Part 23Raspberry pi Part 23
Raspberry pi Part 23Techvilla
 
Driver Configuration Webinar
Driver Configuration WebinarDriver Configuration Webinar
Driver Configuration WebinarAVEVA
 
Network Prog.ppt
Network Prog.pptNetwork Prog.ppt
Network Prog.pptEloOgardo
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket ProgrammingMousmi Pawar
 

Ähnlich wie Create an Arduino Web Server (20)

Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in java
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Sockets
Sockets Sockets
Sockets
 
6005679.ppt
6005679.ppt6005679.ppt
6005679.ppt
 
Lan chat system
Lan chat systemLan chat system
Lan chat system
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
 
03 sockets
03 sockets03 sockets
03 sockets
 
Raspberry pi Part 23
Raspberry pi Part 23Raspberry pi Part 23
Raspberry pi Part 23
 
java networking
 java networking java networking
java networking
 
Driver Configuration Webinar
Driver Configuration WebinarDriver Configuration Webinar
Driver Configuration Webinar
 
Java 1
Java 1Java 1
Java 1
 
Networking
NetworkingNetworking
Networking
 
Network Prog.ppt
Network Prog.pptNetwork Prog.ppt
Network Prog.ppt
 
Net Programming.ppt
Net Programming.pptNet Programming.ppt
Net Programming.ppt
 
class30.ppt
class30.pptclass30.ppt
class30.ppt
 
Osi model
Osi modelOsi model
Osi model
 
class28.ppt
class28.pptclass28.ppt
class28.ppt
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
 

Mehr von Justin Mclean

A Practical Guide to Connecting Hardware to Flex
A Practical Guide to Connecting Hardware to FlexA Practical Guide to Connecting Hardware to Flex
A Practical Guide to Connecting Hardware to FlexJustin Mclean
 
ColdFusion Security and Risk Management
ColdFusion Security and Risk ManagementColdFusion Security and Risk Management
ColdFusion Security and Risk ManagementJustin Mclean
 
Connecting RIAs and hardware together
Connecting RIAs and hardware togetherConnecting RIAs and hardware together
Connecting RIAs and hardware togetherJustin Mclean
 
ColdFusion Security and Risk Management
ColdFusion Security and Risk ManagementColdFusion Security and Risk Management
ColdFusion Security and Risk ManagementJustin Mclean
 
Connecting hardware to ColdFusion
Connecting hardware to ColdFusionConnecting hardware to ColdFusion
Connecting hardware to ColdFusionJustin Mclean
 
Connecting open source hardware to the web
Connecting open source hardware to the webConnecting open source hardware to the web
Connecting open source hardware to the webJustin Mclean
 
Putting your device in a browser or on the web
Putting your device in a browser or on the webPutting your device in a browser or on the web
Putting your device in a browser or on the webJustin Mclean
 
Connecting hardware up to ColdFusion
Connecting hardware up to ColdFusionConnecting hardware up to ColdFusion
Connecting hardware up to ColdFusionJustin Mclean
 
Connecting Hardware to Flex (360MAX)
Connecting Hardware to Flex (360MAX)Connecting Hardware to Flex (360MAX)
Connecting Hardware to Flex (360MAX)Justin Mclean
 
A practical guide to connecting hardware to Flex
A practical guide to connecting hardware to FlexA practical guide to connecting hardware to Flex
A practical guide to connecting hardware to FlexJustin Mclean
 

Mehr von Justin Mclean (11)

A Practical Guide to Connecting Hardware to Flex
A Practical Guide to Connecting Hardware to FlexA Practical Guide to Connecting Hardware to Flex
A Practical Guide to Connecting Hardware to Flex
 
ColdFusion Security and Risk Management
ColdFusion Security and Risk ManagementColdFusion Security and Risk Management
ColdFusion Security and Risk Management
 
Connecting RIAs and hardware together
Connecting RIAs and hardware togetherConnecting RIAs and hardware together
Connecting RIAs and hardware together
 
ColdFusion Security and Risk Management
ColdFusion Security and Risk ManagementColdFusion Security and Risk Management
ColdFusion Security and Risk Management
 
Connecting hardware to ColdFusion
Connecting hardware to ColdFusionConnecting hardware to ColdFusion
Connecting hardware to ColdFusion
 
Connecting open source hardware to the web
Connecting open source hardware to the webConnecting open source hardware to the web
Connecting open source hardware to the web
 
Putting your device in a browser or on the web
Putting your device in a browser or on the webPutting your device in a browser or on the web
Putting your device in a browser or on the web
 
Connecting hardware up to ColdFusion
Connecting hardware up to ColdFusionConnecting hardware up to ColdFusion
Connecting hardware up to ColdFusion
 
Edge Of The Web
Edge Of The WebEdge Of The Web
Edge Of The Web
 
Connecting Hardware to Flex (360MAX)
Connecting Hardware to Flex (360MAX)Connecting Hardware to Flex (360MAX)
Connecting Hardware to Flex (360MAX)
 
A practical guide to connecting hardware to Flex
A practical guide to connecting hardware to FlexA practical guide to connecting hardware to Flex
A practical guide to connecting hardware to Flex
 

Kürzlich hochgeladen

Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 

Kürzlich hochgeladen (20)

Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 

Create an Arduino Web Server

  • 1. Creating an Arduino Web Server From scratch hardware and software
  • 2. Web Servers Simpler than you think A web server Listens for connections Parses requests Send back status messages and resource requested
  • 3. Arduino Overview Open source physical computing platform Multiple form factors Easy to code (C/C++ like) and use (USB) Low cost Great for prototypes, wearable computers, sensor networks etc
  • 4. Arduino Hardware ATMega 8 bit microcontroller 32K program memory, 2K SRAM, 1K EEPROM Dual purpose digital inputs and outputs Analog inputs High performance (16 MIPS) Low power (3.3V or 5V)
  • 5. Arduino IDE/Software Open source Cross platform (Mac, PC and Linux) Alpha but stable Simple to use Includes documentation, help, samples and library for common tasks
  • 6. Arduino Shields Hardware can be easily extended Shields plug in on top of standard boards Build your own or buy off the shelf (lots available) Stackable, can use more than one
  • 7. Ethernet Shields Several shields available Two main types DHCP and non DHCP Some configuration required Non DHCP you set IP and MAC address in code
  • 8. IP and MAC address Set IP address and MAC address in your code Need to be careful with duplicates Set up like so: Ethernet.begin(mac, ip);
  • 9. Ethernet Library Standard ethernet library Includes Client and Server classes Create server like so: Server server(80); server.begin(); Bare bones web server about 20 lines of code and 5K compiled
  • 10. HTTP Protocol HyperText Transfer Protocol Used by web servers to transfer web pages to be displayed in your web browser Connection (usually) on port 80
  • 11. TCP Connections TCP three way connection handshake Client sends SYN with random number (A) Server replies with SYN-ACK containing A+1 and random number (B) Client replies with ACK containing B+1 Luckily ethernet library does this for you!
  • 12. Connection Code Create a client Client client = server.available(); Connected while (client.connected() { .... }
  • 13. HTTP Requests Start with request “GET index.html HTTP/1.1” Optional headers “Accept-Language: en” Empty line Optional message body (POST and other requests)
  • 14. HTTP Request Hack Standard GET request have request followed by blank line So just ignore what is requested and check for blank line
  • 15. Request Code Read characters char c = client.read(); If newline and last character was newline if (c == 'n' && blankline) { ... } if (c == 'n') { blankline = true; }
  • 16. HTTP Response Send back status line "HTTP/1.1 200 OK" Send back content type "Content-Type: text/ html" Send blank line Send (HTML) content
  • 17. Response Code Send status and content type client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); Send content for (int i =0; i < nolines; i++) { client.println(content[i]); }
  • 18. Close Connections Clear up after you client.flush(); client.stop();
  • 19. Arduiono Web Server Demo Aruino IDE Web browser