├── .gitignore ├── CHANGELOG.md ├── doc └── create-new-project-with-template.png ├── .vscode └── extensions.json ├── src └── main.cpp ├── extra_script.py ├── test └── README ├── examples ├── low-energy-consumption │ └── main.cpp ├── blink │ └── main.cpp └── esp-now-le │ └── main.cpp ├── .github ├── FUNDING.yml └── workflows │ ├── build.yml │ └── build_release.yml ├── boards ├── esp32-c6-n4.json ├── esp32-c6-n16.json ├── LilyGo-T-RGB.json ├── LilyGo-T-Deck.json ├── LilyGo-T-Watch-S3.json ├── LilyGo-T-Display-S3-long.json └── LilyGo-T-CameraPlus-ESP32-S3.json ├── LICENSE ├── lib └── README ├── include └── README ├── README.md └── platformio.ini /.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | 3 | ## v0.0.0 4 | 5 | PLEASE WRITE YOUR CHANGES BEFORE YOU CREATE A RELEASE IN THE CHANGELOG.MD FILE! 6 | -------------------------------------------------------------------------------- /doc/create-new-project-with-template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcuw/ESP32-ghbuild-template/HEAD/doc/create-new-project-with-template.png -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "pioarduino.pioarduino-ide" 4 | ], 5 | "unwantedRecommendations": [ 6 | "ms-vscode.cpptools-extension-pack" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void setup() { 4 | Serial.begin(115200); 5 | while (!Serial); 6 | 7 | } 8 | 9 | void loop() { 10 | Serial.println("Hello World"); 11 | delay(2000); 12 | } -------------------------------------------------------------------------------- /extra_script.py: -------------------------------------------------------------------------------- 1 | import os 2 | Import("env") 3 | 4 | # Access to global construction environment 5 | build_tag = env['PIOENV'] 6 | version_tag = os.getenv("FIRMWARE_VERSION") 7 | 8 | env.Replace(PROGNAME="firmware_%s_%s" % (build_tag, version_tag)) -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Test Runner and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/en/latest/advanced/unit-testing/index.html 12 | -------------------------------------------------------------------------------- /examples/low-energy-consumption/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This example shows how to run with low energy consumption 3 | * 4 | * used features: 5 | * - Deep-Sleep mode 6 | * - Touch sensor as wake up trigger (T0 = GPIO4) 7 | */ 8 | #include 9 | 10 | #define THRESHOLD 20 // you can modify this value 11 | 12 | void setup() 13 | { 14 | Serial.begin(115200); 15 | // while (!Serial) 16 | // ; 17 | 18 | // Setup sleep wakeup on Touch Pad 0 (GPIO4) 19 | touchSleepWakeUpEnable(T0, THRESHOLD); 20 | 21 | Serial.println("Going to sleep now"); 22 | Serial.flush(); 23 | esp_deep_sleep_start(); 24 | } 25 | 26 | void loop() 27 | { 28 | // never reach here 29 | } -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [mcuw, vanvuongngo] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /examples/blink/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This example shows how to use a built-in LED with low energy consumption 3 | * 4 | * used features: 5 | * - blink built-in LED 6 | * - Deep-Sleep mode 7 | * 8 | * see https://docs.arduino.cc/built-in-examples/basics/Blink 9 | */ 10 | #include 11 | 12 | #define uS_TO_S_FACTOR 1000000 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | pinMode(LED_BUILTIN, OUTPUT); 18 | 19 | Serial.println("switch LED on"); 20 | digitalWrite(LED_BUILTIN, LOW); // depend on LED circuit, can also be HIGH 21 | delay(200); 22 | 23 | Serial.println("switch LED off"); 24 | digitalWrite(LED_BUILTIN, HIGH); 25 | esp_sleep_enable_timer_wakeup(2 * uS_TO_S_FACTOR); // 2s 26 | esp_deep_sleep_start(); 27 | } 28 | 29 | void loop() 30 | { 31 | // never reach here 32 | } -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags-ignore: 4 | - "**" 5 | pull_request: 6 | branches: [main] 7 | jobs: 8 | build: 9 | name: Build 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout repo 13 | uses: actions/checkout@v4 14 | - name: Set up python 15 | uses: actions/setup-python@v5 16 | with: 17 | python-version: "3.x" 18 | architecture: "x64" 19 | - name: Install PlatformIO 20 | run: python3 -m pip install platformio==6.1.18 21 | - name: Build firmwares 22 | run: FIRMWARE_VERSION=main platformio run 23 | - name: Archive 24 | uses: actions/upload-artifact@v4 25 | with: 26 | name: firmware 27 | path: .pio/build/*/firmware_*.bin 28 | retention-days: 1 29 | -------------------------------------------------------------------------------- /boards/esp32-c6-n4.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "esp32", 4 | "f_cpu": "160000000L", 5 | "f_flash": "80000000L", 6 | "flash_mode": "qio", 7 | "mcu": "esp32c6", 8 | "variant": "esp32c6", 9 | "extra_flags": [ 10 | "-DARDUINO_ESP32C6_DEV", 11 | "-DARDUINO_USB_MODE=1", 12 | "-DARDUINO_USB_CDC_ON_BOOT=1", 13 | "-D BOARD_HAS_PSRAM=1" 14 | ] 15 | }, 16 | "connectivity": [ 17 | "wifi", 18 | "bluetooth" 19 | ], 20 | "frameworks": [ 21 | "arduino", 22 | "espidf" 23 | ], 24 | "name": "Espressif ESP32-C6 N4", 25 | "upload": { 26 | "flash_size": "4MB", 27 | "maximum_ram_size": 524288, 28 | "maximum_size": 4194304, 29 | "require_upload_port": true, 30 | "speed": 460800 31 | }, 32 | "url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html", 33 | "vendor": "Espressif" 34 | } -------------------------------------------------------------------------------- /boards/esp32-c6-n16.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "esp32", 4 | "f_cpu": "160000000L", 5 | "f_flash": "80000000L", 6 | "flash_mode": "qio", 7 | "mcu": "esp32c6", 8 | "variant": "esp32c6", 9 | "extra_flags": [ 10 | "-D ARDUINO_ESP32S3_DEV", 11 | "-D ARDUINO_USB_MODE=1", 12 | "-D ARDUINO_USB_CDC_ON_BOOT=1", 13 | "-D BOARD_HAS_PSRAM=1" 14 | ] 15 | }, 16 | "connectivity": [ 17 | "wifi", 18 | "bluetooth" 19 | ], 20 | "frameworks": [ 21 | "arduino", 22 | "espidf" 23 | ], 24 | "name": "Espressif ESP32-C6 N16", 25 | "upload": { 26 | "flash_size": "16MB", 27 | "maximum_ram_size": 524288, 28 | "maximum_size": 16777216, 29 | "require_upload_port": true, 30 | "speed": 460800 31 | }, 32 | "url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html", 33 | "vendor": "Espressif" 34 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 mcuw 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /boards/LilyGo-T-RGB.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld", 5 | "memory_type": "qio_opi", 6 | "partitions": "default_16MB.csv" 7 | }, 8 | "core": "esp32", 9 | "extra_flags": [ 10 | "-D LILYGO_T_RGB", 11 | "-D ARDUINO_USB_MODE=1", 12 | "-D BOARD_HAS_PSRAM", 13 | "-D ARDUINO_RUNNING_CORE=1", 14 | "-D ARDUINO_EVENT_RUNNING_CORE=1" 15 | ], 16 | "f_cpu": "240000000L", 17 | "f_flash": "80000000L", 18 | "flash_mode": "qio", 19 | "hwids": [["0x303A", "0x1001"]], 20 | "mcu": "esp32s3", 21 | "variant": "esp32s3" 22 | }, 23 | "connectivity": ["wifi", "bluetooth"], 24 | "debug": { 25 | "default_tool": "esp-builtin", 26 | "onboard_tools": ["esp-builtin"], 27 | "openocd_target": "esp32s3.cfg" 28 | }, 29 | "frameworks": ["arduino", "espidf"], 30 | "name": "LilyGo T-RGB (16M Flash 8M OPI PSRAM )", 31 | "upload": { 32 | "flash_size": "16MB", 33 | "maximum_ram_size": 327680, 34 | "maximum_size": 16777216, 35 | "require_upload_port": true, 36 | "speed": 921600 37 | }, 38 | "url": "https://www.lilygo.cc/products/t-rgb", 39 | "vendor": "LilyGo" 40 | } -------------------------------------------------------------------------------- /boards/LilyGo-T-Deck.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld", 5 | "memory_type": "qio_opi", 6 | "partitions": "default_16MB.csv" 7 | }, 8 | "core": "esp32", 9 | "extra_flags": [ 10 | "-D ARDUINO_USB_MODE=1", 11 | "-D ARDUINO_RUNNING_CORE=1", 12 | "-D BOARD_HAS_PSRAM=1", 13 | "-D ARDUINO_RUNNING_CORE=1", 14 | "-D ARDUINO_EVENT_RUNNING_CORE=1" 15 | ], 16 | "f_cpu": "240000000L", 17 | "f_flash": "80000000L", 18 | "flash_mode": "qio", 19 | "hwids": [["0x303A", "0x1001"]], 20 | "mcu": "esp32s3", 21 | "variant": "esp32s3" 22 | }, 23 | "connectivity": ["wifi", "bluetooth"], 24 | "debug": { 25 | "default_tool": "esp-builtin", 26 | "onboard_tools": ["esp-builtin"], 27 | "openocd_target": "esp32s3.cfg" 28 | }, 29 | "frameworks": ["arduino", "espidf"], 30 | "name": "LilyGo T-Deck (16M Flash 8M PSRAM )", 31 | "upload": { 32 | "flash_size": "16MB", 33 | "maximum_ram_size": 327680, 34 | "maximum_size": 16777216, 35 | "require_upload_port": true, 36 | "speed": 921600 37 | }, 38 | "url": "https://www.lilygo.cc/products/t-deck", 39 | "vendor": "LilyGo" 40 | } -------------------------------------------------------------------------------- /boards/LilyGo-T-Watch-S3.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld", 5 | "memory_type": "qio_opi", 6 | "partitions": "default_16MB.csv" 7 | }, 8 | "core": "esp32", 9 | "extra_flags": [ 10 | "-D ARDUINO_TWATCH_S3", 11 | "-D ARDUINO_USB_MODE=1", 12 | "-D BOARD_HAS_PSRAM=1", 13 | "-D ARDUINO_RUNNING_CORE=1", 14 | "-D ARDUINO_EVENT_RUNNING_CORE=1" 15 | ], 16 | "f_cpu": "240000000L", 17 | "f_flash": "80000000L", 18 | "flash_mode": "qio", 19 | "hwids": [["0x303A", "0x1001"]], 20 | "mcu": "esp32s3", 21 | "variant": "esp32s3" 22 | }, 23 | "connectivity": ["wifi", "bluetooth"], 24 | "debug": { 25 | "default_tool": "esp-builtin", 26 | "onboard_tools": ["esp-builtin"], 27 | "openocd_target": "esp32s3.cfg" 28 | }, 29 | "frameworks": ["arduino", "espidf"], 30 | "name": "LilyGo T-Watch S3 (16M Flash 8M OPI PSRAM)", 31 | "upload": { 32 | "flash_size": "16MB", 33 | "maximum_ram_size": 327680, 34 | "maximum_size": 16777216, 35 | "require_upload_port": true, 36 | "speed": 921600 37 | }, 38 | "url": "https://www.lilygo.cc/products/t-watch-s3", 39 | "vendor": "LilyGo" 40 | } -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /boards/LilyGo-T-Display-S3-long.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld", 5 | "memory_type": "qio_opi", 6 | "partitions": "default_16MB.csv" 7 | }, 8 | "core": "esp32", 9 | "extra_flags": [ 10 | "-D ARDUINO_ESP32S3_DEV", 11 | "-D ARDUINO_USB_MODE=1", 12 | "-D ARDUINO_USB_CDC_ON_BOOT=1", 13 | "-D BOARD_HAS_PSRAM=1", 14 | "-D ARDUINO_RUNNING_CORE=1", 15 | "-D ARDUINO_EVENT_RUNNING_CORE=1" 16 | ], 17 | "f_cpu": "240000000L", 18 | "f_flash": "80000000L", 19 | "flash_mode": "qio", 20 | "hwids": [ 21 | [ 22 | "0x303A", 23 | "0x1001" 24 | ] 25 | ], 26 | "mcu": "esp32s3", 27 | "variant": "esp32s3" 28 | }, 29 | "connectivity": [ 30 | "wifi", 31 | "bluetooth" 32 | ], 33 | "debug": { 34 | "default_tool": "esp-builtin", 35 | "onboard_tools": ["esp-builtin"], 36 | "openocd_target": "esp32s3.cfg" 37 | }, 38 | "frameworks": [ 39 | "arduino", 40 | "espidf" 41 | ], 42 | "name": "LilyGo T-Display S3 long (16M Flash 8M PSRAM)", 43 | "upload": { 44 | "flash_size": "16MB", 45 | "maximum_ram_size": 327680, 46 | "maximum_size": 16777216, 47 | "require_upload_port": true, 48 | "speed": 921600 49 | }, 50 | "url": "https://www.lilygo.cc/products/t-display-s3-long", 51 | "vendor": "LilyGo" 52 | } -------------------------------------------------------------------------------- /boards/LilyGo-T-CameraPlus-ESP32-S3.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld", 5 | "memory_type": "qio_qspi", 6 | "partitions": "default_16MB.csv" 7 | }, 8 | "core": "esp32", 9 | "extra_flags": [ 10 | "-D ARDUINO_LILYGO_T_CAMERAPLUS_S3", 11 | "-D ARDUINO_USB_MODE=1", 12 | "-D ARDUINO_USB_CDC_ON_BOOT=1", 13 | "-D BOARD_HAS_PSRAM=1", 14 | "-D ARDUINO_RUNNING_CORE=1", 15 | "-D ARDUINO_EVENT_RUNNING_CORE=1" 16 | ], 17 | "f_cpu": "240000000L", 18 | "f_flash": "80000000L", 19 | "flash_mode": "qio", 20 | "hwids": [ 21 | [ 22 | "0x303A", 23 | "0x83CF" 24 | ], 25 | [ 26 | "0x303A", 27 | "0x1001" 28 | ] 29 | ], 30 | "mcu": "esp32s3", 31 | "variant": "esp32s3" 32 | }, 33 | "connectivity": [ 34 | "wifi", 35 | "bluetooth" 36 | ], 37 | "debug": { 38 | "default_tool": "esp-builtin", 39 | "onboard_tools": ["esp-builtin"], 40 | "openocd_target": "esp32s3.cfg" 41 | }, 42 | "frameworks": [ 43 | "arduino", 44 | "espidf" 45 | ], 46 | "name": "LILYGO T-CameraPlus ESP32-S3 (16M Flash 8M PSRAM)", 47 | "upload": { 48 | "flash_size": "16MB", 49 | "maximum_ram_size": 327680, 50 | "maximum_size": 16777216, 51 | "require_upload_port": true, 52 | "speed": 921600 53 | }, 54 | "url": "https://www.lilygo.cc/products/t-camera-plus-s3", 55 | "vendor": "LilyGo" 56 | } -------------------------------------------------------------------------------- /.github/workflows/build_release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - "*" 5 | jobs: 6 | build: 7 | name: Build 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout repo 11 | uses: actions/checkout@v4 12 | - name: Set up python 13 | uses: actions/setup-python@v5 14 | with: 15 | python-version: "3.x" 16 | architecture: "x64" 17 | - name: Install PlatformIO 18 | run: python3 -m pip install platformio==6.1.18 19 | - name: Build firmwares 20 | run: FIRMWARE_VERSION=${{github.ref_name}} platformio run 21 | - name: Archive 22 | uses: actions/upload-artifact@v4 23 | with: 24 | name: firmware 25 | path: .pio/build/*/firmware_*.bin 26 | retention-days: 1 27 | release: 28 | name: Release 29 | # if: startsWith(github.event.ref, 'refs/tags/v') 30 | needs: build 31 | permissions: 32 | contents: write 33 | runs-on: ubuntu-latest 34 | steps: 35 | - name: Checkout repo for CHANGELOG 36 | uses: actions/checkout@v4 37 | - name: Download artifacts 38 | uses: actions/download-artifact@v4 39 | with: 40 | name: firmware 41 | path: firmware 42 | # - name: Display structure of downloaded files 43 | # run: ls -R 44 | - name: release 45 | uses: ncipollo/release-action@v1 46 | with: 47 | artifacts: "firmware/*/firmware_*.bin" 48 | bodyFile: "CHANGELOG.md" 49 | -------------------------------------------------------------------------------- /include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/esp-now-le/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This example shows how to run with low energy consumption. 3 | * And use as a node with esp-now communication. 4 | * 5 | * used features: 6 | * - Deep-Sleep mode 7 | * - Touch sensor as wake up trigger (T0 = GPIO4) 8 | * - ESP now 9 | */ 10 | #include 11 | #include 12 | #include 13 | 14 | #define THRESHOLD 20 // you can modify this value 15 | 16 | // this is the boardcast address, change to your receiver MAC 17 | uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 18 | 19 | typedef struct struct_message 20 | { 21 | char a[32]; 22 | int b; 23 | float c; 24 | bool d; 25 | } struct_message; 26 | 27 | struct_message myData; 28 | 29 | esp_now_peer_info_t peerInfo; 30 | 31 | // callback when data is sent 32 | void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) 33 | { 34 | Serial.print("Last Packet Send Status: "); 35 | if (status == ESP_NOW_SEND_SUCCESS) 36 | { 37 | Serial.println("Delivery Success"); 38 | digitalWrite(LED_BUILTIN, LOW); 39 | delay(200); 40 | digitalWrite(LED_BUILTIN, HIGH); 41 | } 42 | else 43 | { 44 | Serial.println("Delivery Fail"); 45 | } 46 | } 47 | 48 | void setup() 49 | { 50 | Serial.begin(115200); 51 | // while (!Serial) 52 | // ; 53 | 54 | pinMode(LED_BUILTIN, OUTPUT); 55 | 56 | // Init ESP-NOW 57 | // Set device as a Wi-Fi Station 58 | WiFi.mode(WIFI_STA); 59 | if (esp_now_init() != ESP_OK) 60 | { 61 | Serial.println("Error initializing ESP-NOW"); 62 | return; 63 | } 64 | 65 | // Once ESPNow is successfully Init, we will register for Send CB to 66 | // get the status of Trasnmitted packet 67 | if (esp_now_register_send_cb(OnDataSent) != ESP_OK) 68 | { 69 | Serial.println("Error initializing ESP-NOW callback"); 70 | } 71 | 72 | // Register peer 73 | memcpy(peerInfo.peer_addr, broadcastAddress, 6); 74 | peerInfo.channel = 0; 75 | peerInfo.encrypt = false; 76 | // Add peer 77 | if (esp_now_add_peer(&peerInfo) != ESP_OK) 78 | { 79 | Serial.println("Failed to add peer"); 80 | return; 81 | } 82 | 83 | // Set values to send 84 | strcpy(myData.a, "THIS IS A CHAR"); 85 | myData.b = random(1, 20); 86 | myData.c = 1.2; 87 | myData.d = false; 88 | 89 | // Send message via ESP-NOW 90 | esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *)&myData, sizeof(myData)); 91 | if (result == ESP_OK) 92 | { 93 | Serial.println("Called ESP-Now send successfully"); 94 | } 95 | else 96 | { 97 | Serial.println("Error sending the data"); 98 | } 99 | 100 | // Setup sleep wakeup on Touch Pad 0 (GPIO4) 101 | touchSleepWakeUpEnable(T0, THRESHOLD); 102 | 103 | Serial.println("Going to sleep now"); 104 | Serial.flush(); 105 | esp_deep_sleep_start(); 106 | } 107 | 108 | void loop() 109 | { 110 | // never reach here 111 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESP32 project template 2 | 3 | ## Description 4 | 5 | This is a project template to create microcontroller apps with automatized firmware builds for [ESP32](https://www.espressif.com/en/products/socs/esp32), [ESP32-S2](https://www.espressif.com/en/products/socs/esp32-s2), [ESP32-S3](https://www.espressif.com/en/products/socs/esp32-s3), [ESP32-C6](https://www.espressif.com/en/products/socs/esp32-c6), [ESP32-H2](https://www.espressif.com/en/products/socs/esp32-h2) and [ESP32-P4](https://www.espressif.com/en/products/socs/esp32-p4) microcontroller boards. It uses for that [GitHub Actions](https://github.com/features/actions) and [platformio](https://platformio.org/). Use this repository as a template for your own esp32 projects. 6 | 7 | ## Features 8 | 9 | - Uses Platformio v6.1.18 10 | - CI buils multiple firmwares on git tag push 11 | - Example code 12 | 13 | ## Prerequisites 14 | 15 | - [VSCode](https://code.visualstudio.com/) IDE 16 | 17 | - [pioarduino IDE](#Pioarduino) for [VSCode](https://code.visualstudio.com/) IDE 18 | 19 | ## Get Started 20 | 21 | 22 | 23 | 1. Login to github 24 | 25 | 2. Click on `Use this template` to create a new git repository 26 | 3. Implement your application in the [src/main.cpp](src/main.cpp) 27 | 4. Comment your new change in the [CHANGELOG.md](CHANGELOG.md) file 28 | 5. Push your changes 29 | 30 | ```sh 31 | git add . 32 | ``` 33 | 34 | ```sh 35 | git commit -am "my app" 36 | ``` 37 | 38 | ```sh 39 | git push -u origin main 40 | ``` 41 | 42 | 5. Create a new tag to trigger a release, e.g. for v1.0.0 43 | 44 | ```sh 45 | git tag v1.0.0 46 | ``` 47 | 48 | ```sh 49 | git push origin v1.0.0 50 | ``` 51 | 52 | 6. You can find your firmwares under `Releases` after the CI build finished 53 | 54 | ## GitHub Actions - Workflow 55 | 56 | The release build happens in the `build & release` workflow: [build_release.yml](.github/workflows/build_release.yml). 57 | It creates a release, after creation of a new git tag (named it like `v1.0.0`). 58 | 59 | If you want to test the build on all merge w/o creating a tag then the `build` workflow is what you looking for: [build.yml](.github/workflows/build.yml) 60 | 61 | ## Pioarduino 62 | 63 | The pioarduino platform supports latest boards like [ESP32-C6](https://www.espressif.com/en/products/socs/esp32-c6), [ESP32-H2](https://www.espressif.com/en/products/socs/esp32-h2) and [ESP32-P4](https://www.espressif.com/en/products/socs/esp32-p4) and others. There is a [pioarduino IDE](https://marketplace.visualstudio.com/items?itemName=pioarduino.pioarduino-ide) extension which replaces the [PlatformIO IDE](https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide) extension for VSCode. 64 | 65 | ## PlatformIO 66 | 67 | [PlatformIO](https://platformio.org/) is a tool to create microcontroller apps for arduino platforms and compatibles (esp32). You can install the [Visual Studio Code extension](https://platformio.org/install/ide?install=vscode) in the [Visual Studio Code](https://code.visualstudio.com/) IDE. 68 | 69 | ## Python extra_script.py 70 | 71 | There is a tiny python script needed to customize the firmware filenames within platformio, see documentation: https://docs.platformio.org/en/stable/scripting/examples/custom_program_name.html 72 | 73 | The [extra_script.py](extra_script.py) script gets the platformio env (e.g. lolin32) and the git-tag for the firmware filename. 74 | This is required to publish several firmware names in the github artifacts of a release. 75 | 76 | ## CHANGELOG 77 | 78 | You can write your changes in the [CHANGELOG.md](CHANGELOG.md) before you create a release. It will be shown under the release page. 79 | 80 | ## Example Release 81 | 82 | see [Releases](https://github.com/mcuw/esp-ghbuild-template/releases) on the right sidemenu. 83 | 84 | ## Customize your project 85 | 86 | You can reduce and adapt your required boards in the [platformio.ini](platformio.ini). 87 | 88 | Update the [CHANGELOG.md](CHANGELOG.md) file before you are creating a new release. By creating a new git tag you trigger a new release which generate for you the firmwares. 89 | 90 | ## Supported boards 91 | 92 | Buy on AliExpress (affiliate links) ... 93 | 94 | - ESP32 95 | - [LILYGO T-Beam](https://s.click.aliexpress.com/e/_DBzslDV) with LoRA 96 | - lolin32 97 | - lolin D32 pro 98 | - ESP32 S2 99 | - ESP32 S3 100 | - [LILYGO T-Display S3](https://s.click.aliexpress.com/e/_DBmOMkn) 101 | - [LILYGO T-Display-S3 AMOLED](https://s.click.aliexpress.com/e/_DmboYpZ) 102 | - [LILYGO T-Display-S3 Touch](https://s.click.aliexpress.com/e/_DCBgPlV) 103 | - [LILYGO T-Display S3 Long](https://s.click.aliexpress.com/e/_Dl6UVMx) 104 | - [LilyGo T-Watch S3](https://s.click.aliexpress.com/e/_DEZVvH1) 105 | - [LilyGo T-CameraPlus ESP32-S3](https://s.click.aliexpress.com/e/_DkytBeT) 106 | - [LilyGo T-RGB](https://s.click.aliexpress.com/e/_Dem6i0b) 107 | - [LilyGo T-Deck](https://s.click.aliexpress.com/e/_DBPnZmL) 108 | - [LilyGo T-Deck Plus](https://s.click.aliexpress.com/e/_DDeskaP) 109 | 110 | - ESP32 C6 with WiFi 6 and BT-5 LE 111 | - [NanoESP32-C6](https://s.click.aliexpress.com/e/_ooBtUih) with 16MB flash 112 | - [ESP32-C6](https://s.click.aliexpress.com/e/_DeLjVMb) with 4MB flash and W2812 RGB LED 113 | - [LILYGO T-QT C6](https://github.com/mcuw/esp32-t-qt-c6-sdk) with 4 MB flash, touch display, 6-Axis Sensor 114 | 115 | ## Disclaimer 116 | 117 | Contribution and help - if you find an issue or wants to contribute then please do not hesitate to create a pull request or an issue. 118 | 119 | We provide our build template as is, and we make no promises or guarantees about this code. 120 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; https://docs.platformio.org/en/latest/platforms/espressif32.html 2 | 3 | [platformio] 4 | boards_dir = ./boards 5 | ; uncomment to build an example 6 | ; src_dir = ./examples/blink 7 | ;src_dir = ./examples/low-energy-consumption 8 | ; src_dir = ./examples/esp-now-le 9 | 10 | [env] 11 | build_flags = 12 | ; to use e.g. as part of the firmware name 13 | '-DPIOENV="${PIOENV}"' 14 | 15 | ; coding_standards 16 | -Wno-unused-variable 17 | -Wno-unused-but-set-variable 18 | -Wunreachable-code 19 | 20 | ; debug level 5=VERBOSE https://docs.platformio.org/en/latest/platforms/espressif32.html#debug-level 21 | ; -DCORE_DEBUG_LEVEL=5 22 | extra_scripts = pre:extra_script.py 23 | framework = arduino 24 | lib_deps = 25 | ; place global libs here or under extra.lib_deps_external (see below) 26 | monitor_speed = 115200 27 | ; see pioarduino versions: https://github.com/pioarduino/platform-espressif32/releases 28 | platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.32/platform-espressif32.zip 29 | upload_speed = 921600 30 | ; uncomment and configure when you have multiple ESPs connected 31 | ; upload_port = /dev/tty.usbserial-... 32 | ; monitor_port = /dev/tty.usbserial-... 33 | 34 | ; CUSTOM options 35 | ; You need manually inject these options into a section 36 | ; using ${extra.} (see below) 37 | [extra] 38 | ; https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/external-ram.html 39 | build_flags_psram = 40 | -DBOARD_HAS_PSRAM=1 41 | -mfix-esp32-psram-cache-issue ; https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/external-ram.html#esp32-rev-v1 42 | lib_deps_builtin = 43 | SPI 44 | Wire 45 | lib_deps_external = 46 | ; extend libs for all platforms here 47 | 48 | [esp32] 49 | build_flags = 50 | ${env.build_flags} 51 | lib_deps = 52 | ${env.lib_deps} 53 | ${extra.lib_deps_builtin} 54 | ${extra.lib_deps_external} 55 | ; extend libs only for esp32 based modules here 56 | 57 | [esp32c6] 58 | build_flags = 59 | ${env.build_flags} 60 | lib_deps = 61 | ${env.lib_deps} 62 | ${extra.lib_deps_builtin} 63 | ${extra.lib_deps_external} 64 | ; extend libs only for esp32c6 based modules here 65 | ; Use pioarduino, a community compatible fork of Platformio supporting latest espressif Arduino core 66 | platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip 67 | 68 | [esp32s2] 69 | build_flags = 70 | ${env.build_flags} 71 | lib_deps = 72 | ${env.lib_deps} 73 | ${extra.lib_deps_builtin} 74 | ${extra.lib_deps_external} 75 | ; extend libs only for esp32s2 based modules here 76 | 77 | [esp32s3] 78 | build_flags = 79 | ${env.build_flags} 80 | lib_deps = 81 | ${env.lib_deps} 82 | ${extra.lib_deps_builtin} 83 | ${extra.lib_deps_external} 84 | ; extend libs only for esp32s3 based modules here 85 | 86 | 87 | ; ********* 88 | ; * ESP32 * 89 | ; ********* 90 | 91 | ; pio board config: https://docs.platformio.org/en/latest/platforms/espressif32.html 92 | [env:esp32dev] 93 | extends = esp32 94 | board = esp32dev 95 | build_flags = 96 | ${esp32.build_flags} 97 | lib_deps = 98 | ${esp32.lib_deps} 99 | 100 | ; pio board config: https://docs.platformio.org/en/latest/boards/espressif32/lolin32.html 101 | [env:lolin32] 102 | extends = esp32 103 | board = lolin32 104 | build_flags = 105 | ${esp32.build_flags} 106 | lib_deps = 107 | ${esp32.lib_deps} 108 | 109 | ; Wemos https://www.wemos.cc/en/latest/d32/d32_pro.html 110 | ; pio board config: https://docs.platformio.org/en/latest/boards/espressif32/lolin_d32_pro.html 111 | [env:lolin-d32-pro] 112 | extends = esp32 113 | board = lolin_d32_pro 114 | build_flags = 115 | ${esp32.build_flags} 116 | ${extra.build_flags_psram} ; 4MB PSRAM 117 | lib_deps = 118 | ${esp32.lib_deps} 119 | 120 | ; LILYGO https://www.lilygo.cc/products/t-beam-v1-1-esp32-lora-module 121 | [env:ttgo-t-beam] 122 | extends = esp32 123 | board = ttgo-t-beam 124 | build_flags = 125 | ${esp32.build_flags} 126 | ${extra.build_flags_psram} ; 8MB PSRAM 127 | lib_deps = 128 | ${esp32.lib_deps} 129 | upload_speed = 460800 130 | 131 | ; ************ 132 | ; * ESP32-C6 * 133 | ; ************ 134 | ; devkitc-1: https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html 135 | ; devkitm-1: https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitm-1/index.html 136 | 137 | [env:esp32-c6-n16] 138 | extends = esp32c6 139 | board = esp32-c6-n16 140 | 141 | [env:esp32-c6-n4] 142 | extends = esp32c6 143 | board = esp32-c6-n4 144 | 145 | ; ************ 146 | ; * ESP32-S2 * 147 | ; ************ 148 | 149 | ; TODO http://www.lilygo.cn/prod_view.aspx?TypeId=50033&Id=1321 with psram 150 | ; repository: https://github.com/Xinyuan-LilyGO/LilyGo-T-Display-S2 151 | [env:lilygo-t-display-s2] 152 | extends = esp32s2 153 | board = esp32dev ; what about platformio board support and an own? 154 | 155 | ; ************ 156 | ; * ESP32-S3 * 157 | ; ************ 158 | 159 | ; pio board config: https://docs.platformio.org/en/latest/boards/espressif32/esp32s3box.html 160 | [env:esp32s3box] 161 | extends = esp32s3 162 | board = esp32s3box 163 | build_flags = 164 | ${esp32s3.build_flags} 165 | lib_deps = 166 | ${esp32s3.lib_deps} 167 | 168 | ; pio board config: https://docs.platformio.org/en/latest/boards/espressif32/esp32-s3-devkitc-1.html 169 | [env:esp32-s3-devkitc-1] 170 | extends = esp32s3 171 | board = esp32-s3-devkitc-1 172 | build_flags = 173 | ${esp32s3.build_flags} 174 | ; PSRAM is optional 175 | lib_deps = 176 | ${esp32s3.lib_deps} 177 | 178 | ; LILYGO: https://www.lilygo.cc/products/t-display-s3 179 | ; repository: https://github.com/Xinyuan-LilyGO/T-Display-S3 180 | ; pio board config: https://docs.platformio.org/en/latest/boards/espressif32/lilygo-t-display-s3.html 181 | ; Buy and support mcuw (affiliate link): https://s.click.aliexpress.com/e/_DE2TNqz 182 | [env:lilygo-t-display-s3] 183 | board = lilygo-t-display-s3 184 | build_flags = 185 | ${esp32s3.build_flags} 186 | ${extra.build_flags_psram} ; 8MB PSRAM 187 | lib_deps = 188 | ${esp32s3.lib_deps} 189 | 190 | ; LILYGO: https://www.lilygo.cc/products/t-display-s3-long 191 | ; repository: https://github.com/Xinyuan-LilyGO/T-Display-S3-Long 192 | ; Buy and support mcuw on aliexpress (affiliate link): https://s.click.aliexpress.com/e/_DEv67TX 193 | [env:lilygo-t-display-s3-long] 194 | board = LilyGo-T-Display-S3-long 195 | board_build.partitions = huge_app.csv 196 | build_flags = 197 | ${esp32s3.build_flags} 198 | lib_deps = 199 | ${esp32s3.lib_deps} 200 | 201 | ; SeeedStudio: https://www.seeedstudio.com/WT32-3-5-Inch-Display-p-5542.html 202 | ; Antratek: https://www.antratek.com/wt32-sco1-plus 203 | ; repository: https://github.com/wireless-tag-com/lv_port_esp32 204 | ; ESP32-TUX - github: https://github.com/sukesh-ak/ESP32-TUX 205 | [env:wt32-sc01-plus] 206 | extends = env:esp32-s3-devkitc-1 207 | build_flags = 208 | ${env:esp32-s3-devkitc-1.build_flags} 209 | ${extra.build_flags_psram} ; 2MB PSRAM 210 | 211 | ; LILYGO: https://www.lilygo.cc/products/t-watch-s3 212 | ; repository: https://github.com/Xinyuan-LilyGO/TTGO_TWatch_Library/tree/t-watch-s3 213 | ; Buy and support mcuw on aliexpress (affiliate link): https://s.click.aliexpress.com/e/_DEZVvH1 214 | [env:lilygo-t-watch-s3] 215 | board = LilyGo-T-Watch-S3 216 | board_build.partitions = huge_app.csv 217 | build_flags = 218 | ${esp32s3.build_flags} 219 | lib_deps = 220 | ${esp32s3.lib_deps} 221 | 222 | ; LILYGO: https://www.lilygo.cc/products/t-camera-plus-s3 223 | ; repository: https://github.com/Xinyuan-LilyGO/T-CameraPlus-S3 224 | ; Buy and support mcuw on aliexpress (affiliate link): https://s.click.aliexpress.com/e/_DkytBeT 225 | [env:lilygo-t-cameraplus-s3] 226 | board = LilyGo-T-CameraPlus-ESP32-S3 227 | board_build.partitions = huge_app.csv 228 | build_flags = 229 | ${esp32s3.build_flags} 230 | lib_deps = 231 | ${esp32s3.lib_deps} 232 | 233 | ; LILYGO: https://www.lilygo.cc/products/t-rgb 234 | ; repository: https://github.com/Xinyuan-LilyGO/LilyGo-T-RGB 235 | ; Buy and support mcuw on aliexpress (affiliate link): https://s.click.aliexpress.com/e/_Dem6i0b 236 | [env:lilygo-t-rgb] 237 | board = LilyGo-T-RGB 238 | board_build.partitions = huge_app.csv 239 | build_flags = 240 | ${esp32s3.build_flags} 241 | lib_deps = 242 | ${esp32s3.lib_deps} 243 | 244 | ; LILYGO: https://www.lilygo.cc/products/t-deck 245 | ; repository: https://github.com/Xinyuan-LilyGO/T-Deck 246 | ; Buy and support mcuw on aliexpress (affiliate link): 247 | ; - LilyGo T-Deck: https://s.click.aliexpress.com/e/_Dem6i0b 248 | ; - LilyGo T-Deck Plus: https://s.click.aliexpress.com/e/_DDeskaP 249 | [env:lilygo-t-deck] 250 | board = LilyGo-T-Deck 251 | board_build.partitions = huge_app.csv 252 | build_flags = 253 | ${esp32s3.build_flags} 254 | lib_deps = 255 | ${esp32s3.lib_deps} 256 | --------------------------------------------------------------------------------