-
Notifications
You must be signed in to change notification settings - Fork 637
Build and update from Visual Studio Code using PlatformIO
This page summarizes all you need to compile and deploy Espurna on Windows 10 with Visual Studio Code (VSCode). VSCode is a free, open source, light IDE from Microsoft.
Download it from https://git-scm.com/download/win (choose appropriate version).
Ensure that it modifies the path variable.
Download it from https://code.visualstudio.com/docs/?dv=win
Ensure that it updates the PATH variable (default option).
Download it from https://nodejs.org/en/download/ (more convenient with the Windows Installer (.msi) version)
NPM gets installed with node.js
Restart your computer.
Launch Visual Studio Code. It should detect git (displaying a message in a git pane at the bottom of the window).
From VSC, open a terminal (CTRL+SHIFT+` OR CTRL+SHIFT+P and search for Terminal: Create New Integrated Terminal
) and run
npm install --global gulp-cli
From the extensions pane of Visual Studio Code install the following extensions.
Mandatory :
- Platformio IDE
Optionally :
- Python
- GitLens (to show modifications history)
Clone https://github.com/xoseperez/espurna.git
For example into C:\Users\{user}\Documents\PlatformIO\Projects\xoseperez-espurna
With VSCode, open xoseperez-espurna\code
folder. PlatformIO IDE will start and detect platformio project.
Now you can build espurna, including web files, directly from Visual Studio Code.
To build / upload firmware for a specific board, use "Tasks / Run Task..." (CTRL+ALT+T by default) and search for "Build (...)" / "Upload (...)" tasks.
PlatformIO: Build
and button on the bottom bar builds 'default' environment specified in 'code/platformio.ini' (wemos-d1mini-relayshield
at the time of writing this)
OTA parameters are now picked up from environment variables.
You need to set them up for every Upload (...)
task you want to use. Here's how to do it:
- Press F1 (on Mac it's usually Fn+F1)
- Switch PlatformIO Project Environment from the bottom bar (Optional. Otherwise, default environment from the platformio.ini is used)
- Select
Tasks: Configure Task
(type a part of the name and click it when it appears) - Select
Upload (...)
task you need to use (type a part of the name and click it when it appears) - An editor for a JSON config opens. You'll see a section added with your task name, ex.:
"type": "PlatformIO",
"task": "Upload (itead-sonoff-th)",
"problemMatcher": [
"$platformio"
]
- Add the
options
section before theproblemMatcher
, so you have this:
"type": "PlatformIO",
"task": "Upload (itead-sonoff-th)",
"options": {
"env": {
"ESPURNA_IP": "192.168.4.1",
"ESPURNA_AUTH": "fibonacci"
}
},
"problemMatcher": [
"$platformio"
]
- If you have custom IP or password, put them here. Otherwise, use
192.168.4.1
andfibonacci
- If you have Zeroconf configured, you can use Zeroconf names here, ex:
sonoff-kitchen.local
- Save and close the file. Now you can OTA upload this target successfully
To reuse the same environment (like itead-sonoff-th
) you will need to manually specify platformio command as a "shell" task. The pro is you can seamlessly support several devices with different IPs and passwords right from the VSCode (ref: Platform.IO documentation).
The example below uses special hardware environment, however it is encouraged to use esp8266-<size>-base
environments instead and provide hardware flags via ESPURNA_FLAGS
environment variable (e.g. "ESPURNA_FLAGS": "-DITEAD_SONOFF_BASIC"
)
Here we are declaring "Arbol1" and "Light1" tasks that use the same itead-sonoff-basic
environment:
{
"label": "PlatformIO: Arbol1",
"type": "shell",
"command": "platformio run -e itead-sonoff-basic -t upload",
"options": {
"env": {
"ESPURNA_IP": "192.168.1.100",
"ESPURNA_AUTH": "---"
}
},
"problemMatcher": [
"$platformio"
]
},
{
"label": "PlatformIO: Light1",
"type": "shell",
"command": "platformio run -e itead-sonoff-basic -t upload",
"options": {
"env": {
"ESPURNA_IP": "192.168.1.200",
"ESPURNA_AUTH": "---"
}
},
"problemMatcher": [
"$platformio"
]
}
Source: @oscarsan1, xoseperez/espurna#1515
If you're looking for support:
- Issues: this is the most dynamic channel at the moment, you might find an answer to your question by searching open or closed issues.
- Wiki pages: might not be as up-to-date as we all would like (hey, you can also contribute in the documentation!).
- Gitter channel: you have better chances to get fast answers from project contributors or other ESPurna users. (also available with any Matrix client!)
- Issue a question: as a last resort, you can open new question issue on GitHub. Just remember: the more info you provide the more chances you'll have to get an accurate answer.
- Backup the stock firmware
- Flash a pre-built binary image
- Flash a virgin Itead Sonoff device without opening
- Flash TUYA-based device without opening
- Flash Shelly device without opening
- Using PlatformIO
- from Visual Studio Code
- Using Arduino IDE
- Build the Web Interface
- Over-the-air updates
- Two-step updates
- ESPurna OTA Manager
- NoFUSS
- Troubleshooting
- MQTT
- REST API
- Domoticz
- Home Assistant
- InfluxDB
- Prometheus metrics
- Thingspeak
- Alexa
- Google Home
- Architecture
- 3rd Party Plugins
- Coding style
- Pull Requests