Wiznet makers

junlee0615

Published August 28, 2025 ©

1 UCC

10 VAR

0 Contests

0 Followers

0 Following

Original Link

Arduino Webserver with W5500 Shield

Build a nostalgic Arduino webserver using the WIZnet W5500 shield and a DS18B20 sensor to serve live temperature over HTTP.

COMPONENTS Hardware components

Arduino - Arduino Ethernet Shield 2

x 1


Arduino - Arduino UNO

x 1


DFRobot - Gravity: DS18B20 Temperature Sensor (Arduino Compatible)

x 1

Software Apps and online services

Arduino - Arduino IDE

x 1


PROJECT DESCRIPTION

Arduino W5500 Webserver with DS18B20 — Simple Hardware TCP/IP Temperature Page

Introduction

This project revives a classic: an Arduino webserver that displays live temperature readings in a browser. Using the WIZnet W5500 Ethernet shield for hardware TCP/IP and a DS18B20 temperature sensor on the OneWire bus, we serve a minimal HTML page that anyone on the local network can view.

WIZnet Product Integration

The W5500 handles TCP/IP and Ethernet packet processing in hardware, minimizing MCU overhead. The shield connects to Arduino over SPI (ICSP header), letting the sketch focus on sensor reading and string formatting. A simple EthernetServer on port 80 responds to HTTP requests and prints the current temperature.

Technical Implementation

Wiring

DS18B20 → Arduino

DQ (data)D2 (OneWire bus)

VDD5V (or 3.3V per sensor spec)

GNDGND

Pull‑up: 4.7 kΩ between DQ and VDD

W5500 Shield

Stacked on Arduino; uses SPI via ICSP.

Default chip‑selects (for reference): D10 for Ethernet, D4 for SD (SD unused here).

Generated image

Network Setup

Static IP (in sketch): Ethernet.begin(mac, ip);

Optional DHCP: replace with Ethernet.begin(mac); to obtain an address from your router.

Access from a browser at http://<board_ip>/.

Sketch (Complete)

 
#include <Ethernet.h> // Library for W5500-based Ethernet shield
 
Serial.begin(9600); // Start the serial communication for debugging
 
// Set up the Ethernet shield with a fixed MAC address and IP address
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // MAC address
IPAddress ip(192, 168, 1, 177); // Local IP address (adjust as needed for your network)
 
// Start the Ethernet and the server
Ethernet.begin(mac, ip);
server.begin();
Serial.print("Server is at ");
Serial.println(Ethernet.localIP());
 
// Start the temperature sensor
sensors.begin();
}
 
void loop() {
// Check for incoming client connections
EthernetClient client = server.available();
if (client) {
Serial.println("New client connected");
 
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
 
// If the request is complete (double newline), send the response
if (c == '\n' && currentLineIsBlank) {
sensors.requestTemperatures(); // Request temperature
float temperature = sensors.getTempCByIndex(0); // Get temperature in Celsius
 
// Send the HTTP response headers
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // Connection will close after this response
client.println();
 
// Send the HTML content with temperature
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<h1>Temperature Monitor</h1>");
client.print("<p>Temperature: ");
client.print(temperature);
client.println(" °C</p>");
client.println("</html>");
break;
}
 
if (c == '\n') {
currentLineIsBlank = true;
} else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
 
// Close the connection with the client
client.stop();
Serial.println("Client disconnected");
}
}

Core Features and Behavior

Static IP webserver on port 80 serving a minimal HTML page.

Live temperature read from DS18B20 on each HTTP request.

Connection is closed after responding, keeping the server simple and robust.

Code Analysis

EthernetServer server(80) creates the TCP listener; server.available() yields a client when connected.

A double newline (\r\n\r\n) marks the end of the HTTP request headers; the code checks for a blank line using currentLineIsBlank.

Before responding, sensors.requestTemperatures() triggers a OneWire conversion; getTempCByIndex(0) fetches the first sensor’s reading.

Response includes essential HTTP headers and a minimal HTML body.

Applications and Use Cases

Lab dashboards and classroom demos.

Local environment monitoring on wired networks.

Embedding into larger projects as a simple status page.

Troubleshooting & Tips

IP/Subnet: Ensure the static IP matches your LAN subnet and isn’t already in use.

DHCP: If preferred, switch to DHCP (router must support it) and print the assigned IP via Ethernet.localIP().

Sensor wiring: DS18B20 requires a 4.7 kΩ pull‑up on DQ; noisy/long cables may need careful routing.

Mega compatibility: When using Arduino Mega, keep pin 53 as OUTPUT for SPI to work.

SD coexistence: If the shield’s SD is unused, keep CS (D4) HIGH. If used, only one device on SPI may be active at a time.

Conclusion

Using the WIZnet W5500 Ethernet shield and a DS18B20 sensor, this project demonstrates a clean, nostalgic Arduino webserver pattern. With hardware TCP/IP offload and a tiny HTML page, it’s a perfect starting point for wired IoT dashboards, status pages, or classroom exercises.

Documents
Comments Write