Hello,
I have to connect an ESP32 on a network with a static local IP address, I mean without using DHCP.
If I try the following sketch I get in return (with the serial debug).
but i can’t log in?
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
…[5676]
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
///_, /////_
/__/ v1.0.1 on ESP32
[5677] Connecting to blynk.cloud:80
[10678] Connecting to blynk.cloud:80
[15679] Connecting to blynk.cloud:80
…
Whereas if I use the second sketch it works, but Blynk.begin() does not allow me to connect my ESP32 with a fixed address on my network, how to solve this problem??
FIRST SKETCH
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example runs directly on ESP32 chip.
Note: This requires ESP32 support package:
https://github.com/espressif/arduino-esp32
Please be sure to select the right ESP32 module
in the Tools -> Board menu!
Change WiFi ssid, pass, and Blynk auth token to run :)
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID "xxxxxxxxxxxx"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxx";
char ssid[] = "Linksys-E1200";
char pass[] = "xxxxxxxxxx";
IPAddress device_ip (192, 168, 10, 222);
IPAddress dns_ip ( 8, 8, 8, 8);
IPAddress gateway_ip (192, 168, 10, 1);
IPAddress subnet_mask(255, 255, 255, 0);
void setup()
{
// Debug console
Serial.begin(115200);
delay(3000);
WiFi.config(device_ip, gateway_ip, subnet_mask);
WiFi.begin(ssid,pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Blynk.config(auth);
while (Blynk.connect() == false)
{ } // wait for Blynk to be connected
}
void loop()
{
Blynk.run();
delay(2000);
}
BLYNK_CONNECTED()
{
Serial.println ("Blynk connected Succesfully");
}
SECOND SKETCH
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example runs directly on ESP32 chip.
Note: This requires ESP32 support package:
https://github.com/espressif/arduino-esp32
Please be sure to select the right ESP32 module
in the Tools -> Board menu!
Change WiFi ssid, pass, and Blynk auth token to run :)
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID "xxxxxxxxxx"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxx";
// Set password to "" for open networks.
char ssid[] = "Linksys-E1200";
char pass[] = "xxxxxxxxxxx";
IPAddress device_ip (192, 168, 10, 222);
IPAddress dns_ip ( 8, 8, 8, 8);
IPAddress gateway_ip (192, 168, 10, 1);
IPAddress subnet_mask(255, 255, 255, 0);
void setup()
{
// Debug console
Serial.begin(115200);
delay(3000);
/*
WiFi.config(device_ip, gateway_ip, subnet_mask);
WiFi.begin(ssid,pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Blynk.config(auth);
while (Blynk.connect() == false) { // wait for Blynk to be connected
}
//Blynk.begin(auth, ssid, pass);
*/
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
delay(2000);
}
BLYNK_CONNECTED()
{
Serial.println ("Blynk connected Succesfully");
}
I get the following result:
[14134] Connected to WiFi
[14134] IP: 192.168.10.174
[14134]
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
///_, /////_
/__/ v1.0.1 on ESP32
[14140] Connecting to blynk.cloud:80
[14823] Ready (ping: 204ms).
Blynk connected Succesfully