Подключение к 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

More than a year has passed and when I returned to this question, I saw my mistake! I didn’t specify dns server! =)
WiFi.config(device_ip, gateway_ip, subnet_mask);facepalm
WiFi.config(device_ip, gateway_ip, subnet_mask, dns_ip);

PS: Extremely high disappointment from closing the server for the new year and deleting the application from the AppStore! I paid for energy. I was ready to buy the app. But the very idea of a subscription and its price does not suit me. I’m willing to pay once, but I’m not ready all the time. The project turned out to be a scam. To ruin such an excellent idea =( In confirmation of this, hundreds of thousands of people continue to use the application and their servers. The old Blynk is the best thing in my life! There is no more trust in the new Blynk for such an attitude!

PPS: I understand that local servers ruined the project, deprived of funding. It’s a pity.

Sincerely.

Not exactly.
The concept of a one-off energy payment in exchange for a lifetime of server hosting isn’t economically viable. This meant that the business users were subsidising/funding the server rental and maintenance for all hobby users.
Not necessary a problem in itself, but one which Blynk fixed in their new billing model.

The local server concept was a good one but unfortunately it has been abused by some people, running commercial projects on their own servers. It’s debatable whether these people would have signed-up for a business contract under the old pricing model if local server hadn’t been available, but maybe some would.

As far as it being “scam”, you should look at how companies like Adobe handle licensing of products like Photoshop and then make your mind up about whether Blynk are defrauding users.

Hope you find a viable alternative to Blynk.

Pete.

1 Like