Pages: [1]   Go Down
Author Topic: Ethernet Shield...how to make it talk  (Read 392 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have just bought an Arduino Uno and an Arduino Ethernet Shield (both genuine Arduinos, bought from Element 14 here in Australia). Everything is working great, except that I cannot get any action on the Ethernet port.
I am using the environment version 1.03.
I have tried most of the example sketches.
I have added pin settings for 4 and 10 (not sure if this is needed):
int pin10 = 10;
int pin4 = 4;

void setup() {
  pinMode(pin4, OUTPUT);
  digitalWrite(pin4, HIGH);
  pinMode(pin10, OUTPUT);
  digitalWrite(pin10, LOW);

I have entered the mac address for the Ethernet shield (there is a sticker with the 12-digit code).
I have tried different Ethernet addresses.
I am connecting to my laptop PCs (ASUS machines running Windows 7 SP1).
I have checked that I can ping through the ports on those machines.
I have installed Telnet both server and client on both laptops.
I have some programming education and experience, but I am not a professional programmer or IT/ Ethernet expert.
I have written some software that operate I/O, analogue and digital, all working great.

The Ethernet port refuses to co-operate.

On the Ethernet shield, the Rx LED flashes a fair bit. The Tx LED flashes during connection and configuration, but is always dark during executing any program / sketch.

Am I missing a setting in the code somewhere?
Code example, based on the library:
================================================
/*
Chat  Server

 A simple server that distributes any incoming messages to all
connected clients.  To use telnet to  your device's IP address and type.
You can see the client's input in the serial monitor as well.
Using an Arduino Wiznet Ethernet shield.
 
 Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe

 */

#include <SPI.h>
#include <Ethernet.h>
//#include <arduino.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[] = {
  0x90, 0xA2, 0xDA, 0x0D, 0xB0, 0x72 };
IPAddress ip(192,168,1, 177);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255, 0, 0);


// telnet defaults to port 23
EthernetServer server(23);
boolean alreadyConnected = false; // whether or not the client was connected previously
int pin10 = 10;
int pin4 = 4;

void setup() {
  pinMode(pin4, OUTPUT);
  digitalWrite(pin4, HIGH);
  pinMode(pin10, OUTPUT);
  digitalWrite(pin10, LOW);
  // initialize the ethernet device
  Ethernet.begin(mac, ip, gateway, subnet);
//  Ethernet.begin(mac, ip);
  // start listening for clients
  server.begin();
// Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Chat server address:");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // wait for a new client:
  EthernetClient client = server.available();

  // when the client sends the first byte, say hello:
  if (client) {
    if (!alreadyConnected) {
      // clead out the input buffer:
      client.flush();   
      Serial.println("We have a new client");
     client.println("Hello, client!");
      alreadyConnected = true;
    }

    if (client.available() > 0) {
      // read the bytes incoming from the client:
      char thisChar = client.read();
      // echo the bytes back to the client:
      server.write(thisChar);
      // echo the bytes to the server as well:
      Serial.write(thisChar);
    }
  }
}

=================================
In the Serial Monitor, it shows
Chat server address:192.168.1.177
Then no further action, when I run a Telnet session or PuTTY session to the entered IP address from the laptop.
I have tried the same with the webserver example from Firefox, no response at all from the Arduino.
I have also tried the client apps, no go.
I have also tried with the default mac addresses.
I use a cross-over Ethernet cable. I also tried with a straight cable. No go.

What am I missing? Please help.
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The sketch uses IP addresses in the 192.168.1.x address space.  Not all residential networks are .1.x; in fact .0.x is more common in my experience.

In other words, your local network might be numbered 192.168.0.x and that might be why you can't see the arduino.

You can test this theory without a lot of work: go to your network settings and check your PC's IP address.  If it ends in 1.x, I'm barking up a wrong tree.  If it ends in 0.x, try changing the 1,177 and 1,1 in the IP assignments in your sketch to 0,177 and 0,1 and it might help.

Good luck with your project.

-br


Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Quote
I am connecting to my laptop PCs (ASUS machines running Windows 7 SP1).

Could be a problem area.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Strangely enough I am having the same problem. I have 2 Arduino Ethernet shields, an Arduino mega, Leonardo, and UNO and I have Reid every combination, and I still have had no luck.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys, solved!!!
Solution was to ensure that the third octet in the IP address was the same as on my lappie.
It was 192.254.33.50, so i tried to set the Arduino to 192.254.33.51, and everything came alive!!
All good.
Logged

Pages: [1]   Go Up
Jump to: