Hallo zusammen,
nachdem ich immer noch kein Schritt weiter gekommen bin, fange ich nun an das Shield auf Funktion zu prüfen und möchte einen "einfachen" Netzzugriff über mein Netzwerk realisieren.
Im Internet kursieren so manche Verdrahtungsanweisungen zum Thema Mega2560 + EthernetShield. Ich habe mich daher auf diese
hier bezogen und den Aufbau mal nachgebaut. Die 4 Pinns sind nach hinten weggebogen und haben keine Verbindung zum Mega. Bei dem Code handelt es sich um den BeispielCode "Webclient". Da ich jedoch ohne DHCP arbeite, hab ich ihm die IP-Adresse statisch zugewiesen. Meine Netzwerkkarte am PC ist wie im "ipconfig /all" Bild zu sehen konfiguriert.
Und ... es klappt nix. Ich kann das Shield noch nichtmal anpingen nachdem ich die IP-Konfiguration vorgegeben habe. Jemand noch eine Idee wie ich irgendwie das Teil auf Funktion prüfen kann?
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(173,194,44,87); // Google
IPAddress ip(192,168,178, 15);
IPAddress gateway(192,168,178, 1);
IPAddress subnet(255, 255, 255, 0);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Ethernet.begin(mac, ip,gateway, gateway); //Kein DHCP und daher hab ich die IP's vorgegeben
// start the Ethernet connection:
// if (Ethernet.begin(mac) == 0) {
// Serial.println("Failed to configure Ethernet using DHCP");
// // no point in carrying on, so do nothing forevermore:
// for(;;)
// ;
// }
// give the Ethernet shield a second to initialize:
delay(10000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;;)
;
}
}