Hi everyone, I recently acquired a ENC28J60 module on ebay (3 €, not having the budget for official shield is 30 €)
I download the required library (http://www.geeetech.com/wiki/index.php/Arduino_ENC28J60_Ethernet_Module)
I tested the program WebServerSimple, having set the IP as: 192.168.0.3
I send it and I test, I have my page that appears.
Now, I have on my laptop at 192.168.0.2 web server (apache2 php5 mysql ...)
with my page in the / test / index.php
I open the WebClient example, I set the ip's, I send, and i have one error :
connecting...
connection failed
disconnecting.
#include <Ethernet.h>
byte mac[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
byte ip[] = { 192, 168, 0, 3 };
Server server(80);
void setup() {
Ethernet.begin(mac, ip);
server.begin();
}
void loop() {
Client client = server.available();
if (client) {
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n' && current_line_is_blank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("Analog input 0 = <b>");
client.print(analogRead(0));
client.println("</b>
");
client.print("millis() = <b>");
client.println(millis());
client.println("</b>
");
break;
}
if (c == '\n') {
current_line_is_blank = true;
} else if (c != '\r') {
current_line_is_blank = false;
}
}
}
delay(1);
client.stop();
}
}
So I start wiresharks to see what is happening on the network:
when the arduino is web server, everything works fine:
http://www.hostingpics.net/viewer.php?id=125396wiresharkarduinoServer1.png
when the Arduino is a client does not work:
http://www.hostingpics.net/viewer.php?id=955310wiresharkarduinoClient.png
I do not know very well how the packets, and I would like to say to me why its not working in one direction, while in the other it works ...
Thanks everyone.
Timiti29
PS: I use arduino mega 2560