Why does ip address change sometimes?

My problem is while i connect my enc28j60 and run the code then serial monitor shows some ip address like

[0] Getting IP…
[1252] My IP: XXX.XX.XX.XX

and with this ip i don’t get connection and sometimes without doing anything my serial monitor shows some other ip address like

and with this ip address i get the connection and my set up works fine.

So, the problem is how to fix this??

Please help me.

Depending on what kind of network configuration you have, this is either a result of:

  1. Your router: Each time you connect it’s giving you a different IP address (or at least it changes after some duration (your DHCP lease duration). If your IP address starts with 192.168 or 10.0 this is probably assigned from your router.
  2. Your internet service provider: If your IP address looks like (or any jumble of numbers) then your ENC is connected directly to the Internet and your ISP is changing the IP (less likely I would think).

You should have the same Blynk experience regardless of your IP address but maybe your local network has different configurations based on IP address.

I’m not familiar with the ENC, but if you find an IP address that works (and this is under the assumption that you’re behind a router with a 192.168..-style address) do a search for how to manually assign an IP address using code. That may help.

1 Like

Thanks , my ip address starts with 172.16.

Ah, that sounds like a router-assigned address as well!

The ENC28J60 seems to be a little more difficult to work with (in lieu of a WIZnet-based device) but the EtherCard library is recommended and should be able to set an IP.