0

My Arduino Uno with Ethernet Shield is connected to a Raspberry (rasp1) and the Ethernet Shield is connected to another Raspberry (rasp2) by Ethernet cable; rasp2 has a private IP address (192.168.10.0). I want to find out the Arduino IP address.

I used the example sketch DHCPAddressPrinter but when running it the Serial Monitor remains empty (as Mac Address I used the address located underneath the shield).

Code Used:

#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[] = {
    0x90, 0xA2, 0xDA, 0x11, 0x32, 0x49
};


// 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() {
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    // this check is only needed on the Leonardo:
    while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
    }


    // 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.print("My IP address: ");
    for (byte thisByte = 0; thisByte < 4; thisByte++) {
        // print the value of each byte of the IP address:
        Serial.print(Ethernet.localIP()[thisByte], DEC);
        Serial.print(".");
    }
    Serial.println();
}

void loop() {
sa_leinad
  • 3,188
  • 1
  • 22
  • 51
gert
  • 1

1 Answers1

1

192.168.10.0 is not a valid IP address (unless it's on a /32 subnet which makes no sense on ethernet).

You need to allocate a proper IP address within a proper subnet, such as 192.168.10.1/24 (i.e., IP 192.168.10.1 and netmask 255.255.255.0), and either manually provide a similar IP address to the Arduino (such as 192.168.10.2/24 [IP 192.168.10.2 netmask 255.255.255.0]), or install and configure a DHCP server on the Raspberry to hand out IP addresses within that subnet range (e.g., 192.168.10.100/24 to 192.168.10.200/24) for the Arduino to then be able to use DHCP mode.

Most of that is outside the scope of an Arduino SE site, though.

Majenko
  • 105,095
  • 5
  • 79
  • 137