| 
 | 1 | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |  | 
 | 2 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |  | 
 | 3 | + | 
 | 4 | +# _Hello world example_  | 
 | 5 | + | 
 | 6 | +This is the simplest buildable example made to be used as a template for new projects running Arduino-esp32 as an ESP-IDF component.  | 
 | 7 | +See [Arduino-esp32](https://components.espressif.com/components/espressif/arduino-esp32) in ESP Registry.  | 
 | 8 | + | 
 | 9 | +## How to use example  | 
 | 10 | + | 
 | 11 | +To create a ESP-IDF project from this example with the latest relase of Arduino-esp32, you can simply run command: `idf.py create-project-from-example "espressif/arduino-esp32:hello_world"`.  | 
 | 12 | +ESP-IDF will download all dependencies needed from the component registry and setup the project for you.  | 
 | 13 | + | 
 | 14 | +If you want to use cloned Arduino-esp32 repository, you can build this example directly.  | 
 | 15 | +Go to the example folder `arduino-esp32/idf_component_examples/Hello_world`.  | 
 | 16 | +First you need to comment line 6 `pre_release: true` in examples `/main/idf_component.yml`.  | 
 | 17 | +Then just run command: `idf.py build`.  | 
 | 18 | + | 
 | 19 | +## Example folder contents  | 
 | 20 | + | 
 | 21 | +The project **Hello_world** contains one source file in C++ language [main.cpp](main/main.cpp). The file is located in folder [main](main).  | 
 | 22 | + | 
 | 23 | +ESP-IDF projects are built using CMake. The project build configuration is contained in `CMakeLists.txt`  | 
 | 24 | +files that provide set of directives and instructions describing the project's source files and targets  | 
 | 25 | +(executable, library, or both).   | 
 | 26 | + | 
 | 27 | +Below is short explanation of remaining files in the project folder.  | 
 | 28 | + | 
 | 29 | +```  | 
 | 30 | +├── CMakeLists.txt  | 
 | 31 | +├── main  | 
 | 32 | +│   ├── CMakeLists.txt  | 
 | 33 | +│ ├── idf_component.yml  | 
 | 34 | +│   └── main.cpp  | 
 | 35 | +└── README.md This is the file you are currently reading  | 
 | 36 | +```  | 
 | 37 | + | 
 | 38 | +## How to add Arduino libraries  | 
 | 39 | + | 
 | 40 | +In the project create folder `components/` and clone the library there.  | 
 | 41 | +In the library folder create new CMakeLists.txt file, add lines shown below to the file and edit the SRCS to match the library source files.  | 
 | 42 | + | 
 | 43 | +```  | 
 | 44 | +idf_component_register(SRCS "user_library.cpp" "another_source.c"  | 
 | 45 | + INCLUDE_DIRS "."  | 
 | 46 | + REQUIRES arduino-esp32  | 
 | 47 | + )  | 
 | 48 | +```  | 
 | 49 | + | 
 | 50 | +Below is structure of the project folder with the Arduino libraries.  | 
 | 51 | + | 
 | 52 | +```  | 
 | 53 | +├── CMakeLists.txt  | 
 | 54 | +├── components  | 
 | 55 | +│   ├── user_library  | 
 | 56 | +│   │   ├── CMakeLists.txt This needs to be added  | 
 | 57 | +│   │   ├── ...  | 
 | 58 | +├── main  | 
 | 59 | +│   ├── CMakeLists.txt  | 
 | 60 | +│ ├── idf_component.yml  | 
 | 61 | +│   └── main.cpp  | 
 | 62 | +└── README.md This is the file you are currently reading  | 
 | 63 | +```  | 
0 commit comments