*** [upload] Com3firmware.bin: No Such File or Directory
Learn how to program the ESP32 and ESP8266 NodeMCU boards using VS Code (Microsoft Visual Studio Lawmaking) with PlatformIO IDE extension. We cover how to install the software on Windows, Mac OS X or Ubuntu operating systems.
The Arduino IDE works great for pocket-sized applications. Still, for avant-garde projects with more than than 200 lines of code, multiple files, and other advanced features like auto completion and error checking, VS Code with the PlatformIO IDE extension is the best alternative.
In this tutorial, we'll encompass the following topics:
- Installing VS Code (Visual Studio Code):
- A) Windows
- B) Mac OS X
- C) Linux Ubuntu
- Installing PlatformIO IDE Extension on VS Lawmaking
- Visual Studio Quick Interface Overview
- PlatformIO IDE Overview
- Uploading Code using PlatformIO IDE: ESP32/ESP8266
- Irresolute the Serial Monitor Baud Rate – PlatformIO IDE
- Installing Libraries on PlatformIO IDE
A) Installing VS Code on Windows (Visual Studio Code)
Become to https://code.visualstudio.com/ and download the stable build for your operating system (Windows).
Click on the installation sorcerer to first the installation and follow all the steps to complete the installation. Accept the understanding and press the Next button.
Select the following options and click Next.
Printing the Install push button.
Finally, click Finish to terminate the installation.
Open up VS Lawmaking and you'll be greeted past a Welcome tab with the released notes of the newest version.
That'due south it. Visual Studio Code was successfully installed.
Installing Python on Windows
To programme the ESP32 and ESP8266 boards with PlatformIO IDE you need Python 3.5 or higher installed in your computer. We're using Python 3.viii.5.
Go to python.org/download and download Python 3.8.5 or a newest version.
Open the downloaded file to start the Python installation magician.
The following window shows up.
Important: Make sure y'all check the choice Add Python 3.viii to PATH. And so, you tin click on the Install At present button.
When the installation is successful you'll get the post-obit message.
You tin can click the Close push.
At present, become to this section to install PlatformIO IDE extension.
B) Installing VS Code on Mac OS 10 (Visual Studio Code)
Go to https://code.visualstudio.com/ and download the stable build for your operating system (Mac OS 10).
After downloading the Visual Studio Code awarding file, you'll exist prompted with the following message. Press the "Open" button.
Or open your Downloads folder and open Visual Studio Code.
After that, you lot'll exist greeted by a Welcome tab with the released notes of the newest version.
That's it. Visual Studio Code was successfully installed.
Installing Python on Mac OS X
To program the ESP32 and ESP8266 boards with PlatformIO IDE you need Python 3.5 or higher installed in your computer. We're using Python 3.8.5.
To install Python I'll be using Homebrew. If you don't have the brew command available, type the next command:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
And so, run the mash command to install Python 3.X:
$ mash install python3
Now, go to this section to install PlatformIO IDE extension.
C) Installing VS Code on Linux Ubuntu (Visual Studio Code)
Go to https://code.visualstudio.com/ and download the stable build for your operating system (Linux Ubuntu).
Salvage the installation file:
To install information technology, open a Terminal windows, navigate to your Downloads binder and run the following control to install VS Code.
$ cd Downloads ~/Downloads $ sudo apt install ./code_1.49.1-1600299189_amd64.deb When the installation is finished, VS Lawmaking should be bachelor in your applications menu.
Open up VS Code and you lot'll be greeted by a Welcome tab with the released notes of the newest version.
That's it. Visual Studio Code was successfully installed.
Installing Python on Linux Ubuntu
To program the ESP32 and ESP8266 boards with PlatformIO IDE you need Python 3.v or college installed in your calculator. We're using Python three.viii.
Open the Terminal window and check that you already accept Python 3 installed.
$ python3 --version python iii.8.2
As y'all tin can run across in the preceding figure, Python three.8.2 is already installed.
If you don't have Python 3.viii.X installed, run the next command to install it:
$ sudo apt install python3 Whether you lot already have Python installed or not, you need to run the following command to install Python utilities.
$ sudo apt install python3-distutils
Now, go to this section to install PlatformIO IDE extension.
Installing PlatformIO IDE Extension on VS Code
It is possible to program the ESP32 and ESP8266 boards using VS Code with the PlatformIO IDE extension. Follow the next steps to install the PlatformIO IDE extension.
Open up VS Code:
- Click on the Extensions icon or printing Ctrl+Shift+10 to open the Extensions tab
- Search for "PlatformIO IDE"
- Select the outset option
- Finally, click the Install button (Note: the installation may take a few minutes)
Afterwards installing, make certain that PlatformIO IDE extension is enabled every bit shown below.
Subsequently that, the PlatformIO icon should prove upward on the left sidebar likewise equally an Home icon that redirects you to PlatformIO home.
That's information technology, PlatformIO IDE extension was successfully added to VS Code.
If y'all don't see the PIO icon and the quick tools at the bottom, you may need to restart VS code for the changes to take issue.
Either style, we recommend restarting VS Code before proceeding.
VS Code Quick Interface Overview
Open VS Code. The following print screen shows the significant of each icon on the left sidebar and its shortcuts:
- File explorer
- Search across files
- Source lawmaking management (using gist)
- Launch and debug your lawmaking
- Manage extensions
Additionally, you tin press Ctrl+Shift+P or go to View > Command Palette… to show all the available commands. If you're searching for a control and you don't know where it is or its shortcut, you merely demand to become to the Command Palette and search for information technology.
At the bottom, in that location'due south a blue bar with PlatformIO commands.
Here's the what icon does from left to right:
- PlatformIO Home
- Build/Compile
- Upload
- Clean
- Serial Monitor
- New Concluding
If you hover your mouse over the icons, information technology will show what each icon does.
Alternatively, you can also click on the PIO icon to meet all the PlatformIO tasks.
If the tasks don't show up on your IDE when you click the icon, y'all may demand to click on the 3 dot icon at the pinnacle and enable PlatformIO tasks every bit shown below.
PlatformIO IDE Overview
For yous to get an overview on how PlatformIO works on VS code, nosotros'll show you how to create, save and upload a "Blinking LED" sketch to your ESP32 or ESP8266 board.
Create a New Project
On VS Lawmaking, click on the PlartfomIO Domicile icon. Click on + New Project to start a new project.
Give your projection a proper noun (for example Blink_LED) and select the board you're using. In our instance, we're using the DOIT ESP32 DEVKIT V1. The Framework should exist "Arduino" to utilise the Arduino core.
You can cull the default location to relieve your project or a custom location.
The default location is in this path Documents >PlatformIO >Projects. For this test, you lot tin use the default location. Finally, click "Finish".
For this example, we'll be using the DOIT ESP32 DEVKIT board. If y'all are using an ESP8266 NodeMCU board the process is very like, you just need to select your ESP8266 board:
The Blink_LED project should be accessible from the Explorer tab.
VS Code and PlatformIO have a binder structure that is different from the standard .ino projection. If you click on the Explorer tab, you'll see all the files it created under your projection folder. It may seem a lot of files to work with. But, don't worry, usually you'll just demand to bargain with one or ii of those files.
Warning: y'all shouldn't delete, modify or movement the folders and the platformio.ini file. Otherwise, yous will no longer exist able to compile your project using PlatformIO.
platformio.ini file
The platformio.ini file is the PlatformIO Configuration File for your project. Information technology shows the platform, board, and framework for your project. You tin also add together other configurations like libraries to be included, upload options, irresolute the Serial Monitor baud rate and other configurations.
- platform: which corresponds to the SoC used by the board.
- board: the development board you're using.
- framework: the software surroundings that volition run the projection code.
With the ESP32 and ESP8266, if you want to apply a baud rate of 115200 in your Serial Monitor, you just need to add together the following line to your platformio.ini file.
monitor_speed = 115200 After that, make sure y'all salvage the changes fabricated to the file by pressing Ctrl+South.
In this file, y'all can likewise include the identifier of libraries yous'll use in your projection using the lib_deps directive, as we'll run into later.
src folder
The src folder is your working folder. Nether the src folder, at that place's a chief.cpp file. That's where you write your code. Click on that file. The structure of an Arduino program should open up with the setup() and loop() functions.
In PlatformIO, all your Arduino sketches should start with the #include <Arduino.h>.
Uploading Code using PlatformIO IDE: ESP32/ESP8266
Re-create the post-obit code to your principal.cpp file.
/********* Rui Santos Complete project details at https://RandomNerdTutorials.com/vs-code-platformio-ide-esp32-esp8266-arduino/ *********/ #include <Arduino.h> #ascertain LED 2 void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode(LED, OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(LED, HIGH); Serial.println("LED is on"); delay(thou); digitalWrite(LED, LOW); Serial.println("LED is off"); filibuster(1000); } View raw code
This code blinks the on-board LED every second. It works with the ESP32 and ESP8266 boards (both have the on-lath LED continued to GPIO ii).
We recommend that you re-create this lawmaking manually, so that you see the autocompletion and other interesting features of the IDE in action. Additionally, if yous take a syntax error somewhere in your program, it volition underline it in red fifty-fifty before compiling.
After that, press Ctrl+South or become to File > Salvage to save the file.
Now, you can click on the Upload icon to compile and upload the code. Alternatively, yous can become to the PIO Projection Tasks carte du jour and select Upload.
If the code is successfully uploaded, you should go the following message.
After uploading the code, the ESP32 or ESP8266 should be blinking its on-lath LED every 2d.
Now, click on the Serial Monitor icon and you should see it printing the current LED land.
Note: if you don't come across the Terminal window, go to the carte du jour Terminal > New Terminal.
Observe COM Port
PlatformIO will automatically detect the port your lath is connected to. To bank check the connected devices you can go to the PIO Dwelling house and click the Devices icon.
Troubleshooting
If when trying to upload code y'all get the post-obit error: "Failed to connect to ESP32: Timed out waiting for parcel header" it usually means that your board is not in flashing manner when yous're uploading the code.
When this happens you lot need to printing the ESP32 on-lath Kicking button when y'all commencement seeing a lot of dots in the debugging window.
If you don't want to accept to press the Boot push button every time y'all upload new code, you can follow this guide: [SOLVED] Failed to connect to ESP32: Timed out waiting for packet header.
Changing the Serial Monitor Baud Rate – PlatformIO IDE
The default baud rate used by PlatformIO is 9600. However, information technology is possible to set up a dissimilar value equally mentioned previously. On the File Explorer, nether your project folder, open the platformio.ini file and add the following line:
monitor_speed = baud_rate For case:
monitor_speed = 115200
After that, salve that file.
Installing ESP32/ESP8266 Libraries on PlatformIO IDE
Follow the next procedure if you need to install libraries in PlatformIO IDE.
Click the Dwelling house icon to go to PlatformIO Dwelling house. Click on the Libraries icon on the left side bar.
Search for the library you lot want to install. For case Adafruit_BME280.
Click on the library you want to include in your project. Then, click Add to Project.
Select the project were you desire to use the library.
This will add the library identifier using the lid_deps directive on the platformio.ini file. If you open up your project's platformio.ini file, it should look equally shown in the following image.
Alternatively, on the library window, if you select the Installation tab and roll a bit, you'll see the identifier for the library. You lot can cull any of those identifiers depending on the options you lot want to utilize. The library identifiers are highlighted in red.
Then, go to the platformio.ini file of your project and paste the library identifier into that file, like this:
lib_deps = adafruit/Adafruit BME280 [email protected]^2.1.0 If you need multiple libraries, you can separate their name by a coma or put them on different lines. For example:
lib_deps = arduino-libraries/Arduino_JSON @ 0.1.0 adafruit/Adafruit BME280 Library @ ^two.one.0 adafruit/Adafruit Unified Sensor @ ^1.ane.4 PlatformIO has a congenital-in powerful Library Manager, that allows y'all to specify custom dependencies per project in the Projection Configuration File platformio.ini using lib_deps. This will tell PlatformIO to automatically download the library and all its dependencies when you salvage the configuration file or when y'all compile your project.
Open a Project Binder
To open an existing project folder on PlatformIO, open VS Code, go to PlatformIO Home and click on Open Project. Navigate through the files and select your project folder.
PlatformIO will open all the files within the project folder.
VS Code Color Themes
VS Lawmaking lets you cull between unlike color themes. Go to the Manage icon and select Color Theme. Yous can then select from several different light and nighttime themes.
Shortcuts' Listing
For a consummate list of VS Code shortcuts for Windows, Mac Bone Ten or Linux, check the next link:
- VS Code Keyboard Shortcuts Reference.
Wrapping Upwardly
In this tutorial you've learned how to install and set up Visual Studio Code to work with the ESP32 and ESP8266 boards. VS Lawmaking with the PlatformIO IDE extension is a dandy culling to the classical Arduino IDE, specially when you're working on more avant-garde sketches for larger applications.
Hither'due south some of the advantages of using VS Code with PlatformIO IDE over Arduino IDE:
- It detects the COM port your board is continued to automatically;
- VS Code IntelliSense: Auto-Complete. IntelliSense code completion tries to estimate what you want to write, displaying the different possibilities and provides insight into the parameters that a function may expect;
- Error Highlights: VS Code + PIO underlines errors in your lawmaking before compiling;
- Multiple open tabs: y'all tin can have several lawmaking tabs open at once;
- You can hide certain parts of the code;
- Advanced code navigation;
- And much more than…
If you lot're looking for a more avant-garde IDE to write your applications for the ESP32 and ESP8266 boards, VS Code with the PlatformIO IDE extension is a great option.
Nosotros hope y'all've constitute this tutorial useful. If you like ESP32 and ESP8266, check the post-obit resource:
- Learn ESP32 with Arduino IDE (eBook + form)
- Dwelling Automation using ESP8266 (eBook)
- More ESP32 Projects and Tutorials…
- More ESP8266 Projects and Tutorials…
Source: https://randomnerdtutorials.com/vs-code-platformio-ide-esp32-esp8266-arduino/
0 Response to "*** [upload] Com3firmware.bin: No Such File or Directory"
Post a Comment