I have never worked with with Ethernet or something like it.
I uploaded the code below to my arduino UNO but nothing shows up in the serial monitor, when I remove the first if statement it gives me: 255.255.255.255.
I did fill in the correct mac address and i am using arduino IDE ver. 1.8.5
Because nothing shows up, i don't know what the problem is.
#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[] = {0xA8, 0x61, 0x0A, 0xAE, 0x5B, 0x43 };
// 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() {
}
Which Ethernet controller are you using? The common ones are W5100, W5200, W5500, ENC28J60.
You definitely need to call Ethernet.begin() to have any hope of making the library work, but temporarily removing that statement was a good thing because now we know for certain that your Serial Monitor is working correctly.
pert:
You definitely need to call Ethernet.begin() to have any hope of making the library work, but temporarily removing that statement was a good thing because now we know for certain that your Serial Monitor is working correctly.
Per, Ethernet.begin is there
@NickNatics, do you use the latest version of the Ethernet library (2.00)?
how did you connect the Ethernet cable? to computer or to router/switch?
Do the LEDs on the shield light up?
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}