Go Down

Topic: Ploblems with W5100 Ethernet shield.  (Read 294 times) previous topic - next topic

puttersp

Jan 12, 2019, 06:38 am Last Edit: Jan 12, 2019, 06:42 am by puttersp
I'm working on a project to make an ROV and the ethernet shield I bought from China is not working fine.
It didn't have a mac address sticker printed on the shield.
I tried to upload this code
Code: [Select]

#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[] = { 
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };

// 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() {
  // start the serial library:
  Serial.begin(9600);
  // 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(;;)
      ;
  }
  // print your local IP address:
  Serial.println(Ethernet.localIP());

}

void loop() {

}

to get the local IP but it says "Failed to configure Ethernet using DHCP"
I also tried to upload some example in Arduino IDE but it didn't work too.
I have no idea what Mac address and IP should I use,

Sorry for my bad English.

Juraj

you can use in local network the MAC address from the examples until you have only one Arduino with it. try the examples of the  the latest version of the Ethernet library (2.00). they have better diagnostics. did you connect the Ethernet cable to a router/switch or to a computer? the direct connection to a computer requires configuration of IP address on booth sides. it will not work with dhcp
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

puttersp

I connect the Ethernet shield with a router and the USB with the PC.
I just tried using this code:
Code: [Select]

/*
  DHCP-based IP printer

  This sketch uses the DHCP extensions to the Ethernet library to
get an IP address via DHCP and print the address obtained.
  using an Arduino Wiznet Ethernet shield.

  Circuit:
   Ethernet shield attached to pins 10, 11, 12, 13

  created 12 April 2011
  modified 9 Apr 2012
  by Tom Igoe
  modified 02 Sept 2015
  by Arturo Guadalupi

 */

#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[] = {
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};

void setup() {
  // You can use Ethernet.init(pin) to configure the CS pin
  Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    } else if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // no point in carrying on, so do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  switch (Ethernet.maintain()) {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    default:
      //nothing happened
      break;
  }
}

In the serial monitor, it showed this.
Code: [Select]

Initialize Ethernet with DHCP:
Failed to configure Ethernet using DHCP
Ethernet shield was not found.  Sorry, can't run without hardware. :(

Juraj

#3
Jan 12, 2019, 08:52 am Last Edit: Jan 12, 2019, 08:54 am by Juraj
exact model of the shield? some link?

do you have a SD card inserted on shield? if yes, remove it
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

puttersp

I bought it from this website.
https://www.arduino4.com/product/561/ethernet-shield-w5100-r3-for-arduino-%E0%B8%A3%E0%B8%B8%E0%B9%88%E0%B8%99%E0%B9%83%E0%B8%AB%E0%B8%A1%E0%B9%88

I don't have an SD card inserted.

I forgot to mention but my shield got the '510' bug as in this link
https://arduinodiy.wordpress.com/2017/04/12/the-w5100-bug/
so I soldered  a 100-ohm resistor between pin 1-2 (Tx+/Tx-) and a 100-ohm resistor between pin 3 and 6 (Rx+/Rx-) as explained here
https://forum.arduino.cc/index.php?topic=351477.30



Go Up