I found a great step by step guide online that explains how to configure the Arduino ethernet shield to become a web hosting server. This is the next step up from using terminal. Now, some HTML code is embedded in the code. The Arduino gets a generated IP from a DHCP request. The IP can then be pasted into a modern web browser in which case, if the connection is successful the http will display “HTTP/1.1 200 OK” and then proceed to load the HTML inside the code. However, numerous attempts to load the page have failed.
A number of things could have gone wrong.
1. The router doesn’t have any open spots. The router can only serve up to 254 unique IP’s.
2. The newschool network blocks attempts to access IP’s directly/had security measures.
3. The Arduino ethernet shield should be accessing the HTML through the mini SD card slot.
There could be a lot of things going on in the backend stuff with establishing a working, communicating network that I don’t fully understand. Ultimately, there is more to figure out here and I think there is a lot of potential.
/*Author: W.A. Smith, http://startingelectronics.com
————————————————————–*/
#include <SPI.h>
#include <Ethernet.h>
// MAC address from Ethernet shield sticker under board
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x2A, 0xFB };
IPAddress ip(10, 1, 217, 254);// IP address, may need to change depending on network
IPAddress gateway(10,1,217,1);// Added gateway address just incase
IPAddress subnet(255,255,255,0); //Added subnet as well
EthernetServer server(23); // create a server at port 80, or port 23(default)
void setup()
{
Ethernet.begin(mac, ip, gateway, subnet); // initialize Ethernet device
server.begin(); // start to listen for clients
}
void loop()
{
EthernetClient client = server.available(); // try to get client
if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
// last line of client request is blank and ends with \n
// respond to client only after last line received
if (c == ‘\n’ && currentLineIsBlank) {
// send a standard http response header
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“Connection: close”);
client.println();
// send web page
client.println(“<!DOCTYPE html>”);
client.println(“<html>”);
client.println(“<head>”);
client.println(“<title>Arduino Web Page Test</title>”);
client.println(“</head>”);
client.println(“<body>”);
client.println(“<h1>Hello from Arduino!</h1>”);
client.println(“<p>A web page from the Arduino server</p>”);
client.println(“</body>”);
client.println(“</html>”);
break;
}
// every line of text received from the client ends with \r\n
if (c == ‘\n’) {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
}
else if (c != ‘\r’) {
// a text character was received from client
currentLineIsBlank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)
}