I’m trying to make a local server. Unable to specify IP in sketch.
The example says IPAddress(xxx,xxx,xxx,xxx), 8080. But I get an error ‘IPAddress’ was not declared in this scope.
The libraries I use are <ESP8266_Lib.h><BlynkSimpleShieldEsp8266.h>. Blynk version 1.1.0
You need to post your full sketch, correctly formatted with triple backticks.
Pete.
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <WidgetRTC.h>
char auth[] = "******************************************";
BlynkTimer timer;
WidgetTerminal terminal(V15);
WidgetRTC rtc;
char ssid[] = "***************";
char pass[] = "***************";
#define EspSerial Serial3
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
#define BLYNK_MAX_READBYTES 1024
void setup() {
EspSerial.begin(ESP8266_BAUD);
Blynk.config(wifi, auth, IPAddress(192,168,0,50), 8080);
Blynk.connectWiFi(ssid, pass);
Blynk.connect();
}
void loop() {
timer.run(); //
if (Blynk.connected()) { // If connected run as normal
Blynk.run();}
}
You have the wrong format for the Blynk.begin command. It should be…
Blynk.begin(auth, wifi, ssid, pass, IPAddress(xxx,xxx,xxx,xxx), port);
Pete.
It was not Blynk.begin. It’s Blynk.config.
So, this code is not working alsow:
void setup() {
EspSerial.begin(ESP8266_BAUD);
Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,0,50),8080);
}
’IPAddress’ was not declared in this scope
Apologies, I wasn’t paying attention.
Exactly what hardware are you using, and what board type do you have selected in your Arduino IDE ?
Pete.
I use Arduino Mega with ESP8266 on board.
In the IDE selected “Arduino Mega or Mega 2560”
Have you tried
Blynk.config(auth);
?
This is interesting.
I tried compiling the sketch and get the same error message, then did as bit of experimenting.
It seems that you can’t use IPAddress
when you use the BlynkSimpleShieldEsp8266.h
library as the transport layer.
When you look at the BlynkSimpleShieldEsp8266.h
library it actually has a comment that says:
//TODO: IPAddress
and although I’d seen this before, I didn’t understand it’s relevance.
The solution would probably be to replace IPAddress(192,168,0,50)
with "192.168.0.50"
something like this:
Blynk.config(wifi, auth, "92.168.0.50"), 8080);
Note that when you use quotes like this you need to use dots instead of commas as the separators.
Pete.
I saw it too, but I didn’t think it would surprise you.
I tried
Blynk.config(wifi, auth, "192.168.0.50", 8080);
but I thought it was the wrong format. But it seems to be something else.
[2957] Connecting to TP-Link_C082
[6007] WIFI GOT IP
AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
OK
[13156] +CIFSR:STAIP,“192.168.0.165”
+CIFSR:STAMAC,“bc:ff:4d:2c:c3:98”
[13165] Connected to WiFi
[23297] <[1D|00|01|00] ---------------------token------------------
[23804] Ready (ping: 445ms).
[23805] Free RAM: 5130
[23871] <[11|00|02|00]hver[00]1.1.0[00]h-beat[00]45[00]buff-in[00]1024[00]de
[23993] <v[00]Arduino Mega[00]cpu[00]ATmega2560[00]con[00]ESP826
[24057] <6[00]build[00]Jul 6 2022 10:28:40[00]
[24135] >[00|00|02|00|C8]
[24165] <[11|00|03|00|08]rtc[00]sync
Connected
[24266] >[11|00|03|00|0E]
[24266] >rtc[00]1657103410
[24267] Time sync: OK
[24290] <[14|00|04|00|0D]vw[00]11[00]102.000
[24443] <[14|00|05|00|0D]vw[00]12[00]100.000
[24586] <[14|00|06|00|0D]vw[00]13[00]100.000
[24882] <[14|00|07|00|0C]vw[00]14[00]60.000
[25279] <[14|00|08|00|0E]vw[00]23[00]6553.000
[25703] <[14|00|09|00|09]vw[00]34[00]100
[25831] <[14|00|0A|00|09]vw[00]35[00]100
[25939] <[14|00|0B|00|07]vw[00]10[00]1
[29154] <[14|00|0C|00|07]vw[00]50[00]1
[39181] Cmd error
That’s a really long ping time, and for a local server setup I’d expect to be seeing sub 10ms and probably in the 2-4ms range. I guess that this could be causing your “Cmd error” message.
What hardware are you using for your local server?
Have you tried rebooting your router, any WiFi repeaters and any ethernet switches you have on your network?
Is your Mega/ESP-01 in a location where you’d expect to get a strong WiFi signal?
Pete.
Server: Raspberry Pi 3b, connected by the cabel to the router.
WiFi signal from the Esp -62/-102 dBm.
Could it be a problem that HomeAssistant is running on the same server?
… Rebooting the router seems to have helped. Mega online. But Ping 92ms.
I don’t know, I’ve only ever dabbled with HA and I didn’t like it.
That’s certainly better. I guess you could try stopping you HA server and see if that helps.
Pete.
Stopping HA had no effect. After several reboots Ping 20ms.
Apparently, this is all that can be done.
Thank you.
As I always said, better use esp32 for only $4 instead of old Mega/ESP-01 obsolete boards