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

Esp8266 shield manual IP


#1

Hi to all!I tried to connect arduino Mega with ESP8266 as shield.But i dont understend how connect to my locall server,default try to cnnect blynk.cloud.com.How can I change this setting and connect to the local server?

[code]#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
//#include <ESP8266_HardSer.h>
//#include <BlynkSimpleShieldEsp8266_HardSer.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “***************************”;

// Your WiFi credentials.
// Set password to “” for open networks.
char ssid[] = “******”;
char pass[] = “************”;

// Hardware Serial on Mega, Leonardo, Micro…
#define EspSerial Serial

// or Software Serial on Uno, Nano…
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(15, 14); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);
void setup()
{
// Debug console
Serial.begin(9600);

delay(10);

// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);

Blynk.begin(auth, wifi, ssid, pass);
}

void loop()
{
Blynk.run();
}
[/code]


#2

Example:

char server [] = "192.168.10.120";

Blynk.begin(auth, wifi, ssid, pass, server);

#3

Thank you very much, it works!One more question: How to assign a static IP?


#4

Take a look at the Ethernet examples and come back if you still have problems.

Edit: sorry you are not using Ethernet, see my later post.


#5

yes.And “IPAddress arduino_ip ( 10, 0, 0, 20);” not work


Mega 2560 + esp8266 v3
#6

Take a look at the ESP8266_Standalone_Manual_IP example in the Arduino IDE and GitHub.


#7

You can build completely custom connection handling, like shown in https://github.com/blynkkk/blynk-library/tree/master/examples/More/ArduinoClient
Of course it’s much easier when there’s a library for your hardware, that provides standard Arduino Client interface.


#8

Thanks, I will read and try


#9

Hi, A new problem arose, after a couple of minutes the connection is lost and the device does not want to reconnect.How to solve the problem of reconnecting on ESP8266 i know,but now I’m in difficulty.Can you help me?This is the connection log
[19]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.8 on Arduino Mega

[526] Connecting to home
AT
ATE0
AT+GMR
[3572] AT version:0.21.0.0
SDK version:0.9.5
AT+CIPMUX=1
AT+CWMODE?
AT+CWJAP=“",""
AT+CIFSR
[6614] +CIFSR:STAIP,“192.168.0.100”
+CIFSR:STAMAC,"
************”
[6614] Connected to WiFi
AT+CIPCLOSE=1
AT+CIPSTART=1,“TCP”,“192.168.0.156”,8442
AT+CIPSEND=1,37
*************************[41720] Ready (ping: 12ms).
hver 0.4.8 h-beat 10 buff-in 1024 deAT+CIPSEND=1,40
v Arduino Mega cpu ATmega2560 con ESP8266AT+CIPSEND=1,29
6 build Jul 6 1017 22:48:32 AT+CIPSEND=1,40
$1 i *****************************************AT+CIPSEND=1,1
AT+CIPSEND=1,13
1 vw 5 0
AT+CIPCLOSE=1

and my device is disconnect…