I have an Arduino Uno and a W5100 Ethernet Shield. I am trying to post some data from the Arduino board to the WAMP server running on my computer. I do not have a router so I have directly connected my Ethernet shield stacked onto the Arduino Uno to the laptop's Ethernet port via an Ethernet cable. I have also assigned the Ethernet connection a static IP address 192.168.0.1 and my localhost page opens when I put this address in my browser.
In my Arduino sketch I have assigned the Arduino shield an IP address 192.168.0.4, i.e. on the same IP segment. When I try to do client.connect to the server (192.168.0.1), i.e. localhost, I get "Connection failed".
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0x6F, 0xED };
IPAddress ip(192,168,0,4);
byte server[]={192,168,0,1};
int value=9;
EthernetClient client;
void setup() {
// Serial.begin starts the serial connection between computer and Arduino
Serial.begin(9600);
// start the Ethernet connection
Ethernet.begin(mac,ip);
}
void loop() {
// Connect to the server (your computer or web page)
if (client.connect(server, 80)) {
Serial.println("Connecting...");
client.print("GET /Ethernet/getData.php?"); // This
client.print("value="); // This
client.print(value); // And this is what we did in the testing section above. We are making a GET request just like we would from our browser but now with live data from the sensor
client.println(" HTTP/1.1"); // Part of the GET request
client.println("Host: 192.168.0.1");
client.println("Connection: close");
client.println(); // Empty line
client.println(); // Empty line
client.stop(); // Closing connection to server
}
else {
// If Arduino can't connect to the server (your computer or web page)
Serial.println("--> connection failed\n");
}
delay(10000);
}
Now when I upload the sketch onto the board and run the serial monitor, I get this output:
My Ethernet connection detail screenshot is as follows:
Please tell me any changes that I must make and also are there any WAMP settings which I should change to allow the connection to get established?
Please consider the fact that I don't have a router anywhere in this connection - just my laptop and Ethernet shield connection.