Sunday, 30 April 2017

Tips for using Visual Studio Code with a NodeMCU

I am now working on the code for my project. There are a few things to know to be able to use the Ardino libraries for a NodeMCU with Visual Studio Code as the IDE.

Here are the things I needed to know:

Serial Monitor

You need to open the serial monitor BEFORE uploading the sketch to the device.


Go to the View Command Palette (F1) menu and select:
Arduino: Open Serial Monitor

If the serial monitor is not already open, any initial serial output will not be displayed.


Once open, set the COM port and the speed. I always use 115,200 baud.

If the serial monitor is already open, the implementation of the Arduino Visual Studio Code extension that I am using, temporarily disables the serial monitor for the upload and then pops it in to view and connects immediately after uploading the sketch. This is very handy behaviour.

Keep an eye out for the monitor being closed due to errors! It just needs to be re-opened.

Uploading Sketches

This has the same behaviour as the Arduion IDE. It compiles and uploads as one function.

Go to the View Command Palette (F1) menu and select:
Arduino: Upload (Ctrl+Alt+U)


This displays the OUTPUT window for the Arduino.
When complete, if the serial monitor is already open, it will re-connect the monitor and display the serial monitor window, usually.
Where I have had errors I have found the monitor does not automatically re-open!

The Config file


If, like me, you use a NAS box for storage you might end up having to enter a library path to an IP address or host name.
If you do that, remember to double double escape '\\\\' the initial path variables in the config file:
c_cpp_properties.json

{
"configurations": [
{
  "name": "Win32",
  "includePath": [
    "C:\\Users\\you\\AppData\\Local\\Arduino15\\packages\\esp8266",
    "\\\\192.168.0.100\\users\\you\\Documents\\Arduino\\libraries"
],
  "browse": {
  "limitSymbolsToIncludedHeaders": false,
  "path": [
    "C:\\Users\\you\\AppData\\Local\\Arduino15\\packages\\esp8266",
    "\\\\192.168.0.100\\users\\you\\Documents\\Arduino\\libraries"
]}}]
}

==

I'll add to the above as I learn more.

==

No comments :