### Create Project from Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/bluetooth/ble_profiles/esp/ble_ota/README.md Use this command to create a new project based on the ble_ota example. Ensure you have the IDF build system installed. ```bash idf.py create-project-from-example "espressif/ble_ota^0.1.8:ble_ota" ``` -------------------------------- ### Quick Start: Set Audio Volume using MCP C SDK Source: https://github.com/espressif/esp-iot-solution/blob/master/components/mcp-c-sdk/README.md This example demonstrates how to initialize the MCP server, create a tool to set audio volume with range validation, and start the server. It requires Wi-Fi initialization. ```c #include "esp_mcp_engine.h" #include "esp_mcp_mgr.h" #include "esp_mcp_tool.h" #include "esp_mcp_property.h" // Transport manager (esp_mcp_mgr_*) lives in esp_mcp_mgr.h // MCP engine (esp_mcp_*) lives in esp_mcp_engine.h // Tool callback function static esp_mcp_value_t set_volume_callback(const esp_mcp_property_list_t* properties) { // Get volume parameter from properties int volume = esp_mcp_property_list_get_property_int(properties, "volume"); if (volume < 0 || volume > 100) { ESP_LOGE(TAG, "Invalid volume value: %d", volume); return esp_mcp_value_create_bool(false); } // Set device volume current_volume = volume; ESP_LOGI(TAG, "Volume set to: %d", current_volume); return esp_mcp_value_create_bool(true); } void app_main(void) { // Initialize Wi-Fi (using example_connect) ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_event_loop_create_default()); ESP_ERROR_CHECK(example_connect()); // Create MCP server esp_mcp_t *mcp = NULL; ESP_ERROR_CHECK(esp_mcp_create(&mcp)); // Create tool with callback esp_mcp_tool_t *tool = esp_mcp_tool_create( "audio.set_volume", "Set audio speaker volume (0-100)", set_volume_callback ); // Add volume property with range validation (0-100) esp_mcp_tool_add_property(tool, esp_mcp_property_create_with_range("volume", 0, 100)); // Register tool to server ESP_ERROR_CHECK(esp_mcp_add_tool(mcp, tool)); // Initialize and start MCP with HTTP transport esp_mcp_mgr_handle_t mcp_handle = 0; esp_mcp_mgr_config_t config = MCP_SERVER_DEFAULT_CONFIG(); config.instance = mcp; ESP_ERROR_CHECK(esp_mcp_mgr_init(config, &mcp_handle)); ESP_ERROR_CHECK(esp_mcp_mgr_start(mcp_handle)); ESP_LOGI(TAG, "MCP server started on port 80"); } ``` -------------------------------- ### Example Output Log Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/usb/device/usb_uf2_nvs/README.md This log shows the initialization process, NVS modification, and successful Wi-Fi connection using the provided credentials. It indicates the steps from initial setup to network connectivity. ```log I (0) cpu_start: Starting scheduler on APP CPU. I (448) uf2_nvs_example: no ssid, give a init value to nvs I (448) uf2_nvs_example: no password, give a init value to nvs I (448) TUF2: UF2 Updater install succeed, Version: 0.0.1 I (778) tud_mount_cb: I (27608) uf2_nvs_example: uf2 nvs modified .... I (32888) uf2_nvs_example: wifi start ssid:ESP password:espressif I (32908) wifi:new:<1,1>, old:<1,0>, ap:<255,255>, sta:<1,1>, prof:1 I (33948) wifi:state: init -> auth (b0) I (33958) wifi:state: auth -> assoc (0) I (33978) wifi:state: assoc -> run (10) I (34098) wifi:connected with ESP, aid = 1, channel 1, 40U, bssid = bc:5f:f6:1b:28:5e I (34098) wifi:security: WPA2-PSK, phy: bgn, rssi: -26 I (34108) wifi:pm start, type: 1 I (34108) wifi:set rx beacon pti, rx_bcn_pti: 0, bcn_timeout: 0, mt_pti: 25000, mt_time: 10000 I (34108) wifi:AP's beacon interval = 102400 us, DTIM period = 1 I (34128) wifi:idx:0 (ifx:0, bc:5f:f6:1b:28:5e), tid:0, ssn:3, winSize:64 I (35618) esp_netif_handlers: sta ip: 192.168.1.9, mask: 255.255.255.0, gw: 192.168.1.1 I (35618) uf2_nvs_example: got ip:192.168.1.9 ``` -------------------------------- ### Weight Scale Service Example Source: https://github.com/espressif/esp-iot-solution/blob/master/docs/en/bluetooth/ble_wss.rst This example demonstrates the usage of the Weight Scale Service. It requires Bluetooth Low Energy setup. ```c #include "esp_log.h" #include "esp_check.h" #include "esp_bt.h" #include "esp_bt_main.h" #include "esp_gap_ble_api.h" #include "esp_gatts_api.h" #include "esp_gatt_defs.h" #include "esp_bt_gatt_util.h" #include "esp_bt_uuid.h" #include "esp_bt_helpers.h" #include "esp_wss.h" #define TAG "WSS_DEMO" static uint16_t wss_handle_table[SPP_LE_SPP_NUM_HANDLE]; static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) { switch (event) { case ESP_GATTS_REG_EVT: { esp_gatt_if_t interface = gatts_if; uint8_t service_uuid[16] = { 0x0d, 0x18, }; esp_bt_uuid_t *uuid = (esp_bt_uuid_t *)malloc(sizeof(esp_bt_uuid_t)); if (uuid) { uuid->len = ESP_UUID_LEN_16; memcpy(uuid->uuid.uuid16, service_uuid, sizeof(uint16_t)); esp_wss_config_t wss_cfg = { .role = ESP_WSS_ROLE_BROKER, }; esp_wss_init(uuid, &wss_cfg); free(uuid); } break; } case ESP_GATTS_READ_EVT: { ESP_LOGI(TAG, "GATT_READ_EVT, data range start: %d, data range end: %d", param->read.offset, param->read.len); if (param->read.handle == wss_handle_table[SPP_LE_SPP_DATA_CLIENT_CFG_IDX]) { ESP_LOGI(TAG, "Client Characteristic Configuration handle"); } break; } case ESP_GATTS_WRITE_EVT: { ESP_LOGI(TAG, "GATT_WRITE_EVT, data range start: %d, data range end: %d", param->write.offset, param->write.len); if (param->write.handle == wss_handle_table[SPP_LE_SPP_DATA_RECV_IDX]) { ESP_LOGI(TAG, "Data receive handle"); } else if (param->write.handle == wss_handle_table[SPP_LE_SPP_DATA_CLIENT_CFG_IDX]) { ESP_LOGI(TAG, "Client Characteristic Configuration handle"); if (param->write.value[0] == 1) { ESP_LOGI(TAG, "Client Characteristic Configuration: Notification Enable"); } else if (param->write.value[0] == 0) { ESP_LOGI(TAG, "Client Characteristic Configuration: Notification Disable"); } else { ESP_LOGI(TAG, "Unkown Client Characteristic Configuration : %d", param->write.value[0]); } } break; } case ESP_GATTS_CONNECT_EVT: { ESP_LOGI(TAG, "ESP_GATTS_CONNECT_EVT, remote %s, reason %d", esp_bt_dev_to_addr_str(param->connect.remote_bda, NULL), param->connect.reason); break; } case ESP_GATTS_DISCONNECT_EVT: { ESP_LOGI(TAG, "ESP_GATTS_DISCONNECT_EVT, disconnect reason 0x%x", param->disconnect.reason); esp_ble_gap_start_advertising(); break; } default: break; } } static void ble_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) { switch (event) { case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT: { esp_ble_gap_start_advertising(); break; } case ESP_GAP_BLE_ADV_START_COMPLETE_EVT: { if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) { ESP_LOGE(TAG, "Advertising start failed"); } else { ESP_LOGI(TAG, "Advertising started"); } break; } case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT: { ESP_LOGI(TAG, "update conn params."); break; } default: break; } } void app_main(void) { esp_err_t ret; esp_nimble_hci_and_controller_init(); esp_bluedroid_init(); esp_bluedroid_enable(); ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); ret = esp_bluedroid_init(); if (ret) { ESP_LOGE(TAG, "Bluetooth initialization failed: %s", esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { ESP_LOGE(TAG, "Bluetooth enable failed: %s", esp_err_to_name(ret)); return; } ret = esp_ble_gatts_register_callback(gatts_profile_event_handler); if (ret){ ESP_LOGE(TAG, "GATTS register callback failed, error code = %x", ret); return; } ret = esp_ble_gap_register_callback(ble_gap_event_handler); if(ret){ ESP_LOGE(TAG, "GAP register callback failed, error code = %x", ret); return; } esp_ble_gatts_app_register(0); esp_ble_auth_req_t auth_req = { .own_addr_type = ESP_PUBLIC_ADDR, .bond_dev = true, .மிட_addr_type = ESP_PUBLIC_ADDR, .dev_name = "ESP_WSS", .transport_type = ESP_BLE_TRANSPORT_BLE, .filter_policy = ESP_DBL_FILTER_ALLOW_NON_।, .io_cap = ESP_IO_CAP_NONE, .security_req_mask = ESP_SEC_ENCRYPT, }; esp_ble_set_security_param(ESP_BLE_SM_AUTHEN_REQ_MODE, &auth_req, sizeof(esp_ble_auth_req_t)); esp_ble_gap_set_security_param(ESP_BLE_SM_TARGET_INFO_REQ_MODE, &auth_req, sizeof(esp_ble_auth_req_t)); esp_ble_set_encryption_key_size(128); uint8_t service_uuid[16] = { 0x0d, 0x18, }; esp_bt_uuid_t *uuid = (esp_bt_uuid_t *)malloc(sizeof(esp_bt_uuid_t)); if (uuid) { uuid->len = ESP_UUID_LEN_16; memcpy(uuid->uuid.uuid16, service_uuid, sizeof(uint16_t)); esp_wss_config_t wss_cfg = { .role = ESP_WSS_ROLE_BROKER, }; esp_wss_init(uuid, &wss_cfg); free(uuid); } esp_ble_adv_data_t adv_data = { .set_scan = true, .include_name = true, .name_len = sizeof("ESP_WSS") - 1, .name = "ESP_WSS", .manufacturer_len = 0, .p_manufacturer_data = NULL, .service_data_len = 0, .p_service_data = NULL, .service_uuid_len = sizeof(service_uuid), .p_service_uuid = service_uuid, .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SUP | ESP_BLE_ADV_FLAG_CONT_ADV), }; esp_ble_gap_config_adv_data(&adv_data); } ``` -------------------------------- ### Example Console Output - SD Card Initialization Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/camera/video_recorder/README.md This log shows the initialization of the SD card, including its type, speed, and size, as well as the start of AVI recording. ```log I (855) ov2640: Set PLL: clk_2x: 0, clk_div: 0, pclk_auto: 0, pclk_div: 8 I (935) video_recorder: satrt to test fps I (1693) video_recorder: fps=25.010317, image_average_size=22142 I (1693) file manager: Initializing SD card I (1693) file manager: Using SDMMC peripheral I (1693) gpio: GPIO[39]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (1693) gpio: GPIO[38]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (1695) gpio: GPIO[40]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 Name: SC16G Type: SDHC/SDXC Speed: 20 MHz Size: 15193MB I (1755) avi recorder: Starting an avi [/sdcard/recorde.avi] I (21775) avi recorder: video info: width=640 | height=480 | fps=25 I (21785) avi recorder: frame number=502, size=9482KB I (21849) avi recorder: avi recording completed ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/espressif/esp-iot-solution/blob/master/docs/en/gettingstarted.rst Change into the 'button_power_save' example directory within the cloned repository. If copying the example, ensure 'override_path' configurations in 'main/idf_component.yml' are removed. ```bash cd examples/get-started/button_power_save ``` -------------------------------- ### WAV Player Example Output (SD Card) Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/audio/wav_player/README.md This log shows the application initializing the SD card and preparing to play WAV files. It lists detected files on the SD card and starts playback of the first file. ```log I (354) wav player: [APP] Startup.. I (358) wav player: [APP] Free memory: 299384 bytes I (363) wav player: [APP] IDF version: v4.2-rc-5-g511965b26 I (370) pwm_audio: timer: 0:0 | left io: 25 | right io: 26 | resolution: 10BIT I (379) file manager: Initializing SD card I (382) file manager: Using SDMMC peripheral I (388) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 Name: APPSD Type: SDSC Speed: 20 MHz Size: 961MB Traverse directory /audio |--- System Volume Information |--- WPSettings.dat[12B] |--- IndexerVolumeGuid[76B] |--- Michael Jackson - We Are The World (Demo).wav[56443632B] |--- Main Titles.wav[18522044B] |--- See you again.wav[40490720B] I (466) wav player: have file [0:Michael Jackson - We Are The World (Demo).wav] I (471) wav player: have file [1:Main Titles.wav] I (477) wav player: have file [2:See you again.wav] I (482) wav player: Start to play [0:Michael Jackson - We Are The World (Demo).wav] I (492) wav player: file stat info: /audio/Michael Jackson - We Are The World (Demo).wav (56443632 bytes)... I (503) wav player: frame_rate=44100, ch=2, width=16 ``` -------------------------------- ### Running the MCP Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/mcp-c-sdk/README.md Steps to set up, configure, build, and flash the MCP server example on an ESP32 device. ```bash cd examples/mcp/mcp_server idf.py set-target esp32 idf.py menuconfig # Configure Wi-Fi credentials idf.py build flash monitor ``` -------------------------------- ### Create Project from ble_htp Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/bluetooth/ble_profiles/std/ble_htp/README.md Use this command to create a new project from the ble_htp example template. The example will be downloaded to your current directory for building and flashing. ```bash idf.py create-project-from-example "espressif/ble_htp=*:ble_htp" ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/sensors/ntc_temperature_sensor/README.md Change directory to the ntc_temperature_sensor example within the esp-iot-solution project. ```linux cd ./esp-iot-solution/examples/sensors/ntc_temperature_sensor ``` -------------------------------- ### Create Project from ble_anp Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/bluetooth/ble_profiles/std/ble_anp/README.md Use this command to create a new project from the ble_anp example template. The example will be downloaded to your current directory for building and flashing. ```bash idf.py create-project-from-example "espressif/ble_anp=*:ble_anp" ``` -------------------------------- ### Main Entry Point - app_main() Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/bluetooth/ble_remote_control/tutorial/controller_walkthrough.md The entry point for the BLE HID Remote Control example. It initializes resources, configures Bluetooth, sets up GAP and GATT callbacks, creates tasks for input handling, and starts the main joystick task. Includes conditional logic for console or ADC input modes and an optional tear-down demo. ```c void app_main(void) { // Resource initialisation esp_err_t ret; ret = joystick_init(); if (ret != ESP_OK) { ESP_LOGE(HID_DEMO_TAG, "%s config joystick failed\n", __func__); return; } ret = button_init(); if (ret != ESP_OK) { ESP_LOGE(HID_DEMO_TAG, "%s config button failed\n", __func__); return; } ret = ble_config(); if (ret != ESP_OK) { ESP_LOGE(HID_DEMO_TAG, "%s config ble failed\n", __func__); return; } ESP_LOGI(HID_DEMO_TAG, "BLE configured"); // GAP and GATTS initialisation esp_ble_gap_register_callback(gap_event_callback); esp_ble_gatts_register_callback(gatts_event_callback); ESP_LOGI(HID_DEMO_TAG, "GAP and GATTS Callbacks registered"); gap_set_security(); ESP_LOGI(HID_DEMO_TAG, "Security set"); esp_ble_gatts_app_register(ESP_GATT_UUID_HID_SVC); // Trigger ESP_GATTS_REG_EVT (see gap_gatts.c and hidd.c) ret = esp_ble_gatt_set_local_mtu(500); if (ret){ ESP_LOGE(HID_DEMO_TAG, "set local MTU failed, error code = %x", ret); } // Create tasks and queue to handle input events input_queue = xQueueCreate(10, sizeof(input_event_t)); #ifdef CONFIG_JOYSTICK_INPUT_MODE_CONSOLE print_console_read_help(); xTaskCreate(joystick_console_read, "console_read_joystick", 2048, NULL, tskIDLE_PRIORITY, NULL); #else //CONFIG_JOYSTICK_INPUT_MODE_ADC xTaskCreate(joystick_ext_read, "ext_hardware_joystick", 2048, NULL, tskIDLE_PRIORITY, NULL); #endif // Main joystick task joystick_task(); #ifdef CONFIG_EXAMPLE_ENABLE_TEAR_DOWN_DEMO // Tear down, after returning from joystick_task() tear_down(); ESP_LOGI(HID_DEMO_TAG, "End of joystick demo, restarting in 5 seconds"); DELAY(5000); esp_restart(); #endif } ``` -------------------------------- ### Create Project from USB Host CDC Basic Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/usb/iot_usbh_cdc/README.md Use this command to create a new project from the USB Host CDC Basic example template. The example will be downloaded to your current folder. ```bash idf.py create-project-from-example "espressif/iot_usbh_cdc=*:usb_cdc_basic" ``` -------------------------------- ### Create Project from BLE HRP Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/bluetooth/ble_profiles/std/ble_hrp/README.md This command creates a new project from the ble_hrp example template. The example will be downloaded to your current directory for building and flashing. ```bash idf.py create-project-from-example "espressif/ble_hrp=*:ble_hrp" ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/motor/foc_openloop_control/README.md Change directory to the foc_openloop_control example folder within the esp-iot-solution project. ```linux cd ./esp-iot-solution/examples/motor/foc_openloop_control ``` -------------------------------- ### Create Project from Extended VFS Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/extended_vfs/README.md Generate a new project based on an Extended VFS example. Replace `gpio_simple` with the desired example name (e.g., `i2c_bh1750`, `ledc_simple`). ```bash idf.py create-project-from-example "espressif/extended_vfs=*:gpio_simple" ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/lighting/dali_basic/README.md Change the current directory to the DALI basic example within the esp-iot-solution repository. ```bash cd ./esp-iot-solution/examples/lighting/dali_basic ``` -------------------------------- ### Create Project from Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/elf_loader/README.md Generate a new project from an example template using 'idf.py create-project-from-example'. This command downloads the specified example into the current directory. ```bash idf.py create-project-from-example "espressif/elf_loader=*:elf_loader_example" ``` -------------------------------- ### Install ESP-PPQ Source: https://github.com/espressif/esp-iot-solution/blob/master/docs/en/ai/touch_digit_recognition.rst Installs the ESP-PPQ quantization tool by first uninstalling any existing ppq installation and then installing directly from the GitHub repository. ```bash pip uninstall ppq pip install git+https://github.com/espressif/esp-ppq.git ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/motor/foc_velocity_control/README.md Change the current directory to the foc_velocity_control example folder within the esp-iot-solution project. ```linux cd ./esp-iot-solution/examples/motor/foc_velocity_control ``` -------------------------------- ### Create Project from BLE Device Information Service Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/bluetooth/ble_services/README.md This command creates a new project from the BLE Device Information Service (DIS) example template. The example will be downloaded to your current directory, allowing you to build and flash it. ```bash idf.py create-project-from-example "espressif/ble_services=*:ble_dis" ``` -------------------------------- ### Create Project from GProf Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/gprof/README.md Use 'idf.py create-project-from-example' to generate a new project based on the 'gprof_simple' example. This downloads the example code to your current directory. ```sh idf.py create-project-from-example "espressif/gprof=*:gprof_simple" ``` -------------------------------- ### Create BLE MIDI Example Project Source: https://github.com/espressif/esp-iot-solution/blob/master/components/bluetooth/ble_profiles/third_party/ble_midi/README.md This command creates a new project from a template that includes the ble_midi example. The example demonstrates registering and publishing the BLE-MIDI GATT service, sending/receiving BEP via notifications, and aggregating messages. ```bash idf.py create-project-from-example "espressif/ble_profiles=*:ble_midi" ``` -------------------------------- ### LittleFS Usage Example Source: https://github.com/espressif/esp-iot-solution/blob/master/docs/en/storage/file_system.rst A basic example program demonstrating the usage of the LittleFS file system. ```c #include "esp_log.h" #include "esp_err.h" #include "esp_vfs_littlefs.h" static const char *TAG = "example"; void app_main(void) { esp_err_t ret; // Mount LittleFS filesystem ret = esp_vfs_littlefs_register("/littlefs", "storage", 5, NULL); if (ret != ESP_OK) { ESP_LOGE(TAG, "Failed to mount LittleFS: %s", esp_err_to_name(ret)); return; } ESP_LOGI(TAG, "LittleFS mounted"); // Use the filesystem // ... your code here ... // Unmount ret = esp_vfs_littlefs_unregister("/littlefs"); if (ret != ESP_OK) { ESP_LOGE(TAG, "Failed to unmount LittleFS: %s", esp_err_to_name(ret)); } ESP_LOGI(TAG, "LittleFS unmounted"); } ``` -------------------------------- ### Start IOT ETH Layer Source: https://github.com/espressif/esp-iot-solution/blob/master/docs/en/solution/4g/iot_eth.rst Starts the IOT ETH driver after it has been installed. This function is crucial for enabling network communication over the Ethernet interface. ```c ret = iot_eth_start(eth_handle); if (ret != ESP_OK) { ESP_LOGE(TAG, "Failed to start eth driver"); return; } ``` -------------------------------- ### Create Project from Simple OTA Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/bootloader_support_plus/README.md Use this command to create a new project based on the `simple_ota_example` provided in the esp-iot-solution repository. This example demonstrates bootloader support plus. ```bash idf.py create-project-from-example "espressif/bootloader_support_plus=*:simple_ota_example" ``` -------------------------------- ### Initialize and Start BLE Connection Source: https://github.com/espressif/esp-iot-solution/blob/master/docs/en/bluetooth/ble_conn_mgr.rst Initializes the BLE connection manager with configuration and starts the BLE advertising. Use this for basic BLE setup. ```c esp_ble_conn_config_t config = { .device_name = CONFIG_EXAMPLE_BLE_ADV_NAME, .broadcast_data = CONFIG_EXAMPLE_BLE_SUB_ADV }; ESP_ERROR_CHECK(esp_ble_conn_init(&config)); ESP_ERROR_CHECK(esp_ble_conn_start()); ``` -------------------------------- ### Example Output Log Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/elf_loader/elf_loader_example/README.md Sample log output observed when running the ELF loader example, showing the start and successful execution of the ELF application. ```log I (0) cpu_start: Starting scheduler on APP CPU. I (382) elf_loader: Start to relocate ELF I (392) elf_loader: Start to run ELF hello world 0 hello world 1 hello world 2 hello world 3 hello world 4 hello world 5 hello world 6 hello world 7 hello world 8 hello world 9 I (10392) elf_loader: Success to exit from APP of ELF ``` -------------------------------- ### Create Project from QuickJS-NG Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/quickjs-ng/README.md Use the component manager to create a new project based on the QuickJS-NG example template. ```bash idf.py create-project-from-example "espressif/quickjs-ng=*:quickjs-ng" ``` -------------------------------- ### Example Usage of adc_battery_estimation Source: https://github.com/espressif/esp-iot-solution/blob/master/components/sensors/battery_fuel_gauge/adc_battery_estimation/README.md This example demonstrates how to initialize and use the adc_battery_estimation component to get battery capacity readings. Ensure necessary ADC configurations and resistor values are set correctly. ```c #include #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "adc_battery_estimation.h" #define TEST_ADC_UNIT (ADC_UNIT_1) #define TEST_ADC_BITWIDTH (ADC_BITWIDTH_DEFAULT) #define TEST_ADC_ATTEN (ADC_ATTEN_DB_12) #define TEST_ADC_CHANNEL (ADC_CHANNEL_1) #define TEST_RESISTOR_UPPER (460) #define TEST_RESISTOR_LOWER (460) #define TEST_ESTIMATION_TIME (50) void app_main(void) { adc_battery_estimation_t config = { .internal = { .adc_unit = TEST_ADC_UNIT, .adc_bitwidth = TEST_ADC_BITWIDTH, .adc_atten = TEST_ADC_ATTEN, }, .adc_channel = TEST_ADC_CHANNEL, .lower_resistor = TEST_RESISTOR_LOWER, .upper_resistor = TEST_RESISTOR_UPPER, }; adc_battery_estimation_handle_t adc_battery_estimation_handle = adc_battery_estimation_create(&config); for (int i = 0; i < TEST_ESTIMATION_TIME; i++) { float capacity = 0; adc_battery_estimation_get_capacity(adc_battery_estimation_handle, &capacity); printf("Battery capacity: %.1f%%\n", capacity); vTaskDelay(pdMS_TO_TICKS(500)); } adc_battery_estimation_destroy(adc_battery_estimation_handle); } ``` -------------------------------- ### Example Console Output Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/bluetooth/ble_conn_mgr/ble_periodic_adv/README.md This is the typical console output observed when the periodic_adv example is started. It shows initialization details for the Bluetooth controller and host, including MAC address and BLE host task status. ```log I (316) BTDM_INIT: BT controller compile version [80abacd] I (316) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12 I (366) system_api: Base MAC address is not set I (366) system_api: read default base MAC address from EFUSE I (376) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a I (376) blecm_nimble: BLE Host Task Started I (386) blecm_nimble: getting characteristic(0x2a00) I (386) blecm_nimble: getting characteristic(0x2a01) I (396) blecm_nimble: getting characteristic(0x2a05) I (406) blecm_nimble: Instance 1 started (periodic) I (406) blecm_nimble: Instance 1 started (extended) ``` -------------------------------- ### Create USB Camera Local Display Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/usb/usb_stream/README.md Create a project from the usb_camera_lcd_display example template for local display of USB Camera feeds. ```bash idf.py create-project-from-example "espressif/usb_stream=*:usb_camera_lcd_display" ``` -------------------------------- ### MCP Server Connection Log Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/mcp/mcp_server/README.md Example log output showing the MCP server starting and registering its endpoint after a successful Wi-Fi connection. ```log I (2543) wifi:connected with MySSID, aid = 1, channel 6, BW20, bssid = xx:xx:xx:xx:xx:xx I (3542) example_connect: - IPv4 address: 192.168.1.100 I (3552) mcp_server: MCP Server started on port 80 I (3553) mcp_server: MCP endpoint registered: /mcp_server ``` -------------------------------- ### Build, Flash, and Monitor USB Stream Example Source: https://github.com/espressif/esp-iot-solution/blob/master/components/usb/usb_stream/examples/usb_stream_mic_spk/README.md Builds, flashes, and monitors the USB stream example project. Ensure the IDF environment is set up and the target chip is configured. ```bash # Run . ./export.sh to set IDF environment # Run idf.py set-target esp32s3 to set target chip # Run pip install "idf-component-manager~=1.1.4" to upgrade your component manager if any error happens during last step idf.py -p PORT flash monitor ``` -------------------------------- ### Example BLE OTS Console Output Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/bluetooth/ble_services/ble_ots/README.md Sample console output after the ESP-IDF project boots and starts advertising the BLE Object Transfer Service. ```log I (330) BLE_INIT: BT controller compile version [9359a4d] I (340) system_api: Base MAC address is not set I (340) system_api: read default base MAC address from EFUSE I (350) BLE_INIT: Bluetooth MAC: 58:cf:79:1e:9e:de I (350) phy_init: phy_version 1150,7c3c08f,Jan 24 2024,17:32:21 I (420) blecm_nimble: BLE Host Task Started I (420) blecm_nimble: No characteristic(0x2a00) found I (420) blecm_nimble: No characteristic(0x2a01) found I (420) blecm_nimble: No characteristic(0x2a05) found I (430) NimBLE: GAP procedure initiated: stop advertising. I (440) NimBLE: GAP procedure initiated: advertise; I (440) NimBLE: disc_mode=2 I (440) NimBLE: adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256 I (450) NimBLE: I (460) main_task: Returned from app_main() ``` -------------------------------- ### Example Output Log Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/usb/device/usb_webcam/README.md This log shows the initialization process of the USB WebCam example, including camera detection, format negotiation, and configuration details. ```log I (0) cpu_start: Starting scheduler on APP CPU. I (533) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations I (534) usb_webcam: Selected Camera Board ESP-S3-EYE I (534) usb_webcam: Format List I (534) usb_webcam: Format(1) = MJPEG I (534) usb_webcam: Frame List I (535) usb_webcam: Frame(1) = 1280 * 720 @15fps, Quality = 14 I (535) usb_webcam: Frame(2) = 640 * 480 @15fps, Quality = 14 I (535) usb_webcam: Frame(3) = 480 * 320 @30fps, Quality = 10 I (869) usb_webcam: Mount I (2099) usb_webcam: Suspend I (9343) usb_webcam: bFrameIndex: 1 I (9343) usb_webcam: dwFrameInterval: 666666 I (9343) s3 ll_cam: DMA Channel=4 I (9344) cam_hal: cam init ok I (9434) sccb: pin_sda 4 pin_scl 5 I (9434) sccb: sccb_i2c_port=1 I (9354) camera: Detected camera at address=0x30 I (9357) camera: Detected OV2640 camera I (9357) camera: Camera PID=0x26 VER=0x42 MIDL=0x7f MIDH=0xa2 I (9434) cam_hal: buffer_size: 16384, half_buffer_size: 1024, node_buffer_size: 1024, node_cnt: 16, total_cnt: 180 I (9435) cam_hal: Allocating 184320 Byte frame buffer in PSRAM I (9435) cam_hal: Allocating 184320 Byte frame buffer in PSRAM I (9436) cam_hal: cam config ok I (9436) ov2640: Set PLL: clk_2x: 0, clk_div: 0, pclk_auto: 0, pclk_div: 12 ``` -------------------------------- ### Build and Flash Example with Board Manager Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/ai/xiaozhi_chat/README.md Build, flash, and monitor the example using idf.py, ensuring the board configuration is generated first. Set IDF_EXTRA_ACTIONS_PATH if required. ```bash export IDF_EXTRA_ACTIONS_PATH=./managed_components/espressif__esp_board_manager # Board config: run after first clone or when changing board (-l list boards, -b set board by name or index) idf.py gen-bmgr-config -l idf.py gen-bmgr-config -b # Build, flash and open serial monitor (replace PORT with your port, e.g. /dev/ttyUSB0 or COM3) idf.py -p PORT build flash monitor ``` -------------------------------- ### Initialize MIPI DSI Bus and Panel IO Source: https://github.com/espressif/esp-iot-solution/blob/master/docs/en/display/lcd/mipi_dsi_lcd.rst Initialize the MIPI DSI bus and install the panel IO for an LCD device. This example uses EK79007_PANEL_BUS_DSI_2CH_CONFIG for bus configuration. ```c ESP_LOGI(TAG, "MIPI DSI PHY Powered on"); esp_ldo_channel_handle_t ldo_mipi_phy = NULL; esp_ldo_channel_config_t ldo_mipi_phy_config = { .chan_id = 3, .voltage_mv = 2500, }; ESP_ERROR_CHECK(esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldo_mipi_phy)); ESP_LOGI(TAG, "Initialize MIPI DSI bus"); esp_lcd_dsi_bus_handle_t mipi_dsi_bus = NULL; esp_lcd_dsi_bus_config_t bus_config = EK79007_PANEL_BUS_DSI_2CH_CONFIG(); ESP_ERROR_CHECK(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus)); ESP_LOGI(TAG, "Install panel IO"); esp_lcd_panel_io_handle_t mipi_dbi_io = NULL; esp_lcd_dpi_panel_config_t dpi_config = { .virtual_channel = 0, .dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, .dpi_clock_freq_mhz = 60, // Pixel clock frequency .in_color_format = LCD_COLOR_FMT_RGB888, // Color format .video_timing = { ``` -------------------------------- ### Initialize SPD2010 Touch Driver Source: https://github.com/espressif/esp-iot-solution/blob/master/docs/en/input_device/touch_panel.rst Example of initializing the SPD2010 touch driver using I2C. Configure GPIO pins and touch panel parameters according to your hardware setup. ```c #include "esp_lcd_touch_spd2010.h" esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_SPD2010_CONFIG(); esp_lcd_touch_config_t tp_cfg = { .x_max = 320, .y_max = 320, .rst_gpio_num = GPIO_NUM_NC, .int_gpio_num = GPIO_NUM_NC, .levels = { .reset = 0, .interrupt = 0, }, .flags = { .swap_xy = 0, .mirror_x = 0, .mirror_y = 0, }, }; esp_lcd_touch_handle_t tp; ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_spd2010(io_handle, &tp_cfg, &tp)); ``` -------------------------------- ### Build and Flash LVGL Lottie Player Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/display/gui/lvgl_lottie_player/README.md Navigate to the example directory, set the target, and build/flash the project. This is the standard procedure for deploying the LVGL Lottie Player example. ```bash cd examples/display/gui/lvgl_lottie_player idf.py set-target esp32s31 idf.py build flash monitor ``` -------------------------------- ### Initialize QSPI Interface for CO5300 LCD Source: https://github.com/espressif/esp-iot-solution/blob/master/components/display/lcd/esp_lcd_co5300/README.md Configures and initializes the QSPI bus and panel IO for the CO5300 LCD. Ensure that the example pins and host are defined correctly for your hardware setup. ```c ESP_LOGI(TAG, "Initialize QSPI bus"); const spi_bus_config_t buscfg = CO5300_PANEL_BUS_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_PCLK, EXAMPLE_PIN_NUM_LCD_DATA0, EXAMPLE_PIN_NUM_LCD_DATA1, EXAMPLE_PIN_NUM_LCD_DATA2, EXAMPLE_PIN_NUM_LCD_DATA3, EXAMPLE_LCD_H_RES * 80 * sizeof(uint16_t)); ESP_ERROR_CHECK(spi_bus_initialize(EXAMPLE_LCD_HOST, &buscfg, SPI_DMA_CH_AUTO)); ESP_LOGI(TAG, "Install panel IO"); esp_lcd_panel_io_handle_t io_handle = NULL; const esp_lcd_panel_io_spi_config_t io_config = CO5300_PANEL_IO_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_CS, callback, &callback_data); ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)EXAMPLE_LCD_HOST, &io_config, &io_handle)); ``` -------------------------------- ### Initialization Log Example Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/display/gui/lvgl_common_demo/README.md The serial console will display initialization logs upon successful flashing. These logs indicate the selected LCD interface and resolution, and confirm the start of the LVGL benchmark demo. ```log I (xxx) main: Selected LCD interface: MIPI DSI I (xxx) main: Initializing LCD: 1024x600 I (xxx) main: Starting LVGL benchmark demo ``` -------------------------------- ### Initialize and Use NTC Thermistor Sensor Source: https://github.com/espressif/esp-iot-solution/blob/master/components/sensors/ntc_driver/README.md This example demonstrates how to configure, create, and use the NTC driver to get temperature readings. Ensure the correct circuit mode and ADC parameters are set. ```c //1.Select the NTC sensor and initialize the hardware parameters ntc_config_t ntc_config = { .b_value = 3950, .r25_ohm = 10000, .fixed_ohm = 10000, .vdd_mv = 3300, .circuit_mode = CIRCUIT_MODE_NTC_GND, .atten = ADC_ATTEN_DB_11, .channel = ADC_CHANNEL_3, .unit = ADC_UNIT_1 }; //2.Create the NTC Driver and Init ADC ntc_device_handle_t ntc = NULL; adc_oneshot_unit_handle_t adc_handle = NULL; ESP_ERROR_CHECK(ntc_dev_create(&ntc_config, &ntc, &adc_handle)); ESP_ERROR_CHECK(ntc_dev_get_adc_handle(ntc, &adc_handle)); //3.Call the temperature function float temp = 0.0; if (ntc_dev_get_temperature(ntc, &temp) == ESP_OK) { ESP_LOGI(TAG, "NTC temperature = %.2f ℃", temp); } ESP_ERROR_CHECK(ntc_dev_delete(ntc)); ``` -------------------------------- ### Interact with BLE UART Bridge Devices Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/bluetooth/ble_uart_service/README.md List available BLE devices, check connection, enter console mode, or start a daemon for OpenCode integration. Ensure the example is flashed and advertising first. ```bash cd $IDF_PATH/tools/ble/ble_uart_bridge python main.py list-devices python main.py connection-check python main.py console python main.py daemon --host 127.0.0.1 --port 8888 ``` -------------------------------- ### Build and Flash Project Source: https://github.com/espressif/esp-iot-solution/blob/master/examples/ai/esp_dl/self_learning_classification/README.md Build the project, flash it to the board, and monitor serial output. Replace PORT with your board's serial port name. Exit the monitor with Ctrl+]. ```bash idf.py -p PORT flash monitor ``` -------------------------------- ### Initialize and Control Sensorless BLDC Motor Source: https://github.com/espressif/esp-iot-solution/blob/master/components/motor/esp_sensorless_bldc_control/README.md Example demonstrating the initialization and control of a sensorless BLDC motor using the ESP Sensorless BLDC Control component. This includes setting up event handlers, motor configuration, and starting the motor. ```c esp_event_loop_create_default(); esp_event_handler_register(BLDC_CONTROL_EVENT, ESP_EVENT_ANY_ID, &bldc_control_event_handler, NULL); switch_config_t_t upper_switch_config = { .control_type = CONTROL_TYPE_MCPWM, .bldc_mcpwm = { .group_id = 0, .gpio_num = {17,16,15}, }, }; switch_config_t_t lower_switch_config = { .control_type = CONTROL_TYPE_GPIO, .bldc_gpio[0] = { .gpio_num = 12, .gpio_mode = GPIO_MODE_OUTPUT, }, .bldc_gpio[1] = { .gpio_num = 11, .gpio_mode = GPIO_MODE_OUTPUT, }, .bldc_gpio[2] = { .gpio_num = 10, .gpio_mode = GPIO_MODE_OUTPUT, }, }; bldc_zero_cross_adc_config_t zero_cross_adc_config = { .adc_handle = NULL, .adc_unit = ADC_UNIT_1, .chan_cfg = { .bitwidth = ADC_BITWIDTH_12, .atten = ADC_ATTEN_DB_0, }, .adc_channel = {ADC_CHANNEL_3, ADC_CHANNEL_4, ADC_CHANNEL_5, ADC_CHANNEL_0, ADC_CHANNEL_1}, }; bldc_control_config_t config = { .speed_mode = SPEED_CLOSED_LOOP, .control_mode = BLDC_SIX_STEP, .alignment_mode = ALIGNMENT_ADC, .six_step_config = { .lower_switch_active_level = 0, .upper_switch_config = upper_switch_config, .lower_switch_config = lower_switch_config, .mos_en_config.has_enable = false, }, .zero_cross_adc_config = zero_cross_adc_config, }; /*!< Init hardware driver */ bldc_control_init(&bldc_control_handle, &config); /*!< Setting motor direction */ bldc_control_set_dir(bldc_control_handle, CCW); /*!< Start motor control */ bldc_control_start(bldc_control_handle, 300); ```