Activity Forums Questions & Troubleshooting DHCP connection failed

  • DHCP connection failed

     Lukas updated 11 months ago 3 Members · 4 Posts
  • SylvainH

    Member
    October 28, 2021 at 5:04 pm

    Hi,

    I can’t connected to my controllino Maxi automation through DHCP. I have “ethernet shield not found” as a result. Any idea what could be the problem ? I have tried a fresh install of arduini IDE, older ethernet library. Thanks for your help.

    Here is my sketch (basic DhcpAdressPrinter arduino sketch) :

    #include <SPI.h>
    #include <Controllino.h>

    /*
    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;
    }
    }

  • Lukas

    Member
    November 5, 2021 at 2:43 pm

    Hi,

    comment out the line

    Ethernet.init(10); // Most Arduino shields

    The chipselect is defined in the board definition, so it will be defined properly when you select the Board – CONTROLLINO.

    Please use the latest Ethernet library.

    Good luck!

    Lukas

  • Oldtimer

    Member
    November 10, 2021 at 2:44 pm

    <font style=”vertical-align: inherit;”><font style=”vertical-align: inherit;”>Hallo, hatte heute das selbe Problem aber dank Euren Beitrags konnte ich es sofort beheben!</font></font>

    • Lukas

      Member
      January 4, 2022 at 3:18 pm

      Great, thanks for the feedback!

      Oltimer says: Hello, I had the same problem today but thanks to your contribution I was able to fix it immediately!


Viewing 1 - 3 of 3 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now