Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Arduino Networking

You're reading from   Arduino Networking Connect your projects to the Web using the Arduino Ethernet library

Arrow left icon
Product type Paperback
Published in Aug 2014
Publisher
ISBN-13 9781783986866
Length 118 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Marco Schwartz Marco Schwartz
Author Profile Icon Marco Schwartz
Marco Schwartz
Arrow right icon
View More author details
Toc

Creating a web server on Arduino

For the rest of this chapter, we are going to take another approach. We are still going to make the Arduino with the Ethernet Shield work as an independent system, but this time we are even going to create a web server on the Arduino board. This is actually similar to the project we saw in the Chapter 2, Sending Data to a Web Server, but this time it is the Arduino board itself that will display the data as it is measured.

The sketch for this part starts by including the right libraries, as shown in the following code:

#include "DHT.h"
#include <Ethernet.h>
#include <SPI.h>

Define the pin and the type of the sensor in the following manner:

#define DHTPIN 7
#define DHTTYPE DHT11

Also, you have to define the MAC address of your Ethernet shield as usual, as shown in the following line of code:

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xFE, 0x40 };

We will also define a default IP address in case the DHCP fails, as shown in the following line:

IPAddress...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime