Coder Social home page Coder Social logo

vsc-guide-for-esp32's Introduction

Setting up Visual Studio Code for ESP32 IDF (FreeRTOS)

Logo Logo

ESP32 IoT IDF

Xtensa IoT framework.

Steps

Download and install VSC

Below link will point to the latest version of the Microsoft code editor which is free and open source.
Go ahead and download the latest release.

Visual Studio Code

Install VSC extensions

After the installation open editor and go to 'Extensions' section to browse all available vsc extensions.
You need the following:

  • C++
  • Native Debug
  • Code Outline or AL Outline (to display and navigate properties)

Setup toolchain

Next you need tools for compilation and linking your projects Go to below link and follow instructions https://docs.espressif.com/projects/esp-idf/en/feature-cmake/get-started/index.html#setup-toolchain

You need to download all-in-one esp-idf tools installer https://dl.espressif.com/dl/esp-idf-tools-setup-1.1.exe and get the latest ESP-IDF framework

How to get ESP-IDF

Setup and verify environment variables

Make sure all path and idf variables are present and pointing to right locations. IDF_PATH is cruicial. You can use run-command way to set them up with setx IDF_PATH "...your path to esp-idf folder"

Example setup:

Note: If you want to quickly install whole environment with esp-idf framework - I created a batch file that will pull esp-idf from github repository, download it to user profile location (C:\Users\NAME\ESP32) and set the IDF_PATH automatically.
IMPORTANT: Please run this file as administrator!!
esp32setenv.bat

Make sure you install Git for Windows
Git Client download page

Create project

To create project that can properly compile you need the following:

.vscode folder must be present in the root project directory

.vscode folder must have the following files:

to have key shortcuts you need to modify keybindings.json file

keybindings.json is located in C:\Users....your profile name.... \AppData\Roaming\Code\User This file will allow to run compilation etc with just pressing keyshortcut

alternatively and what I recommend - use the command line from terminal to compile,monitor and run your app

  • idf.py -p COM3 flash -- wil compile and flash the board on port COM3
  • idf.py -p COM3 monitor -- will display live serial monitor in console

if you want to flash and immefiately monitor use

  • idf.py -p COM3 flash monitor

build will build project with changes
fullclean will erase old files and refresh the whole build for new compilation

Typical project file structure:

Important note:

To open your project you must choose 'Open Folder' option

Configure ESP32

Before compiling your project run the command to set up all necessary settings that IDF will use for your ESP32 chip.
In Integrated Terminal window run idf.py menuconfig
If you are not in Powershell but in cmd.exe - you can run powershell idf.py menuconfig

Example:


Hit ESC until menuconfig asks about saving the configuration.
Confirm save.

CMake

To use CMake environment your project must have CMakeLists.txt (just like Make files) in project directory

It usually contains f.ex. below lines

set(MAIN_SRCS
    main/spi_master_example_main.c
    main/pretty_effect.c
    main/decode_image.c)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(spi_master)

You can change them to the project files you have. Follow the examples provided in examples folder together with idf framework that you downloaded There are CMakeList.txt files in different folders that will help you how to add directories and component references

I will post more later on CMake... ;)

vsc-guide-for-esp32's People

Contributors

deous avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.