BlynkBlink Arduino sketch with FIXED IP

Could anyone give me an example how to implement a FIXED IP address when for example turning a LED on and off?
Thks. Sam.

1 Like
IPAddress server_ip (10, 0, 0, 10);

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 10,   0,   0,  20);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 10,   0,   0,   1);
IPAddress subnet_mask(255, 255, 255,   0);

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, server_ip, 8443, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
  // Or like this:
  //Blynk.begin(auth, "server.org", 8443, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}

note that the “IPAddress server” and server_ip are for the “backend server”

I tried the following code with a Uno which seemed to be working fine for a few hours, then when I tried to add a second Uno with a different MAC, IP, Dashboard & auth neither of the Uno’s would work again. Unless I removed all the code to manage the MAC & IP, this results in both trying to use the same MAC address of DE:ED:BA:FE:FE:ED, which doesn’t work on the same network. I also have had a YUN running the whole time without any issues (its MAC is unique and simpleYun doesn’t allow you to change the MAC).

/*IPAddress server_ip (10, 0, 0, 10); // Not used

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xC0, 0x15, 0xC0, 0xFF, 0xEE, 0x81 };
IPAddress arduino_ip ( 192,   168,   1,  81);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 192,   168,   1,   1);
IPAddress subnet_mask(255, 255, 255,   0);*/

void setup()
{
  Serial.begin(9600); // See the connection status in Serial Monitor
  Blynk.begin(auth, "cloud.blynk.cc", 8443, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}

If anyone has any suggestions on how to connect multiple Uno’s with unique MACs, I would be grateful.

Oops, my first line should start with // not /*

Thanks for the quick response.
I changed all parameters with those of my own. These parameters normaly work with other fixed IP sketches.
Unfortunately no luck yet.
Just to be sure I forwarded port 8443 on my router.
I refreshed my token. Resetting all devices.
The serial output replies only with “[…] Connecting to .(server ip).:8443”

I have a standard Arduino Uno with a standard Ethernet Shield connecting directly into my router.
Do I need, in my case, the IPAddress server parameter. If so what should this be? The IP provided by my ISP?
I tried this also.
I cannot skip this parameter because then the Serial Output gives me the wrong My IP address (changes this into the DNS ip address).

Thks for your advice.
Sam

Try “cloud.blynk.cc” instead of “server.org” in your Blynk.begin(), I assume this negates the IP entered at IPAddress server_ip (10, 0, 0, 10);

You should connect to 8442. This port is for hardware.

8443 is a port for apps and it uses SSL for security. That’s why you can’t connect.

1 Like

@elatrium, I hope it works now. Please ask more questions if not.
You can also contact me directly: volodymyr@blynk.cc

About multiple UNOs on one LAN, I filed a bug so we will check this scenario again, thanks!

Hi there,

It is working now. It was indeed port 8442 I had to use and for the IP server I used cloud blynk.cc.
Thank you all for your answers.

Regards,
Sam :smile:

@vshymanskyy I’m trying to do the same with a local blynk server but associating a static IP address to my ESP8266, is this how I do it ---- seems to give me an error in compiling :frowning:

Blynk.begin(auth, "SSID", "Password", IPAddress(xxx,xxx,xxx,xxx), arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);

I’ve defined arduino_ip etc, as per the Ethernet example.
IPAdddress (xxxxx) is the IP Adresss of my local blynk server

The error I get in compiling is:
Arduino: 1.6.11 (Mac OS X), Board: “WeMos D1 R2 & mini, 80 MHz, 115200, 4M (3M SPIFFS)”

/Volumes/Arduino/My Arduino Code Library/Arduino/ESP8266_Temp_OneWire_Demo_mdv1/ESP8266_Temp_OneWire_Demo_mdv1.ino: In function ‘void setup()’:
ESP8266_Temp_OneWire_Demo_mdv1:166: error: no matching function for call to ‘BlynkWifi::begin(char [33], const char [10], const char [11], IPAddress, IPAddress&, IPAddress&, IPAddress&, IPAddress&, byte [6])’
Blynk.begin(auth, “xxxx”, “xxxx”, IPAddress(xxx,xxx,xxx,xxx), arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
^
/Volumes/nas1backup/Arduino/My Arduino Code Library/Arduino/ESP8266_Temp_OneWire_Demo_mdv1/ESP8266_Temp_OneWire_Demo_mdv1.ino:166:132: note: candidates are:
In file included from /Volumes/nas1backup/Arduino/My Arduino Code Library/Arduino/ESP8266_Temp_OneWire_Demo_mdv1/ESP8266_Temp_OneWire_Demo_mdv1.ino:66:0:
/Users/xxxxi/Documents/Arduino/libraries/Blynk/BlynkSimpleEsp8266.h:66:10: note: void BlynkWifi::begin(const char*, const char*, const char*, const char*, uint16_t)
void begin(const char* auth,

      ^

/Users/xxxx/Documents/Arduino/libraries/Blynk/BlynkSimpleEsp8266.h:66:10: note: candidate expects 5 arguments, 9 provided
/Users/xxxxx/Documents/Arduino/libraries/Blynk/BlynkSimpleEsp8266.h:76:10: note: void BlynkWifi::begin(const char*, const char*, const char*, IPAddress, uint16_t)
void begin(const char* auth,

      ^

/Users/xxxxx/Documents/Arduino/libraries/Blynk/BlynkSimpleEsp8266.h:76:10: note: candidate expects 5 arguments, 9 provided
exit status 1
no matching function for call to ‘BlynkWifi::begin(char [33], const char [10], const char [11], IPAddress, IPAddress&, IPAddress&, IPAddress&, IPAddress&, byte [6])’

@mars I think IPAddress(xxx,xxx,xxx,xxx) is arduino_ip so you have it twice in the Blynk.begin() function.

The IPAddress is IPAddress of my local blynk server actually.

@Dimitry Is there any documentation on to setup static IP address for esp8266 ?

@mars working code available at Setting StaticIP address on ESP8266