Downloading a webpage from internet using Arduino

Downloading a webpage from internet using arduino via Ethernet Shield

Downloading a webpage from the internet using Arduino via Ethernet Shield

Connections:

Just Connect Arduino Ethernet Shield on the top of Arduino or Arduino Mega, and connect Ethernet cable on which internet is accessible, and use the code given below to connect to the Internet using Arduino.

Downloading a webpage from internet using arduino via Ethernet Shield

Downloading a webpage from internet using arduino via Ethernet Shield

 

Code for Arduino:

In this program, we are downloading a test page from galaxysofts.com, which shows Date in two different formats.

#include <SPI.h>
#include <Ethernet.h>byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
char serverName[] = "www.comm2excel.com";
EthernetClient client;

void setup() 
{

Serial.begin(9600);

if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");

while(true);
}

delay(1000);
Serial.println("connecting...");

if (client.connect(serverName, 80)) {
Serial.println("connected");

client.println("GET http://www.galaxysofts.com/uploads/test.php HTTP/1.0");
client.println();
} 
else {

Serial.println("connection failed");
}
}

void loop()
{

if (client.available()) {
char c = client.read();
Serial.print(c);
}

if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();

while(true);
}
}

 

Results:

Downloading a webpage from internet using arduino via Ethernet Shield

 

Video on downloading a webpage from the internet (www) using Arduino via Ethernet Shield:

Downloads:

* This code was earlier posted on comm2excel.com, which is closed and now we are transferring data to galaxysofts.com.

 

Related Links:

Leave a Reply

Your email address will not be published.