Arduino Uno with ENC28J60 won't obtain IP

Hi all,

My Arduino Uno connected to a local server running on my Mac can’t obtain an IP address. Serial monitor reports a DHCP error.

Mac is connected to my TP-link router via Wi-Fi (local IP 192.168.0.101).
Blynk app is set to connect to 192.168.0.101 via port 8443.
ENC28J60 is connected to TP-LINK routers ethernet port.
In my sketch i have <Blynk.begin(auth, IPAddress(192,168,0,101), 8442);>

I am not experienced in networking so I dont know if Ethernet connected hardware can connect to a Wi-Fi connected device (which are on the same network).

Can anyone please help?
Thanks

Yes the Uno should be able to connect to server running on the MAC (firewall and ports permitting etc).

Sketch and Serial Monitor please.

Sorry, sketch got deleted somehow.

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "d***************************************************0f";

void setup()
{
  Serial.begin(9600);
  
  //Blynk.begin(auth);
  
  // You can also specify server.
  // For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example
  //Blynk.begin(auth, "blynk-cloud.com", 8442);
  Blynk.begin(auth, IPAddress(192,168,0,101), 8442);
}

void loop()
{
  Blynk.run();
}

And serial monitor:

[0[0] Getting IP...
[60166] DHCP Failed!
[0] Getting IP...
[60167] DHCP Failed!
[0] Getting IP...

Thanks for a prompt response.

@kost9 include these items in your sketch and paste another Serial Monitor if it doesn’t connect:

//..........................
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 192,   168,   0,  150);
IPAddress dns_ip     (  192,   168,   0,   101);
IPAddress gateway_ip ( 192,   168,   0,   101);
IPAddress subnet_mask(255, 255, 255,   0);


void setup() {
  //.............
    Blynk.begin(auth, "192.168.0.101, 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);

}

Now it obtains an IP but cant connect.
Serial Monitor:

[0] Using static IP
[1050] IP:192.168.0.150
[1051] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.4 on Arduino Uno

[5001] Connecting to 192.168.0.101:8442
[30003] Connecting to 192.168.0.101:8442
[55005] Connecting to 192.168.0.101:8442

I get that response from my ENC when I have one of my pins disconnected. Are you sure all pins are connected correctly?

Confirm which pins you are using on the Uno.

Can you ping the Uno on 192.168.0.150?

Thank you Costas, I had one of my pins misconnected. Very dumb of me.

Thanks for great support!

1 Like

Common problem and Serial Monitor doesn’t really give you a warning unless you have experienced it before i.e. it gives you an IP and you think the ENC is fully operational, when it’s not.

1 Like

Hey …all of my pins are ok …which pins you messed up btw? I am still getting same error “Connecting…”

@VINEET Old topic. Please create your own, with details. Thank you.