Nano with Ethernet shield ENC28J60 not connecting to Blynk

Hi,
I’m trying to connect my arduino nano with the ENC28J60 shield to the blynk app but it is not working.

I’m using this code from the blynk library

#define BLYNK_PRINT Serial


#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>

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


void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth);
  // You can also specify server:
  //Blynk.begin(auth, "blynk-cloud.com", 80);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8080);
}

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

On the terminal it is written:
[0] Getting IP …
[60258] DHCP Failed!

I don’t understand why because everything else seems to be good

The auth is good, and the connections are good too because i’m using this shield :

Thanks for helping me.

Sorry just noticed that its ethernet and not wifi. My bad. :slight_smile:

What version of the Blynk library are you using?
cul
billd

did you try some basic Ethernet library examples like WbServer or WebClient?

Hi thanks for the replies,
I’m using the arduino web editor and with that i don’t need to download any library, so i don’t realy know the version. But i can try directly with the arduino app and the latest library of blynk.
I didn’t tried some basic ethernet library exemple because I don’t realy know how this work.

Use library version 0.6.1

Pete.

Last time I tried the Arduino web IDE doesn’t work with Blynk as you can’t install the Blynk library (and it’s not part of the standard Arduino build . . .) You need to use the Arduino IDE app. Do NOT use the latest beta Blynk libraries.

billd

1 Like

So I downloaded this :

but it doesn’t detect the library :

Also when i try to upload the program to the card i get an error message :

If you’re basing that comment on the colour-coding in the IDE then don’t worry, the library has been detected.
Colour coding is based on a keywords file and is just an added extra which isn’t mandatory.

You could try removing the #define BLYNK_PRINT Serial, but as you’re 180% over size I doubt that will help enough.
I think the issue is probably the size of the UIPEthernet library.

Do you need a hard-wired Ethernet solution, or would WiFi work for you? If not then you’d be better using a NodeMCU or Wemos D1 Mini.

Pete.

I just tried to upload the same sketch with an other computer on the same arduino nano and it work.
I have now uploaded the sketch with the last library on my nano but it still can’t get the Ip like in my first post.

Pete.

No, I didn’t, I will try the WbServer but what does it do?

I tried to upload the WebServer sketch.

#include <SPI.h>
#include <Ethernet.h>

// 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, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

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
  }
  Serial.println("Ethernet WebServer Example");

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }

  // start the server
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

I think i have to change the IP and the mac address in the sketch.
But i have 2 problems :
-Where can i see the mac adress of my device
-which ip should I enter? that of my internet box?

Your Ethernet adapter doesn’t have a MAC address, which is why you have to specify one. It just needs to be different from any other device MAC address on your network.

In the same way, the IP address you specify must be unique on your network. This usually involves changing only the last part of the IP address to a number between 1 and 254

You can use a tool like Advanced IP Scanner to see the IP and MAC addresses currently in use on your network.

The code you posted doesn’t seem to be using the UIPEthernet library, is it one of the code examples from the UIPEthernet examples?

Pete.

No it’s not, I took this sketch here

Wich one should i use ?

So what should i do ?
Is it okay if i use the previous Webserver sketch or do i need to take one from the UIPEthernet library ?

Yes.

Pete.

Hi, I just realized something, the RJ45 socket is supposed to light up when connected with the cable wich wasn’t the case before. So I tried to disconnect/reconnect the arduino nano to the shield and now i can see the leds working.
But the shield is making some heat, it is not realy hot but enough to let me think it is annormal.
In addition, the card still cannot get the ip with the ENC28J60 exemple from blynk.

Are you plugging the other end of your Ethernet cable directly into the router, or are you using an Ethernet switch?
Some Ethernet shields don’t work correctly with some switches, so plugging directly into the router will eliminate that as a potential issue.

Pete.

Yes my shield is plugged directly into the router