DFR0850 detects I2C devices, but cannot find ethernet hardware

I’m building a POE temperature logger (reads I2C devices, and calls a URL to record the values on a SQL server. Long story short, while the DFR0850 can read the I2C devices, the ethernet fails to detect, and thus doesn’t work. Switch is a Ubiquiti Pro 48 port POE switch so power is fine, I’ve also tried the Wiki code on the DFRobot website for the shield as well, and no luck with it either. My switch doesn’t even see the MAC address of the unit. I’ve verified the cable using a cable tester and all the pins are perfect.

Code as follows, I’ve been playing with the various reset pins and no combination of pins 4 or 11 make a difference either. Nothing I do seems to work, the I2C is good, but the ethernet … not so much. I’ve included plenty of watchdog code to catch when it crashes, fails, etc, and it gets stuck on the loop

Ethernet shield was not found.
Connection Failed Link State ... Reset
Ethernet shield was not found.
Connection Failed Link State ... Reset
Ethernet shield was not found.
Connection Failed Link State ... Reset
#include <SPI.h>
#include <Ethernet.h>
#include <Adafruit_MCP9808.h>
#include <avr/wdt.h>

// Buttons
#define SS     10U    //W5500 CS
#define RST    11U    //W5500 RST

// Web Loop
unsigned long previousMillis = 0UL;
unsigned long interval = 30000UL;

// Watchdog Loop
unsigned long WDpreviousMillis = 0UL;
unsigned long WDinterval = 500UL;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0x00, 0xC0, 0xFF, 0xEE
};
IPAddress ip(10, 0, 0, 8);
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(10, 0, 0, 1);
IPAddress dnsServer(10, 0, 0, 10);

// Initialize the Ethernet library
EthernetClient client;

// Temp Sensor
Adafruit_MCP9808 i2ctemp1 = Adafruit_MCP9808();
Adafruit_MCP9808 i2ctemp2 = Adafruit_MCP9808();
Adafruit_MCP9808 i2ctemp3 = Adafruit_MCP9808();

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  // Make the reset work
  pinMode(RST,OUTPUT);
  digitalWrite(RST,HIGH);
  // Setup the static IP
  // Ethernet.init(53);
  Ethernet.begin(mac, ip, dnsServer, gateway, subnet);
  // Reset Pin
  digitalWrite(RST, HIGH);
  // Setup temp sensor 1
  if (!i2ctemp1.begin(0x18)) {
    Serial.println("Couldn't find MCP9808! Module 1 Check your connections and verify the address is correct.");
  while (1);
  }
  i2ctemp1.setResolution(3);
  // Setup temp sensor 2
  if (!i2ctemp2.begin(0x19)) {
    Serial.println("Couldn't find MCP9808! Module 2 Check your connections and verify the address is correct.");
  while (1);
  }
  i2ctemp2.setResolution(3);
  // Setup temp sensor 3
  if (!i2ctemp3.begin(0x1A)) {
    Serial.println("Couldn't find MCP9808! Module 3 Check your connections and verify the address is correct.");
  while (1);
  }
  i2ctemp3.setResolution(3);
  // Start the Watchdog
  wdt_enable(WDTO_2S);
  // Disable PIN 4 & Init W5500
  //pinMode(4,OUTPUT);
  //digitalWrite(4,HIGH);
  //digitalWrite(RST,HIGH);
  //digitalWrite(SS, HIGH);
  //delay(200);
  //digitalWrite(RST,LOW);
  //digitalWrite(SS, LOW);
  //delay(200);
  //digitalWrite(RST,HIGH);
  //digitalWrite(SS, HIGH);
  delay(200);
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.");
  }
  else if (Ethernet.hardwareStatus() == EthernetW5100) {
    Serial.println("W5100 Ethernet controller detected.");
  }
  else if (Ethernet.hardwareStatus() == EthernetW5200) {
    Serial.println("W5200 Ethernet controller detected.");
  }
  else if (Ethernet.hardwareStatus() == EthernetW5500) {
    Serial.println("W5500 Ethernet controller detected.");
  }
}

