-->
Page 1 of 1

NodeMCU 1.0 controlled by Blynk App can't create HTTP server

PostPosted: Wed Jan 04, 2017 7:25 pm
by rayvburn
Hello and welcome, it’s my first post here.
The issue I’m facing is I can’t manage my NodeMCU 1.0 board to work as WebServer and simultaneously have connection with Blynk web server. I’m working in Arduino IDE, using Blynk library for Arduino 0.4.3. I have some data I want to send to server and also I need to control some pins of NodeMCU. I simply pasted the code from HelloServer example into my program but it didn't work. I tried to trim the majority of my code just to check what can be the problem. So you can see my setup() and loop() here:

Code: Select allvoid setup() {
 
  Serial.begin(9600);
 
  Blynk.begin(auth, ssid, pass);

  delay(3000);
 
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp8266")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);
  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
   
}


Code: Select allvoid loop() {
 
  server.handleClient();
  Blynk.run();
 
}


Code: Select allvoid handleRoot() {
  server.send(200, "text/plain", Bufor);
}

void handleNotFound() {
  String message = "*";
  server.send(404, "text/plain", message);
}


When I have Blynk.begin() before WiFi.begin() in the serial monitor I just see dots (so I guess NodeMCU can’t connect to my hotspot) and NodeMCU doesn’t start HTTP server. When I have WiFi.begin() before Blynk.begin() I see in the serial monitor that HTTP server started, but NodeMCU can’t connect to Blynk web server and I can’t control pins with my phone app.
The HelloServer example from ESP8266 library works flawlessly. As well as controlling pins from app without forcing NodeMCU to handle HTTP server.
Do you guys know the solution or lead me into right direction finding it?
Thanks