Arduino Atmega 168 & Arduino Ethernet Shield

Hello ! i’ve got a big problem.I have an Arduino Duemilanove 168 & an Ethernet Shield.I want do an example from library but i don’t figure out how to make it work.I have connected my ethernet shield directly to ethernet cable and nothing and after that i connect it to my laptop and nothing.I have a switch with all plugs for ethernet,for my laptop and for my ethernet shield.Please help me and sorry for my grammatical errors(i’m from RO).Here is my code:

#include <Ethernet.h>

byte mac = { 0x00, 0x54, 0x7c, 0x77, 0x89, 0x1B }; my mac
byte ip = { 89,68,33,125 }; // ip pc
byte server = { 209,85,135,147 }; // ip google

Client client(server, 80);

void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);

delay(1000);

Serial.println(“Se conecteaza sau nu…”);

if (client.connect()) {
Serial.println("<< CONECTAT >> ");
client.println(“GET /search?q=arduino HTTP/1.0”);
client.println();
} else {
Serial.println(“Conexiune Frecata…”);
}
}

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

if (!client.connected()) {
Serial.println();
Serial.println(“DECONECTAT…”);
client.stop();
for(;:wink:
;
}
}

Please help me sombody !!

Did you open the serial monitor to see the result which is sent to the serial interface?

Please check on your network if you arduino board is available. Use the command "Ping". And also check with ping if the external server (google) ist reachable.

byte ip[] = { 89,68,33,125 }; // ip pc

This should be an unique ip address for the arduino and not the ip of you pc. Usually I use an internal, private ip address for the arduino board, i.e 10.0.0.10 or 192.168.1.10

it's doesn't work !! i have unpluged de ethernet from pc and i put ethernet shield connected to my pc.i have modified the ip but nothing happens .please check my ping: Here it's my ping when ethernet shield it's unpluged. Windows IP Configuration

Ethernet adapter Local Area Connection:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :

Wireless LAN adapter Wireless Network Connection:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :

Tunnel adapter isatap.{9178B6CE-9F54-4D82-A075-7D69A13A90E0}:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :

Tunnel adapter Local Area Connection* 12:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :

Tunnel adapter isatap.{4227AE81-FC79-438D-AAD1-879D69C1517A}:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :

Here it's ethernet shield connected to my pc:

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::4026:993d:94dd:9de4%22 Autoconfiguration IPv4 Address. . : 169.254.157.228 Subnet Mask . . . . . . . . . . . : 255.255.0.0 Default Gateway . . . . . . . . . :

Wireless LAN adapter Wireless Network Connection:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :

Tunnel adapter isatap.{9178B6CE-9F54-4D82-A075-7D69A13A90E0}:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :

Tunnel adapter Local Area Connection* 12:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :

Tunnel adapter isatap.{4227AE81-FC79-438D-AAD1-879D69C1517A}:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :

C:\Users\Alpha Black>

So that you can access internt (google ip), you will must a gateway.

Is your ethernet cable a cross? For connect directly in your laptop?!

my cable is directly from my laptop to ethernet shield.but i want to connect the to a switch.in switch i have plug in my ethernet,my laptop and my ethernet shield.

it's posible to modify the cable to make it crossover or something like that?

I have to wonder why your laptop is using a zero-configuration address… Is the switch connected to anything other than your computer and ethernet shield?

Otherwise, you are probably running the wrong example. Try it with the ethernet server example. Change it like so:

/*

  • Web Server
  • A simple web server that shows the value of the analog input pins.
    */

#include <Ethernet.h>

byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip = { 169,254,157,229 };

Server server(80);

void setup()
{
Ethernet.begin(mac, ip);
server.begin();
}

void loop()
{
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we’ve gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == ‘\n’ && current_line_is_blank) {
// send a standard http response header
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println();

// output the value of each analog input pin
for (int i = 0; i < 6; i++) {
client.print("analog input “);
client.print(i);
client.print(” is “);
client.print(analogRead(i));
client.println(”
");
}
break;
}
if (c == ‘\n’) {
// we’re starting a new line
current_line_is_blank = true;
} else if (c != ‘\r’) {
// we’ve gotten a character on the current line
current_line_is_blank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}

program your arduino, connect your computer and the ethernet shield to the switch. Ensure that the link LEDs are lit on your switch (if you have them) and on the arduino. If they aren’t, press the reset button on the arduino/ethernet shield to retry.

Once they are lit, open your browser on your computer and type this in:

http://169.254.157.229/

You should see a simple web page from the arduino.

it's not working !! what i'm doing wrong?

what should i do?

Are you connecting the ethernet shield to your pc or to the switch?

As they need to have their own cat5 cable to the switch/router. So one to your pc then another one to the ethernet shield.

i’m connecting the ethernet shield to switch where is connected and my laptop.i’ve unpluged the switch and plug ethernet shield directly to the computer and nothing happens.

've unpluged the switch and plug ethernet shield directly to the computer and nothing happens.

If you connect the ethernet shield directly with the pc then you need to use a cross over cable. I suggest to use an ethernet switch or ethernet hub.

It looks like you have a networking problem and not an arduino problem. >:( Please try to connect a second computer to your network and then ping this computer. If it doesn't work you have to solve this networking problem first.

Generally it is pretty easy to run the ethernet shield on a working network. For the first test you should always use the sample sketches from the arduino website.