BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Подключение к Blynk со своими ip, gw, mask - как?

Помогите составить скетч подключения, в котором заданы свои IP, Gateway и Mask сети, когда в ней нет dhcp сервера.

char myip[] = “10.0.6.14”;
char gw[] = “10.0.1.1”;
char mask[] = “255.255.0.0”;

В дальнейшем, хочу сделать конструкцию автоматической смены одного из трёх шлюзов при недоступности интернета, перебором.

What type of board, and are you using WiFi or wired Ethernet?

Pete.

1 Like

ESP8266 and WiFi.

Pete.

1 Like

Thank you so much! :slight_smile:

1 Like

You’re welcome!

You could look at using WiFi Manager to allow you to enter your credentials if you don’t want to hard-code them and use brute-force.

Pete.

1 Like

I was unable to connect to Blynk.
The device appears on the net! work, responds to ping.
Attempts are constantly visible in the Serial console…
Where could the error be?
My ver.: Arduino 1.8.13; Blynk 0.6.1; Ethernet 2.0.0;

My example:

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "Key";
char ssid[] = "WiFi";
char pass[] = "Pass";

byte arduino_mac[] = { 0x48, 0x3F, 0xDA, 0x9C, 0xCD, 0xA7 };
IPAddress device_ip  (10, 0, 6, 14);
IPAddress dns_ip     (8, 8, 8, 8);
IPAddress gateway_ip (10, 0, 1, 1);
IPAddress subnet_mask(255, 255, 0, 0);

void setup()
{
  Serial.begin(115200);
  WiFi.config(device_ip, gateway_ip, subnet_mask);
  WiFi.begin(ssid, pass);

  Blynk.config(auth);
  while (Blynk.connect() == false) {}
}

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

Try changing this to:
Blynk.config(auth, "Blynk-cloud.com", 8080);

As your ISP may be blocking port 80

Pete.

1 Like

When the ip is received on the machine (dhcp server enable), there is a connection with Blynk. The provider does not block anything, it is checked.
Снимок экрана 2021-05-02 в 01.06.35

That sounds like a local networking problem, or an error in the network settings in your sketch

Pete.

1 Like

No problem with the network - 100%
I gave the sketch “as is”, where the problem is – me unknown.
I Added icmp check <Pinger.h> before connecting to Blynk.config(auth, “139.59.206.133”, 80);, output – dns resolving does not work:
When contacting Blynk.config(auth, “blynk-cloud.com”, 80); – there is no connection.
When referring to Blynk.config(auth, “139.59.206.133”, 80); – there is a connection!
The dns addresses themselves (8.8.8.8[google], 77.88.8.8[yandex] etc.) checked different ones.
How to solve the problem with the work of the dns client in <ESP8266WiFi.h>? Resolve IP by name does not work.

Serial Pinger test
Connecting to AP..........Ok

Pinging default gateway with IP 10.0.1.1
Reply from 10.0.1.1: bytes=32 time=9ms TTL=64
Reply from 10.0.1.1: bytes=32 time=2ms TTL=64
Reply from 10.0.1.1: bytes=32 time=1ms TTL=64
Reply from 10.0.1.1: bytes=32 time=2ms TTL=64
Ping statistics for 10.0.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0.00% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 9ms, Average = 3.50ms
Destination host data:
    IP address: 10.0.1.1
    MAC address: 86:c9:b2:a8:df:24

Pinging blynk-cloud.com
Error during ping command.

Pinging undefinedname
Error during ping command.

Pinging to ip 139.59.206.133
[34511] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on NodeMCU

[34515] Connecting to 139.59.206.133:80
Reply from 139.59.206.133: bytes=32 time=138ms TTL=54
[34801] Ready (ping: 133ms).
Reply from 139.59.206.133: bytes=32 time=66ms TTL=54
Reply from 139.59.206.133: bytes=32 time=65ms TTL=54
Reply from 139.59.206.133: bytes=32 time=65ms TTL=54
Ping statistics for 139.59.206.133:
    Packets: Sent = 4, Received = 4, Lost = 0 (0.00% loss),
Approximate round trip times in milli-seconds:
    Minimum = 65ms, Maximum = 138ms, Average = 83.50ms
Destination host data:
    IP address: 139.59.206.133

Why not stick with using the hard-coded IP address instead of blynk-cloud.com ?
It’s not a problem, as your Blynk project only exists on one of the three global cloud servers. In your case this is the one located in Frankfurt.

Pete.

1 Like

And if the project changes its IP address, me will have to change the firmware. And if it happens in a year, you can forget what the reason is =)
The standard example (sketch) it does not work for me, can you somehow solve it?

The server IPs haven’t changed in the past 5 years, and if you use IFTTT then the actual IP address has to be used to avoid Geo DNS issues, so it’s safe to use the IP address.

Pete.

1 Like