Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) ESP8266 wifi doesn't connect / visual studio 2017 (Read 7300 times)
Pappy.
Newbies
*
Offline


Posts: 6
Joined: Apr 14th, 2017
ESP8266 wifi doesn't connect / visual studio 2017
Apr 14th, 2017 at 9:38am
Print Post  
Hello together,
I'm new and I have a problem using the Visual Studio 2017 IDE with visualmicro.
When I upload a sketch to an ESP8266 with Visual Studio 2017, the ESP8266 doesn't connect to my wifi. Same sketch uploaded with Arduino IDE and the ESP8266 connects without problems.

The ESP8266 is on the NodeMCU 1.0 (same problem with WeMos D1 mini) board.

Code is from http://iot-playground.com/blog/2-uncategorised/40-esp8266-wifi-relay-switch-ardu...

Code (C++)
Select All
#include <ESP8266WiFi.h>

const char* ssid = "your-ssid";
const char* password = "your-password";

// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  delay(10);

  // prepare GPIO2
  pinMode(2, OUTPUT);
  digitalWrite(2, 0);
 
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
 
  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.println(WiFi.localIP());
}
 



Simple code like flashing LED over GPIO without wifi is no problem.
I would be very grateful if someone can help me.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #1 - Apr 14th, 2017 at 10:02am
Print Post  
Hi,

Please ensure the tool bar shows "Release" and not "Debug" then try the upload again.

Also confirm which version of the esp core you have installed?

Thanks
« Last Edit: Apr 14th, 2017 at 10:05am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Pappy.
Newbies
*
Offline


Posts: 6
Joined: Apr 14th, 2017
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #2 - Apr 14th, 2017 at 10:13am
Print Post  
After two days of searching, the answer is so simple Grin

Thank you very much for your quick answer. This solved the problem.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #3 - Apr 14th, 2017 at 10:16am
Print Post  
Thanks. It's important to check what was going wrong so I have a question.

Are you uploading with ip address or serial/com?

Thanks
  
Back to top
WWW  
IP Logged
 
Pappy.
Newbies
*
Offline


Posts: 6
Joined: Apr 14th, 2017
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #4 - Apr 14th, 2017 at 10:51am
Print Post  
I'm uploading with USB Serial (onboard USB, no extra adapter)
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #5 - Apr 14th, 2017 at 10:57am
Print Post  
Thanks.

Did you see "Connecting to " in the serial monitor when it did not connect?
  
Back to top
WWW  
IP Logged
 
Pappy.
Newbies
*
Offline


Posts: 6
Joined: Apr 14th, 2017
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #6 - Apr 14th, 2017 at 11:52am
Print Post  
Yes, it will hang in the while loop.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #7 - Apr 14th, 2017 at 3:37pm
Print Post  
Thanks I will try it. The debugger, in COM not IP mode, just uses serial which your code is already using so it will be interesting to find the issue.

By the way, possibly of no interest, the OTA upload is much faster than the serial upload.
  
Back to top
WWW  
IP Logged
 
Pappy.
Newbies
*
Offline


Posts: 6
Joined: Apr 14th, 2017
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #8 - Apr 15th, 2017 at 6:29am
Print Post  
For me serial is easier, because I don't know how to upload OTA. But I will definitely inform me how this works, thanks.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #9 - Apr 15th, 2017 at 5:43pm
Print Post  
Hi,

This issue is resolved in the next release although it might be something the esp team want to investigate. 

The debugger adds adds a small delay to the start of the mcu giving the serial monitor time to open and avoid missing the serial messages sent from the setup() method.

The delay() is injected into the temp build copy of the code at the start of the setup() as per the following example. In my tests, adding this single line of code to your example produces the result that you have described.

Below you can see that I have tested with a delay(3000) and that consistently causes a problem for me. Does it for you?

The next release doesn't bother with the delay if an esp board is selected.

Thanks

The interim update 1704.15 can be downloaded from here

Code
Select All
#include <ESP8266WiFi.h>

const char* ssid = "your-ssid";
const char* password = "your-password";

// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);

void setup() {
  delay(3000);  //<<<<< simulate debugger delay
  Serial.begin(115200);
  delay(10);

  // prepare GPIO2
  pinMode(2, OUTPUT);
  digitalWrite(2, 0);
 
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
 
  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.println(WiFi.localIP());
}
 

« Last Edit: Apr 15th, 2017 at 7:43pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Pappy.
Newbies
*
Offline


Posts: 6
Joined: Apr 14th, 2017
Re: ESP8266 wifi doesn't connect / visual studio 2017
Reply #10 - Apr 23rd, 2017 at 12:55pm
Print Post  
Hi,
sorry for the late answer, I'm back from holidays and tested your code now. The delay causes the same problem for me, too.
Thanks for the great and fast support.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint