[Solved]Can not establish an ethernet connection

Hello, I have been struggling with this for a couple of days now:

I have network setup: Laptop - 3G dongle - wifi router( with RJ45 port ) - Switch - ArduinoUno+Ethernet ShieldW5100 (No SD card)

The 3G dongle in the wifi router provides a wireless internet connection, and by extending the network through the routers RJ45 jack I can create a LAN network with an internet connection.

I am attempting to setup a high speed real-time monitoring system

I have attempted the WebServer example but the browser displays that the IP address is being rejected or not available :frowning:

I have attempted the following test code

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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte gateway[] = {192, 168, 169, 1};    // router IP 
byte subnet[] = {255, 255, 255, 0};

IPAddress ip(192,168,169,7);  // I have tried many different numbers but 7 is my lucky one , atleast in roulet 


void setup() {
  Serial.begin(9600);

  // disable SD SPI
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  // Start ethernet
  Serial.print(F("Starting ethernet..."));
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  Serial.println(Ethernet.localIP());

  delay(2000);
  Serial.println(F("Ready"));
}

void loop() {
}

The serial monitor returns: “starting ethernet 0.0.0.0” Ready"

and the following DHCP connection example code:

//zoomkat 11-04-13
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test client GET
//for use with W5100 based ethernet shields
//remove SD card if inserted
//data from myIP server captured in readString

#include <SPI.h>
#include <Ethernet.h>
String readString;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "checkip.dyndns.com"; // zoomkat's test web page server
EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600);
  Serial.println("client readString test 11/04/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
  Serial.println();
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  } 
}

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET / HTTP/1.1"); //download text
    client.println("Host: checkip.dyndns.com");
    client.println("Connection: close");  //close 1.1 persistent connection 
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    readString += c; //places captured byte in readString
  }

  //Serial.println();
  client.stop(); //stop client
  Serial.println("client disconnected.");
  Serial.println("Data from server captured in readString:");
  Serial.println();
  Serial.print(readString); //prints readString to serial monitor
  Serial.println(); 
  Serial.println();
  Serial.println("End of readString");
  Serial.println("==================");
  Serial.println();
  readString=""; //clear readString variable

}

The serial monitor does not return anything

I am stuck with the 3G dongle - Wifi Router with RJ45 port -Switch - hardware combo for another 2 months.

Please help with some ideas, I wonder if the router rejects the arduino, or the switch fail to transfer requests from the arduino to the server? Not sure if one of the cables should be crossover? ( I have a new laptop, dont know how to check if it is done internally )

Thank you in advance

Personally, I think your setup is pretty far from the norm to expect it to be supported. I'd start with a connection directly to a hard-wired router (though I realize that this may not be possible for you). Eliminate as many possible points of failure as possible. Add them back in one at a time. The switch would be next. Then, the wireless router, etc.

Use the DHCP, but initialize the Serial port before you send an error message. Now the error messages is not shown, and the sketch stops at the while.

The serial monitor returns: "starting ethernet 0.0.0.0" Ready"

The SPI connection to the ethernet shield is failing. Check the shield is inserted fully into the Arduino. Also check for solder bridges on the w5100 IC pins and pads.

Until that returns "Starting ethernet...192.168.169.7", your Arduino is not communicating with the shield.

I have troubles with my W5100 Ethernet Shield and a slow wifi tablet. Perhaps the timing or timeouts or retries for the Ethernet library is not as good as normal websites.

Let me explain: My Arduino and Ethernet shield runs a webpage and is connected with my router with a cable. Everything seems to work well. That router has also wifi. I have a very cheap tablet with very bad wifi connection. That tablet is often not able to show that webpage, but it can connect to all the sites on the internet.

Maybe you have a combination of problems, and this could be one of them.

This response has nothing to do with a router, or anything on the RJ45 side of the w5100. This was an attempt to set a static IP.

The serial monitor returns: "starting ethernet 0.0.0.0" Ready"

It is an indication that the SPI bus is failing. That is the connection between the Arduino and the w5100, not the w5100 connection to a router.

You probably got the ethernet shield fully inserted into the Arduino.

So I got the LAN connection working by running the 3G dongle straight into the laptop USB Port and connecting the Arduino and laptop through ethernet. Just share the "mobile broadband connection" with the LAN connection through ICS.

Coding lesson no. 428: Always test your assumptions. Coding lesson no. 2: Triple check your hardware connection

It was never the router at all, only a faulty connection with the Arduino. You really have to squeeze the two together :grin:

Thanks SurferTim

All I can say is: ew!