Summary
ESP8266 modules are cheap and flexible microcontrollers. They can be purchased easily on AliExpress (https://www.aliexpress.com/item/1005006211265531.html) or elsewhere. They are one of many types of Arduino compatible microcontrollers.
VS Code is an Microsoft IDE that is common across the industry – https://code.visualstudio.com/
The below page focuses on the requirements to program the module in Linux.
Plug-in
To program an Arduino style unit the VS Code, you’ll need the Arduino extension (Marketplace Link: https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino). Once installed, it will prompt for the Arduino CLI, choose to use the “built in” CLI at this point.
In Linux the Arduino CLI will be saved in ~/.vscode/extensions/vsciot-vscode.vscode-arduino-0.6.0-linux-x64/assets/platform/linux-x64/arduino-cli/arduino-cli.app
Note that the Arduino CLI required the file name to match the directory name. For example, test-project.ino
needs to be stored in a directory name something like ~/coding/arduino/test-project
VS Code Settings
The project directory also needs to have a .vscode
directory that contains an arduino.json
file. This file needs to contain the details of the microcontroller and the project, such as:
{
"configuration": "xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,eesz=4M2M,led=2,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200",
"board": "esp8266:esp8266:nodemcuv2",
"port": "/dev/ttyUSB0",
"sketch": "test-project.ino",
"output": "./build"
}
VS Code Interface
VS Code will show icons for running code near the .ino file tab. Rollover tips will show the action for each icon.
The status bar at the bottom of the screen shows details of the selected module and port.
Arduino CLI
Updates to the CLI can be done with a command like~/.vscode/extensions/vsciot-vscode.vscode-arduino-0.6.0-linux-x64/assets/platform/linux-x64/arduino-cli/arduino-cli.app update
Arduino code will often rely on libraries. You can find the exact library name with/.vscode/extensions/vsciot-vscode.vscode-arduino-0.6.0-linux-x64/assets/platform/linux-x64/arduino-cli/arduino-cli.app lib search "ArduinoJSON" | grep "Name:"
The library can then be installed with~/.vscode/extensions/vsciot-vscode.vscode-arduino-0.6.0-linux-x64/assets/platform/linux-x64/arduino-cli/arduino-cli.app lib install "
sonArduinoJ
"
ESP8266 programming
To ensure the current user account can access the serial ports, runsudo usermod -a -G dialout $USER
and then logout and log back in.
Run lsusb
to ensure that module is recognised. Generally a device name of QinHeng Electronics CH340 serial converter
will be shown.
Run dmesg | grep tty
to see which device is assigned, typically something like /dev/ttyUSB0