Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 00a9579

Browse filesBrowse files
Add Arduino as Component examples (espressif#8878)
* Example for IDF component registry * Added readme * updated readme * remove idf dependency * add empty lines on file end * idf_component.yml version change * Updated readme for local development --------- Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
1 parent b303cb4 commit 00a9579
Copy full SHA for 00a9579

File tree

Expand file treeCollapse file tree

7 files changed

+103
-0
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+103
-0
lines changed

‎idf_component.yml

Copy file name to clipboardExpand all lines: idf_component.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,6 @@ dependencies:
6565
version: "^1.4.2"
6666
rules:
6767
- if: "target in [esp32s3]"
68+
examples:
69+
- path: ../idf_component_examples/
6870

+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# For more information about build system see
2+
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
3+
# The following five lines of boilerplate have to be in your project's
4+
# CMakeLists in this exact order for cmake to work correctly
5+
cmake_minimum_required(VERSION 3.16)
6+
7+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
8+
project(main)
+63Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
```
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
idf_component_register(SRCS "main.cpp"
2+
INCLUDE_DIRS ".")
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## IDF Component Manager Manifest File
2+
dependencies:
3+
espressif/arduino-esp32:
4+
version: '*'
5+
override_path: '../../../'
6+
pre_release: true
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "Arduino.h"
2+
3+
void setup(){
4+
Serial.begin(115200);
5+
}
6+
7+
void loop(){
8+
Serial.println("Hello world!");
9+
delay(1000);
10+
}
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Arduino ESP32
3+
#
4+
CONFIG_AUTOSTART_ARDUINO=y
5+
# end of Arduino ESP32
6+
7+
#
8+
# FREERTOS
9+
#
10+
CONFIG_FREERTOS_HZ=1000
11+
# end of FREERTOS
12+
# end of Component config

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.