Hardware can not connect to local server

Hi. nodemcu can not connect to local server but connect to cloud

the server version is: 0.33.0
android app can successfully register and login to local server on port 9443

the sketch:

#include <DHT.h>                                      //Declarate DHT Library
#include <ESP8266WiFi.h>                              //Declarate ESP8266 Board Library
#include <BlynkSimpleEsp8266.h>
#define DHTPIN 4                                      //Pin of DHT 22
#define DHTTYPE DHT22                                 //Type of DHT
                                      
DHT dht(DHTPIN, DHTTYPE);                             //Declarate dht

int val = 0;                                          //Declarate val variable
char auth[] = "976f5e30be0c47c2ac50d5b027b03bf0";                 //Put your blink token
char ssid[] = "MikroTik Home";                            //Put your SSID of your connection
char pass[] = "123456";                            //Put your Password of your connection
char server[] = "10.5.51.3";
 
void setup() {  
  Blynk.begin(auth, ssid, pass, server);                      //Connect the blynk to esp8266 board                          
  dht.begin();                                        //Start DHT sensor                                              
}

void loop() {
  Blynk.run();                                        //Run the Blynk                                                                              
  float h = dht.readHumidity();                       //Read humidity and put it in h variable                             
  float t = dht.readTemperature();                    //Read temperature and put it in t variable                        
  float q = analogRead(A0);                           //Read air quality and put it into q variable                                  
  Blynk.virtualWrite(V5, t);                          //Send t value to blynk in V5 virtual pin                                 
  Blynk.virtualWrite(V6, h);                          //Send h value to blynk in V6 virtual pin                                 
  Blynk.virtualWrite(V0, q);                          //Send q value to blynk in V0 virtual pin        
  if (q>100) {                                              
    Blynk.notify("The Quailty of air is bad !!");     //Blynk will send notify if q>70
  }
  if (t>40) {
    Blynk.notify("The Temperature is too high");      //Blynk will send notify if t>40
  }
}

thanks for reply. I add #define BLYNK_DEFAULT_PORT 8080 to sketch but not working yet.

Try to put it under “include” sections.

1 Like

not fixed :frowning:

Than please other option from topic above

I trying all solutions on the forum but doesn’t help :sob:

Give this a try

  Blynk.begin(auth, ssid, pass, server, 8080);
3 Likes

Thanksssss ! you solved my problem :heart_eyes::kissing_heart:

1 Like

Clearly not all of them :wink: … having the new port 8080 right in the Blynk.begin() or Blynk.config() is referenced in the topic link above, and shown as an option in all the examples, not to mention all over this forum.

Good catch @Shadeyman :slight_smile:

One of these days we will get past this port changeover situation… one of these days…

2 Likes

Apart from what others have said, I’ll repeat what I’ve seen @Gunner, @Costas and @Pete say often. I did take that advice seriously and implemented it. Made my code stable, readable and easy to debug. Keep your loop simple such as

void loop()
{
blynk.run();
timer.run();
}

Invoke all other calls through timers. virtualWrites in loop is a big no.

2 Likes