void loop() {
  // Firing trigger setup 
  unsigned long currentMillis = millis();
  unsigned long WDcurrentMillis = millis();

  // Watchdog Reset Every 500ms
  if(WDcurrentMillis - WDpreviousMillis > WDinterval) {
    WDpreviousMillis = WDcurrentMillis;
    wdt_reset();
  }

  // Connect To Webserver Loop
  if(currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;
    if(Ethernet.linkStatus() == LinkON) {
      int    HTTP_PORT   = 80;
      char   HOST_NAME[] = "10.0.0.10";
      if (client.connect(HOST_NAME, HTTP_PORT)) {
        // We connected, now close it quick.
        client.stop();
        // Temp Sensor 1 Code
        i2ctemp1.wake();
        delay(150);
        float c1 = i2ctemp1.readTempC();
        i2ctemp1.shutdown_wake(1);
        // Temp Sensor 2 Code
        i2ctemp2.wake();
        delay(150);
        float c2 = i2ctemp2.readTempC();
        i2ctemp2.shutdown_wake(1);
        // Temp Sensor 3 Code
        i2ctemp3.wake();
        delay(150);
        float c3 = i2ctemp3.readTempC();
        i2ctemp3.shutdown_wake(1);  

        String HTTP_METHOD = "GET"; // or "POST"
        String PATH_NAME1;
        PATH_NAME1 += "/sensor/index.php?id=0x18&var=";
        PATH_NAME1 += String(c1);
        String PATH_NAME2;
        PATH_NAME2 += "/sensor/index.php?id=0x19&var=";
        PATH_NAME2 += String(c2);
        String PATH_NAME3;
        PATH_NAME3 += "/sensor/index.php?id=0x1A&var=";
        PATH_NAME3 += String(c3);
        // make a HTTP request:
        // send HTTP header
        client.connect(HOST_NAME, HTTP_PORT);
        client.setConnectionTimeout(100);
        client.println(HTTP_METHOD + " " + PATH_NAME1 + " HTTP/1.1");
        client.println("Host: " + String(HOST_NAME));
        client.println("Connection: close");
        client.println(); // end HTTP header
        client.stop();
        client.connect(HOST_NAME, HTTP_PORT);
        client.setConnectionTimeout(100);
        client.println(HTTP_METHOD + " " + PATH_NAME2 + " HTTP/1.1");
        client.println("Host: " + String(HOST_NAME));
        client.println("Connection: close");
        client.println(); // end HTTP header
        client.stop();
        client.connect(HOST_NAME, HTTP_PORT);
        client.setConnectionTimeout(100);
        client.println(HTTP_METHOD + " " + PATH_NAME3 + " HTTP/1.1");
        client.println("Host: " + String(HOST_NAME));
        client.println("Connection: close");
        client.println(); // end HTTP header
        client.stop();
      } else {// if not connected:
        Serial.println("Connection Failed Host Connect ... Reset");
        digitalWrite(RST, LOW);
        delay(250);
        digitalWrite(RST, HIGH);
        delay(250);
        setup();
        loop();
      }
    } else {
      Serial.println("Connection Failed Link State ... Reset");
      digitalWrite(RST, LOW);
      delay(250);
      digitalWrite(RST, HIGH);
      delay(250);
      setup();
      loop();
    }
  }
}
1 Like

Hi Michael, welcome to the forum!

Cheers for posting what you’ve tried so far, and the code you are using.

This all seems to check out, I assume you had this uncommented while testing different pins?

I’m assuming the “reset” jumper on the shield is set to pin 11?

If that’s the case, we can try setting up one of these on the bench over here with the DFRobot code to try and replicate your issue.

Keen to get to the bottom of this one!

1 Like
#define RST    11U    //W5500 RST

Yep, RST is defined as 11, and that code block was previously uncommented and tested, I was slowly stripping things back to get things to work. The thing is, the I2C devices are connected via the DFR0850 and the DFR0221 can connect to them just fine. All the LED’s on both board light up, and there’s even the link light on the DFR0850 as well, so everything appears at face value to be fine.

1 Like

Hi Michael,

Good to hear there are more things as they should be. As a last step, could you please attach a photo or two of how you’ve got everything hooked up? We may spot something.

Once we’ve seen that, we’ll set up your code on the bench with a unit from our stock, and if it works, you may have faulty hardware, in which case we’ll handle that via email as an RMA.

No worries, here’s some pics of how it’s setup.

thumbnail_image0
thumbnail_image1
thumbnail_image2

1 Like