Mega 2560 + esp8266 v3

I can’t use:
IPAddress local_IP(192, 168, 1, 40);IPAddress gateway(192, 168, 1, 202);IPAddress subnet(255, 255, 255, 0);IPAddress primaryDNS(8, 8, 8, 8);IPAddress secondaryDNS(8, 8, 4, 4);
I can not use in conjunction Mega and ESP8266, only dhcp. Help me find a solution.

I use this example:
https://examples.blynk.cc/?board=Arduino%20Mega%202560&shield=ESP8266%20WiFi%20Shield&example=GettingStarted%2FBlynkBlink

I connect mega and esp gnd-gnd, vin-vin, tx-rx, rx-tx

two solutions :

  1. go to your router and make a reservation for that mac address.
  2. Post your full code, we have some really good community members that might be able to spot the error pretty quick.

Full code in example

Youre joking , right ?

Forget Blynk for a second, how do you normally get this board up and running with that ip address / mask ?

Is there a problem with reserving it on your router? Why are you trying to do this in the first place?

This board does not, but in conjunction with the eps8266 why not? After dhcp works. Just in the library for this bunch there are no indications of what I need.
My idea is to add the necessary functions to the library.

i can add:
#include <IPAddress.h> //for IPAddress local_IP(192, 168, 1, 40);…
and i think it is the solution for my question

but when i add
#include <WiFi.h>
there is error: Compilation error for Arduino/Arduino Mega or Mega 2560.

A search of the forums showed me this guy got it working.

Do you test it?

there is error: Compilation error for Arduino/Arduino Mega or Mega 2560.

That is because you are using a command that has no place with an ESP as shield secerio, thus not part of the “As shield” library.

With AT firmware, the ESP becomes a simple Serial to WiFi transceiver and is not directly programmable. Instead you use a Blynk Library and commands compatible with the Arduino.

i am sure it can work.
if you are running a bunch of dhcp, the rest is just things that needed to be done.
here is the code:

#define BLYNK_PRINT Serial
#define EspSerial Serial2
#define ESP8266_BAUD 115200  
#include <ESP8266_Lib.h>              //u can download it https://goo.gl/9FcFSF
#include <BlynkSimpleShieldEsp8266.h>  //u can download https://goo.gl/QSPHVP
ESP8266 wifi(&EspSerial);
char auth[] = "***********";char ssid[] = "********";char pass[] = "**********";




/////////////my addons
#include <IPAddress.h>     //include it and IPAddress work!!!
//it is already work!!!!!!! but i have to test it...
IPAddress local_IP(192, 168, 1, 40);IPAddress gateway(192, 168, 1, 202);IPAddress subnet(255, 255, 255, 0);IPAddress primaryDNS(8, 8, 8, 8);IPAddress secondaryDNS(8, 8, 4, 4);

char blynkserver[] = "192,168,1,205";   //it is need for Blynk.begin(auth, wifi, ssid, pass, blynkserver, 8080); - it is mistake when use ip adress directly

#include <WiFi.h> //for message? does not work...
//////////////// end of my addons




void setup()
{  Serial.begin(9600);

  //does not work help with it///////////////////////////////////////////////
  /*
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {    Serial.println("STA Failed to configure");  }  Serial.print("Connecting to ");  Serial.println(ssid);  WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {    delay(500);    Serial.print(".");  }
Serial.println("");  Serial.println("WiFi connected!");  Serial.print("IP address: ");  Serial.println(WiFi.localIP());  Serial.print("ESP Mac Address: ");  Serial.println(WiFi.macAddress());  Serial.print("Subnet Mask: ");  Serial.println(WiFi.subnetMask());  Serial.print("Gateway IP: ");  Serial.println(WiFi.gatewayIP());  Serial.print("DNS: ");  Serial.println(WiFi.dnsIP());  
////////////////////////////////////////
 */

  EspSerial.begin(ESP8266_BAUD);
  delay(10);
Blynk.begin(auth, wifi, ssid, pass, blynkserver, 8080);
}

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

AFAIK there is no “official” Blynk way to set static IPs for Arduino with ESP as shield configuration.

There are a few references about it in this forum - Esp8266 shield manual IP But mostly beyond my thinking abilities right now :stuck_out_tongue: so I will have to step back and watch. Besides, I just use DHCP and set IP reservations in my router based on MAC.

one more way:
To configure a separate ESP as the reader port of the Mega and the sender to the Blynk.
Question how to assign data from rx / tx to a virtual Blynk port.

Or take esp8266 and PCF8575 and CD74HC4067 and throw Mega 2560

I’d start by increasing this number.

razorline

2 Likes