Arduino ethernet manual

Hello Guys,
I am working under university LAN network with a ip server and port 8080. For this i got a code, but when i run,it show Login timeout error. Please help me to get connected to blynk cloud.

#define BLYNK_PRINT Serial

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

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

IPAddress server_ip (proxy ip address);
IPAddress port=proxy port; // ip address and port number is given by  university.

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( static ip of my port);
IPAddress dns_ip     (  dns server ip);
IPAddress gateway_ip ( gateway ip);
IPAddress subnet_mask(255, 255, 255,   0);

#define W5100_CS  10
#define SDCARD_CS 4

void setup()
  // Debug console

  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(auth, server_ip, port, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
  // Or like this:
  //Blynk.begin(auth, "", 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);

void loop()

A couple of issues with your code…

I’m not sure you can use “IPAddress port=8080” to define your port as 8080.

You correctly define your Ethernet select pin as GPIO 10 using this code" #define W5100_CS 10" but you don’t have a corresponding pinMode statement or a digitalWrite to set GPIO10 to LOW. You might get away without that, but if you do then remove the definition as its not required.

On the hardware side, these W5100 shields are very temperamental. If you do a bit of googling or search this site you’ll see what I mean. In addition, they won’t work with some Ethernet switches. If you’re connecting directly into a Layer 2 Ethernet switch then I think you’ll have a problem. If you plug your shield into a Layer 3 switch, then plug this into the Layer 2 switch it will be fine.

Edited to add…
I just tried defining “IPAddress port=8080;” then doing a “Serial.println(port);”
The serial monitor prints port as “”, so that’s certainly not achieving what you’re looking for.


please edit your post and format your code. it looks nicer and easier to read.


Sir, would you suggest me the modifications I need to do in the code in a more explained way. I am new to such projects. Thank You for your time.

I’m not going to write your code for you, but I’ll explain the changes you need to make…

This line is a problem, because you’re defining a variable called port with the structure of an IP address (in the format xxx,xxx,xxx,xxx) :

IPAddress port=proxy port; // ip address and port number is given by university.

You actually need to store a number such as 8080, so probably need to declare this as an integer rather than an IPaddress. Something like this:

int port=8080;

Alternatively, if you read the comment in the code that begins “// Or like this:”, you’ll see that you could actually just write the port number directly into the blynk.begin statement. In the example in the comment, port 8442 is being used. You could replace this with 8080, which would remove the need for declaring the integer variable called “port”. The disadvantage of doing this is that you need to trawl through your code to find the hard-coded port value if you ever want to change this in future. Much better to have it declared as a global variable at the top of your code, along with the other network related variables, but potentially useful if you want to do some quick and dirty testing.

The Ethernet shield has two devices on it, the Ethernet port and an SD card. Because of the way that the hardware had been implemented, you can only use one device at any one time. If you wanted to use both in your code (which you don’t) then you’d need to switch between the two devices by disabling GPIO2 and enabling GPIO10, then disabling GPIO10 and enabling GPIO2. Your code starts off well, by defining names for both GPIO pins - W5100_CS for GPIO10 and SDCARD_C for GPIO2.
You then have these two lines that relate to the SD card on GPIO2:

digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

This tells the Arduino that GPIO2 will be used as an Output, and then sets it HIGH (to 5 volts) which disables the SD card. As I said before, this may be sufficient to enable the Ethernet port by default, but for neatness and completeness you should add a couple of lines to explicitly do this. They would look something like this:

pinMode(W5100_CS, OUTPUT);
digitalWrite(W5100_CS, LOW); // Select the Ethernet port

These could go immediately after the two matching SD_CARD statements, before the blynk.config statement.



I tried your modifications sir, but it is not able to connect, Sir, is it possible that sysadmins of our LAN has not yet authorized for this connection and i need to ask for permissions? I will gie this a try though. But please keep suggesting other modifications if required.

Is the link LED lit on the Ethernet shield when you plug-in the Ethernet cable?
What LED activity do you see when your code is running?

Have you tried pressing the reset button on the shield a few times? - these shields are very temperamental on power-up, especially if you have a bad one.