How to configure static IP on ethernet (w5500 arduino shield)

hi, i was trying to connect via static ip.
but it is not connecting.

i used the following:

/*************************************************************
  This example shows how to use Arduino Ethernet shield (W5100)
  to connect your project to Blynk.

  NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
        DON'T use them in your sketch directly!

  WARNING: If you have an SD card, you may need to disable it
        by setting pin 4 to HIGH. Read more here:
        https://www.arduino.cc/en/Main/ArduinoEthernetShield

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/

/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID           "XXXXXXXXXXXXX"
#define BLYNK_TEMPLATE_NAME         "Quickstart Template"
#define BLYNK_AUTH_TOKEN            "XXXXXXXXXXXXXXXXXXXXXXXXX_XXXXXX"

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


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

#define W5100_CS  10
#define SDCARD_CS 4

IPAddress server_ip (128, 199, 144, 129);
byte device_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress device_ip  (192, 168, 50, 165);    
IPAddress dns_ip     (8,  8, 8, 8);       
IPAddress gateway_ip (192, 168, 50,  1);  
IPAddress subnet_mask(255, 255, 255, 0);    

BlynkTimer timer;

// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  int value = param.asInt();

  // Update state
  Blynk.virtualWrite(V1, value);
}

// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
 }

void myTimerEvent()
{

  Blynk.virtualWrite(V2, millis() / 1000);
}

void setup()
{

  Serial.begin(9600);
  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80, device_ip, dns_ip, gateway_ip, subnet_mask, device_mac);                
  timer.setInterval(1000L, myTimerEvent);
}

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

}

Heres the output:

[12862] Using static IP
[14423] IP:192.168.50.165
[14424] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.3.0 on Arduino

 #StandWithUkraine    https://bit.ly/swua


[14589] Connecting to blynk.cloud:80
[16248] Connecting to blynk.cloud:8080
[19589] Connecting to blynk.cloud:80
[21209] Connecting to blynk.cloud:8080
[24590] Connecting to blynk.cloud:80
[26210] Connecting to blynk.cloud:8080
[29591] Connecting to blynk.cloud:80
[31211] Connecting to blynk.cloud:8080

Posting photos of your computer screen (or even proper screenshots) isn’t a good thing to do, as they aren’t very clear and only show a small amount of the serial output.
It’s far better to copy the text from the serial monitor and paste it into your forum post, using triple backticks at the beginning and end so that it displays correctly.
Triple backticks look like this:
```

Also, posting snippets of code doesn’t really help solve your problem. It’s far better to post your entire sketch. In your case I assume that your problem lies with the values you’ve assigned to the various IP addresses and the MAC address, but you haven’t shared these so we can’t tell.

When you post code it also needs triple backticks at the beginning and end so that it displays correctly.

Pete.

1 Like

You’ve edited your post, but despite me giving you triple backticks to copy/paste you’ve used different characters, which don’t work.

Please try again.

Pete.

1 Like

sorry about that, my bad… i think its okay now.

Your code is okay, your serial output isn’t.

Pete.

yes, i do not know why. i ping the server, its all okay.

C:\Users\RGD_PC>ping blynk.cloud

Pinging blynk.cloud [128.199.144.129] with 32 bytes of data:
Reply from 128.199.144.129: bytes=32 time=107ms TTL=52
Reply from 128.199.144.129: bytes=32 time=107ms TTL=52
Reply from 128.199.144.129: bytes=32 time=107ms TTL=52
Reply from 128.199.144.129: bytes=32 time=107ms TTL=52

Ping statistics for 128.199.144.129:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 107ms, Maximum = 107ms, Average = 107ms

and heres my credentials:

  Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Realtek PCIe GbE Family Controller
   Physical Address. . . . . . . . . : 30-65-EC-C3-EB-61
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 192.168.50.165(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.50.1
   DNS Servers . . . . . . . . . . . : 8.8.8.8
   NetBIOS over Tcpip. . . . . . . . : Enabled

I meant that your formatting of your serial output is still missing triple backticks, the same as the ping results in your latest post.

Pete.

1 Like

So it looks like youre trying to assign a static IP address to your Arduino which is teh same as the IP address used by your PC…

Pete.

i am using one cable, i pulled out the cable on my pc, then putting it to the w5500 shield.

Have you tried a different IP address for your Arduino (one that’s not being used by anything else)?

Your router probably has a routing table entry for your PC and then when it sees a device with a different MAC address trying to use the same IP address it won’t be happy.

Pete.

Thank you for the quick reply. I will try it now. :slight_smile:

I have the same results:

[12663] Using static IP
[14225] IP:192.168.99.80
[14226] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.3.0 on Arduino

 #StandWithUkraine    https://bit.ly/swua


[14390] Connecting to blynk.cloud:80
[19535] Connecting to blynk.cloud:80
[24643] Connecting to blynk.cloud:80
[29751] Connecting to blynk.cloud:80
[34859] Connecting to blynk.cloud:80
[39966] Connecting to blynk.cloud:80
[45074] Connecting to blynk.cloud:80
[46695] Connecting to blynk.cloud:8080
IPAddress server_ip (128, 199, 144, 129);
byte device_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress device_ip  (192, 168, 99, 80);    
IPAddress dns_ip     (8,  8, 8, 8);       

IPAddress gateway_ip (192, 168, 99,  2);  
IPAddress subnet_mask(255, 255, 255, 0);  

Now I’m really confused by your choice of IP address ranges and subnet masks.

How has your gateway moved from 192.168.50.1 to 192.168.99.2 ?

Pete.

yes, since i use the other network switch that have more available ports. now i can plug to the network both laptop and ethernet shield. i disable the firewall.