Before proceeding further, be sure to follow the info. at Part 1 and Part 2 to setup and VS Code and PlatformIO.
1. Click on the "PlatformIO: Home" icon at the bottom of the window.
2. Then click on the "Libraries" icon.
3. Enter the name of the library to be installed (in this case "pubsubclient"), then click the search button.
Click on the name of the library (in red circle).
4. Click on the "Install to..." icon (the "..." part of the Install icon) to install the library to a specific project folder. If you want the library to be visible to all projects, click on the "Install" part to install the library to the Global storage.
The default is "Global storage".
5. Click on "Global storage", select the project to which the library will be installed to.
In my case, it's "ESP8266 Arduino Projects".
Note, When the library is installed to a project folder, the library will only be visible to that specific project. When the library is installed to Global storage, the library will be visible to all the projects.
Scroll down and click the "Install" button to install the library.
6. The installed library is placed under "piolibdeps".
Left click on "piolibdeps" to see the installed library.
Note,
The library installed for the specific project is under the project's folder. In my case, the library is at "C:\Users\WeiHsiungHuang\Documents\PlatformIO\Projects\ESP8266 Arduino Projects\.piolibdeps\PubSubClient_ID89".
For libraries installed to "Global storage", they are kept under "C:\Users\WeiHsiungHuang\.platformio\lib".
To manage libraries in global storage, use "platformio lib --global list" or specify custom storage "platformio lib --storage-dir /path/to/storage/ list".
For instance, running the command "platformio lib --global list" in terminal window will display info. of the libraries installed in global storage.
To remove a library in global storage, use the command "platformio lib -g uninstall library_name". For instance, issue "platformio lib -g uninstall PubSubClient" will remove the PubSubClient library from global storage.
To check the installed library for specific project, use the command below (replace the part highlighted in red and underlined with the directory to your projects.
"platformio lib --storage-dir C:\Users\WeiHsiungHuang\Documents\PlatformIO\Projects\ list"
IMPORTANT!! There shall not be space in project / folder name. For info. on how to rename the folder, please refer to the section on how to rename / remove PlatformIO project folder at the end of this post.
To remove a library in project folder, use the command "platformio lib -d /path/to/dir uninstall [LIBRARY...]".
For instance, the command below will remove the PubSubClient library from "ESP8266_Arduino_Projects".
"platformio lib -d C:\Users\WeiHsiungHuang\Documents\PlatformIO\Projects\ESP8266_Arduino_Projects\ uninstall PubSubClient"
C:\>platformio lib --storage-dir C:\Users\WeiHsiungHuang\Documents\PlatformIO\Projects\ESP8266_Arduino_Projects\ list Library Storage: C:\Users\WeiHsiungHuang\Documents\PlatformIO\Projects\ESP8266_Arduino_Projects\.piolibdeps PubSubClient ============ #ID: 89 A client library for MQTT messaging. MQTT is a lightweight messaging protocol ideal for small devices. This library allows you to send and receive MQTT messages. It supports the latest MQTT 3.1.1 protocol and can be configured to use the older MQTT 3.1 if needed. It supports all Arduino Ethernet Client compatible hardware, including the Intel Galileo/Edison, ESP8266 and TI CC3000. Version: 2.6 Homepage: http://pubsubclient.knolleary.net Keywords: ethernet, mqtt, iot, m2m Compatible frameworks: arduino Compatible platforms: atmelavr, atmelsam, espressif8266, intel_arc32, microchippic32, nordicnrf51, teensy, timsp430 Authors: Nick O'Leary C:\>platformio lib -d C:\Users\WeiHsiungHuang\Documents\PlatformIO\Projects\ESP8266_Arduino_Projects\ uninstall PubSubClient Library Storage: C:\Users\WeiHsiungHuang\Documents\PlatformIO\Projects\ESP8266_Arduino_Projects\.piolibdeps Uninstalling PubSubClient @ 2.6: [OK] C:\>
For more info. about library management, visit the link below.
http://docs.platformio.org/en/latest/userguide/lib/index.html#cmd-lib
Reference:
#3 How to Install External Libraries Using PlatformIO
https://www.youtube.com/watch?v=_pSVzV4PdiA
========================================================================
How to rename / remove PlatformIO project folder
1. Open the folder where the project folder is located.
In my case, it's at "C:\Users\WeiHsiungHuang\Documents\PlatformIO\Projects".
2. Make a copy of the folder to be rename then rename the copied folder. For instance, the copy of "ESP8266 Arduino Projects" is renamed to "ESP8266_Arduino_Projects" to leave no space in the folder name.
3. Open PIO IDE, go to "File" -> "Add Folder to Workspace".
Locate the folder to be added to the workspace. In this case, the folder is at "C:\Users\WeiHsiungHuang\Documents\PlatformIO\Projects".
Click on "ESP8266_Arduino_Projects", then click on the "Add" button to add it into the workspace.
4. "ESP8266_Arduino_Projects" is now in the workspace.
5. To remove the folder with the old name, right click on the folder name then select "Remove Folder from Workspace" to remove it.
The original folder could be deleted now or kept as backup.
After adding folder with new name to the workspace, be sure to do the following so that the new folder is recognized by PlatformIO.
1. Go to PlatformIO home, click on Open Project.
2. Click on Projects, then click on the project with the new project name. In this case, it's "ESP8266_Arduino_Projects".
3. Click on Open "ESP8266_Arduino_Projects".
After doing this, the project folder "ESP8266_Arduino_Projects" will appear in the location option for installing library. Otherwise, the new folder won't appear in the location option.
Click here to go to part 4 (the last part) of this series.
No comments:
Post a Comment