SlideShare a Scribd company logo
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

More Related Content

What's hot (19)

DOCX
Chatting dengan beberapa pc laptop
yayaria
 
PDF
Encrypt all transports
Eleanor McHugh
 
PDF
Network programming Using Python
Karim Sonbol
 
PDF
Whispered secrets
Eleanor McHugh
 
PPT
Socket System Calls
Avinash Varma Kalidindi
 
PDF
ikh331-06-distributed-programming
Anung Ariwibowo
 
PPTX
Socket programming
Anurag Tomar
 
PPT
Ppt of socket
Amandeep Kaur
 
PDF
Advanced Sockets Programming
elliando dias
 
PDF
maXbox Starter 39 GEO Maps Tutorial
Max Kleiner
 
PPTX
Hands on with Smart Contracts session #3
Gene Leybzon
 
PPTX
[4] 아두이노와 인터넷
Chiwon Song
 
PDF
sbt-ethereum: a terminal for the world computer
Steve Waldman
 
PDF
Poker, packets, pipes and Python
Roger Barnes
 
PPT
Application Layer and Socket Programming
elliando dias
 
PDF
Introduction to Rust
Jean Carlo Machado
 
PDF
iCloud keychain
Alexey Troshichev
 
PPT
Opentalk at Large - StS 2005
Martin Kobetic
 
PDF
Socket Programming
elliando dias
 
Chatting dengan beberapa pc laptop
yayaria
 
Encrypt all transports
Eleanor McHugh
 
Network programming Using Python
Karim Sonbol
 
Whispered secrets
Eleanor McHugh
 
Socket System Calls
Avinash Varma Kalidindi
 
ikh331-06-distributed-programming
Anung Ariwibowo
 
Socket programming
Anurag Tomar
 
Ppt of socket
Amandeep Kaur
 
Advanced Sockets Programming
elliando dias
 
maXbox Starter 39 GEO Maps Tutorial
Max Kleiner
 
Hands on with Smart Contracts session #3
Gene Leybzon
 
[4] 아두이노와 인터넷
Chiwon Song
 
sbt-ethereum: a terminal for the world computer
Steve Waldman
 
Poker, packets, pipes and Python
Roger Barnes
 
Application Layer and Socket Programming
elliando dias
 
Introduction to Rust
Jean Carlo Machado
 
iCloud keychain
Alexey Troshichev
 
Opentalk at Large - StS 2005
Martin Kobetic
 
Socket Programming
elliando dias
 

Similar to Creating an Arduino Web Server from scratch hardware and software (20)

PDF
programmer avec Arduino
mohamednacim
 
PDF
Ethernet Shield
Tinker London
 
PDF
Ethernet Shield
Tinker
 
DOCX
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
alfredacavx97
 
DOCX
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
VannaSchrader3
 
PDF
Web server
Sujeet Kumar Singh
 
PDF
maXbox_Arduino_Pascal_Magazine
Max Kleiner
 
PPT
Http
Eri Alam
 
PDF
maXbox Arduino Tutorial
Max Kleiner
 
PPT
Web Services 2009
Cathie101
 
PPT
Web Services 2009
Cathie101
 
PDF
Edge Of The Web
Justin Mclean
 
DOC
T2
Mo Ch
 
PDF
Build a Micro HTTP Server for Embedded System
Jian-Hong Pan
 
PDF
Micro HTTP Server for Embedded
exeri0n1
 
PDF
Maxbox starter18
Max Kleiner
 
PPT
The world wide web science and technology.00000002ppt
michaelcana021092
 
PPT
The world wide web.00000000000000354748ppt
michaelcana021092
 
PPT
Web
Mayank Vora
 
programmer avec Arduino
mohamednacim
 
Ethernet Shield
Tinker London
 
Ethernet Shield
Tinker
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
alfredacavx97
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
VannaSchrader3
 
Web server
Sujeet Kumar Singh
 
maXbox_Arduino_Pascal_Magazine
Max Kleiner
 
Http
Eri Alam
 
maXbox Arduino Tutorial
Max Kleiner
 
Web Services 2009
Cathie101
 
Web Services 2009
Cathie101
 
Edge Of The Web
Justin Mclean
 
T2
Mo Ch
 
Build a Micro HTTP Server for Embedded System
Jian-Hong Pan
 
Micro HTTP Server for Embedded
exeri0n1
 
Maxbox starter18
Max Kleiner
 
The world wide web science and technology.00000002ppt
michaelcana021092
 
The world wide web.00000000000000354748ppt
michaelcana021092
 
Ad

More from Justin Mclean (10)

PDF
A Practical Guide to Connecting Hardware to Flex
Justin Mclean
 
PDF
ColdFusion Security and Risk Management
Justin Mclean
 
PDF
Connecting RIAs and hardware together
Justin Mclean
 
PDF
ColdFusion Security and Risk Management
Justin Mclean
 
PDF
Connecting hardware to ColdFusion
Justin Mclean
 
PDF
Connecting open source hardware to the web
Justin Mclean
 
PDF
Putting your device in a browser or on the web
Justin Mclean
 
PDF
Connecting hardware up to ColdFusion
Justin Mclean
 
PDF
Connecting Hardware to Flex (360MAX)
Justin Mclean
 
PDF
A practical guide to connecting hardware to Flex
Justin Mclean
 
A Practical Guide to Connecting Hardware to Flex
Justin Mclean
 
ColdFusion Security and Risk Management
Justin Mclean
 
Connecting RIAs and hardware together
Justin Mclean
 
ColdFusion Security and Risk Management
Justin Mclean
 
Connecting hardware to ColdFusion
Justin Mclean
 
Connecting open source hardware to the web
Justin Mclean
 
Putting your device in a browser or on the web
Justin Mclean
 
Connecting hardware up to ColdFusion
Justin Mclean
 
Connecting Hardware to Flex (360MAX)
Justin Mclean
 
A practical guide to connecting hardware to Flex
Justin Mclean
 
Ad

Recently uploaded (20)

PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PDF
Next level data operations using Power Automate magic
Andries den Haan
 
PDF
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PPTX
The birth and death of Stars - earth and life science
rizellemarieastrolo
 
PDF
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
PPTX
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
PPTX
Reimaginando la Ciberdefensa: De Copilots a Redes de Agentes
Cristian Garcia G.
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
PPTX
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PDF
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
Next level data operations using Power Automate magic
Andries den Haan
 
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
The birth and death of Stars - earth and life science
rizellemarieastrolo
 
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
Reimaginando la Ciberdefensa: De Copilots a Redes de Agentes
Cristian Garcia G.
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Practical Applications of AI in Local Government
OnBoard
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
Kubernetes - Architecture & Components.pdf
geethak285
 

Creating an Arduino Web Server from scratch hardware and software

  • 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