{"id":2993,"date":"2024-11-20T15:00:04","date_gmt":"2024-11-20T07:00:04","guid":{"rendered":"https:\/\/saludpcb.com\/zh\/?p=2993"},"modified":"2025-09-26T06:16:05","modified_gmt":"2025-09-25T22:16:05","slug":"uart-with-esp32-uart-guide-send-and-receive","status":"publish","type":"post","link":"https:\/\/saludpcb.com\/zh\/uart-with-esp32-uart-guide-send-and-receive\/","title":{"rendered":"\u7cbe\u901a ESP32 UART | \u5b8c\u6574\u7684\u767c\u9001\u8207\u63a5\u6536\u6578\u64da\u6307\u5357"},"content":{"rendered":"\n<hr class=\"wp-block-separator alignwide has-text-color has-palette-color-1-color has-alpha-channel-opacity has-palette-color-1-background-color has-background is-style-wide\"\/>\n\n\n\n<p>ESP32 UART\uff08\u901a\u7528\u975e\u540c\u6b65\u6536\u767c\u5668\uff09\u5728\u9019\u500b\u5b8c\u6574\u7684\u6307\u5357\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e&nbsp;UART&nbsp;\u7684\u57fa\u790e\u77e5\u8b58\u3001\u5982\u4f55\u5728&nbsp;ESP32&nbsp;\u4e0a\u8a2d\u7f6e&nbsp;UART\uff0c\u4e26\u63d0\u4f9b\u5be6\u7528\u7684\u6578\u64da\u50b3\u8f38\u793a\u4f8b\u3002\u7121\u8ad6\u60a8\u662f\u521d\u5b78\u8005\u9084\u662f\u7d93\u9a57\u8c50\u5bcc\u7684\u958b\u767c\u8005\uff0c\u638c\u63e1&nbsp;UART&nbsp;\u901a\u4fe1\u90fd\u80fd\u986f\u8457\u63d0\u5347\u60a8\u7684\u9805\u76ee\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/saludpcb.com\/zh\/wp-content\/uploads\/2024\/11\/Mastering-ESP32-UART-Complete-Guide-for-Sending-and-Receiving-Data.jpg\" alt=\"ESP32 UART\" class=\"wp-image-3004\" title=\"\" srcset=\"https:\/\/saludpcb.com\/zh\/wp-content\/uploads\/2024\/11\/Mastering-ESP32-UART-Complete-Guide-for-Sending-and-Receiving-Data.jpg 1024w, https:\/\/saludpcb.com\/zh\/wp-content\/uploads\/2024\/11\/Mastering-ESP32-UART-Complete-Guide-for-Sending-and-Receiving-Data-768x768.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>\u5167\u5bb9<\/h2><nav><ul><li class=\"\"><a href=\"#introduction\">\u7c21\u4ecb<\/a><\/li><li class=\"\"><a href=\"#why-use-dma-and-i-2-s-with-adc-on-esp-32-1\">UART<\/a><\/li><li class=\"\"><a href=\"#why-use-dma-and-i-2-s-with-adc-on-esp-32\">ESP32 UART \u786c\u9ad4\u7279\u6027<\/a><\/li><li class=\"\"><a href=\"#setting-up-i-2-s-and-dma-for-adc-data-collection\">\u4f7f\u7528 ESP32-PICO-KIT \u958b\u767c\u677f<\/a><\/li><li class=\"\"><a href=\"#\u7de8\">\u7de8\u5beb\u4ee3\u78bc<\/a><\/li><li class=\"\"><a href=\"#\u4ee3\u78bc\u89e3\u91cb\">\u4ee3\u78bc\u89e3\u91cb<\/a><\/li><li class=\"\"><a href=\"#data-collection-and-processing\">\u8f38\u51fa\u8aaa\u660e<\/a><\/li><li class=\"\"><a href=\"#\u7bc4\u4f8b\u8f38\u51fa\u65e5\u5fd7\uff1a-1\">\u7d50\u679c\u8f38\u51fa<\/a><\/li><li class=\"\"><a href=\"#conclusion\">\u7d50\u8ad6<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"introduction\">\u7c21\u4ecb<\/h2>\n\n\n\n<p>UART\uff08Universal Asynchronous Receiver Transmitter\uff09\u662f\u4e00\u7a2e\u57fa\u65bc\u786c\u9ad4\u7684\u5354\u8b70\uff0c\u901a\u5e38\u7528\u65bc\u5fae\u63a7\u5236\u5668\u8207\u5176\u4ed6\u8a2d\u5099\u4e4b\u9593\u7684\u4e32\u884c\u901a\u4fe1\u3002\u5b83\u4f7f\u7528\u5169\u689d\u7dda\uff1aTX\uff08\u50b3\u8f38\uff09\u548c RX\uff08\u63a5\u6536\uff09\u3002\u6578\u64da\u4ee5\u4e00\u4f4d\u4e00\u4f4d\u7684\u65b9\u5f0f\u5728\u9019\u5169\u689d\u7dda\u4e0a\u50b3\u9001\uff0c\u4e26\u4e14 UART \u901a\u4fe1\u662f<strong>\u7570\u6b65\u7684<\/strong>\uff0c\u9019\u610f\u5473\u8457\u4e0d\u9700\u8981\u540c\u6b65\u6642\u9418\u4fe1\u865f\u4f86\u63a7\u5236\u6578\u64da\u50b3\u8f38\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"why-use-dma-and-i-2-s-with-adc-on-esp-32-1\">UART<\/h2>\n\n\n\n<p>UART \u662f\u4e00\u7a2e\u786c\u4ef6\u901a\u4fe1\u5354\u8b70\uff0c\u4f7f\u8a2d\u5099\u4e4b\u9593\u80fd\u9032\u884c\u4e32\u884c\u901a\u4fe1\u3002\u5b83\u4f7f\u7528\u5169\u689d\u6578\u64da\u7dda\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>TX\uff08\u50b3\u8f38\uff09<\/strong>\uff1a\u5c07\u6578\u64da\u767c\u9001\u5230\u53e6\u4e00\u500b\u8a2d\u5099\u3002<\/li>\n\n\n\n<li><strong>RX\uff08\u63a5\u6536\uff09<\/strong>\uff1a\u5f9e\u53e6\u4e00\u500b\u8a2d\u5099\u63a5\u6536\u6578\u64da\u3002<\/li>\n<\/ul>\n\n\n\n<p>UART \u901a\u4fe1\u662f\u7570\u6b65\u7684\uff0c\u9019\u610f\u5473\u8457\u5b83\u4e0d\u9700\u8981\u5171\u4eab\u6642\u9418\u4fe1\u865f\u3002\u76f8\u53cd\uff0c\u96d9\u65b9\u8a2d\u5099\u9700\u8981\u5354\u5546\u4e00\u500b\u6ce2\u7279\u7387\uff08\u6bcf\u79d2\u50b3\u8f38\u7684\u6bd4\u7279\u6578\uff09\uff0c\u4ee5\u78ba\u4fdd\u6b63\u78ba\u7684\u6578\u64da\u50b3\u8f38\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"why-use-dma-and-i-2-s-with-adc-on-esp-32\">ESP32 UART \u786c\u9ad4\u7279\u6027<\/h2>\n\n\n\n<p>\u6211\u5011\u5c07\u4f7f\u7528 ESP32 \u7684 UART \u7aef\u53e3\u4f86\u9032\u884c\u4e32\u884c\u901a\u4fe1\u3002\u9019\u662f\u786c\u9ad4\u63a5\u7dda\u7684\u57fa\u672c\u6d41\u7a0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>TX \u5f15\u8173<\/strong>\uff1a\u5c07 ESP32 \u7684 TX\uff08\u50b3\u8f38\u7aef\uff09\u5f15\u8173\u9023\u63a5\u5230\u63a5\u6536\u8a2d\u5099\u7684 RX\uff08\u63a5\u6536\u7aef\uff09\u5f15\u8173\u3002<\/li>\n\n\n\n<li><strong>RX \u5f15\u8173<\/strong>\uff1a\u5c07 ESP32 \u7684 RX \u5f15\u8173\u9023\u63a5\u5230\u767c\u9001\u8a2d\u5099\u7684 TX \u5f15\u8173\u3002<\/li>\n\n\n\n<li><strong>GND \u5f15\u8173<\/strong>\uff1a\u5c07 ESP32 \u7684 GND \u5f15\u8173\u9023\u63a5\u5230\u5916\u90e8\u8a2d\u5099\u7684 GND\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u63a5\u7dda\u793a\u610f\u5716\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"adoc\" class=\"language-adoc\">Module            PC or Mac\nESP32 (TX) ----&gt; \u5916\u90e8\u8a2d\u5099 (RX)\nESP32 (RX) &lt;---- \u5916\u90e8\u8a2d\u5099 (TX)\nGND -------------------- GND<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"setting-up-i-2-s-and-dma-for-adc-data-collection\">\u4f7f\u7528 ESP32-PICO-KIT \u958b\u767c\u677f<\/h2>\n\n\n\n<p><strong>\u786c\u9ad4\u80cc\u666f<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GPIO16 \u548c GPIO17 \u662f&nbsp;<strong>ESP32 \u6a21\u7d44\u5167\u90e8 UART0<\/strong>&nbsp;\u7684\u9810\u8a2d\u8173\u4f4d\uff0c\u8207 USB-to-UART \u63a5\u53e3\u76f8\u9023\uff0c\u7528\u65bc\u71d2\u9304\u7a0b\u5f0f\u548c\u5e8f\u5217\u76e3\u8996\u3002<\/li>\n\n\n\n<li>\u9019\u4e9b\u8173\u4f4d\u88ab\u5167\u90e8\u4f7f\u7528\uff0c\u7121\u6cd5\u4f5c\u70ba\u5916\u90e8 UART \u901a\u8a0a\u7684 TX \u548c RX \u8173\u4f4d\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u66ff\u4ee3\u65b9\u6cd5<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6539\u7528&nbsp;<strong>GPIO21 (TX)<\/strong>&nbsp;\u548c&nbsp;<strong>GPIO22 (RX)<\/strong>&nbsp;\u4f5c\u70ba UART2 \u7684\u50b3\u8f38\u548c\u63a5\u6536\u8173\u4f4d\u3002<\/li>\n\n\n\n<li>GPIO21 \u548c GPIO22 \u662f\u901a\u7528\u8173\u4f4d\uff0c\u53ef\u7528\u65bc UART \u6216\u5176\u4ed6\u5916\u8a2d\u901a\u8a0a\uff0c\u4e14\u5728 <a href=\"https:\/\/saludpcb.com\/zh\/esp32-pico-devkit-module-pinout\/\">ESP32-PICO-KIT<\/a> \u4e2d\u662f\u81ea\u7531\u53ef\u7528\u7684\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u7de8\">\u7de8\u5beb\u4ee3\u78bc<\/h2>\n\n\n\n<p>\u9996\u5148\uff0c\u6211\u5011\u9700\u8981\u521d\u59cb\u5316 ESP32 UART \u4e26\u914d\u7f6e\u6ce2\u7279\u7387\u3001\u6578\u64da\u4f4d\u3001\u505c\u6b62\u4f4d\u7b49\u53c3\u6578\u3002ESP32 \u652f\u63f4\u6700\u591a\u4e09\u500b UART \u57e0\uff0c\u6bcf\u500b UART \u57e0\u90fd\u53ef\u4ee5\u914d\u7f6e\u4e0d\u540c\u7684\u8a2d\u7f6e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"cpp\" class=\"language-cpp\">#include &lt;stdio.h&gt;\n#include &lt;string.h&gt;\n#include \"freertos\/FreeRTOS.h\"\n#include \"freertos\/task.h\"\n#include \"driver\/uart.h\"\n#include \"driver\/gpio.h\"\n#include \"esp_log.h\"\n\nstatic const char *TAG = \"uart_test\";\n\n\/\/ UART configuration\n#define UART_NUM UART_NUM_2        \/\/ Using UART2\n#define UART_TX_PIN GPIO_NUM_21    \/\/ TX Pin\n#define UART_RX_PIN GPIO_NUM_22    \/\/ RX Pin\n#define UART_BAUD_RATE 115200      \/\/ Baud rate\n#define BUF_SIZE 256               \/\/ Buffer size\n\n\/\/ UART initialization function\nstatic void uart_init() {\n    \/\/ Check if UART driver is already installed, and remove it if necessary\n    if (uart_is_driver_installed(UART_NUM)) {\n        uart_driver_delete(UART_NUM);\n        vTaskDelay(pdMS_TO_TICKS(100));  \/\/ Allow time for proper cleanup\n    }\n\n    \/\/ UART configuration structure\n    uart_config_t uart_config = {\n        .baud_rate = UART_BAUD_RATE,\n        .data_bits = UART_DATA_8_BITS,\n        .parity = UART_PARITY_DISABLE,\n        .stop_bits = UART_STOP_BITS_1,\n        .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,\n        .rx_flow_ctrl_thresh = 122,\n        .source_clk = UART_SCLK_APB,\n    };\n\n    \/\/ Configure UART parameters\n    esp_err_t err = uart_param_config(UART_NUM, &amp;uart_config);\n    if (err != ESP_OK) {\n        ESP_LOGE(TAG, \"UART parameter config failed with error: %d\", err);\n        return;\n    }\n\n    \/\/ Set UART pins\n    err = uart_set_pin(UART_NUM, UART_TX_PIN, UART_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);\n    if (err != ESP_OK) {\n        ESP_LOGE(TAG, \"UART set pin failed with error: %d\", err);\n        return;\n    }\n\n    \/\/ Install UART driver\n    err = uart_driver_install(UART_NUM, BUF_SIZE, BUF_SIZE, 0, NULL, 0);\n    if (err != ESP_OK) {\n        ESP_LOGE(TAG, \"UART driver install failed with error: %d\", err);\n        return;\n    }\n\n    ESP_LOGI(TAG, \"UART initialized successfully\");\n}\n\n\/\/ UART transmission task\nvoid uart_tx_task(void *arg) {\n    const char* test_str = \"Hi UART\\n\";\n    while(1) {\n        \/\/ Send test string\n        if(uart_write_bytes(UART_NUM, test_str, strlen(test_str)) &gt; 0) {\n            ESP_LOGI(TAG, \"Sent: %s\", test_str);\n        } else {\n            ESP_LOGE(TAG, \"Failed to send data\");\n        }\n        vTaskDelay(pdMS_TO_TICKS(2000));  \/\/ Send data every 2 seconds\n    }\n}\n\n\/\/ UART reception task\nvoid uart_rx_task(void *arg) {\n    uint8_t data[BUF_SIZE];  \/\/ Buffer to store received data\n    const char* welcome_msg = \"Hello, welcome!\\n\";\n    \n    while(1) {\n        \/\/ Read data from UART\n        int len = uart_read_bytes(UART_NUM, data, sizeof(data) - 1, pdMS_TO_TICKS(100));\n        if(len &gt; 0) {\n            data[len] = '\\0';  \/\/ Null-terminate the received string\n            ESP_LOGI(TAG, \"Received %d bytes: %s\", len, data);\n            \n            \/\/ Check if received string matches \"Hi UART\"\n            if (strncmp((char*)data, \"Hi UART\", 7) == 0) {\n                uart_write_bytes(UART_NUM, welcome_msg, strlen(welcome_msg));  \/\/ Send welcome message\n                ESP_LOGI(TAG, \"Sent welcome message\");\n            }\n        }\n        vTaskDelay(pdMS_TO_TICKS(50));  \/\/ Add delay to avoid task overload\n    }\n}\n\nvoid app_main(void)\n{\n    \/\/ Wait for the system to stabilize\n    vTaskDelay(pdMS_TO_TICKS(1000));\n    \n    \/\/ Initialize UART\n    uart_init();\n    \n    \/\/ Allow additional time for initialization to complete\n    vTaskDelay(pdMS_TO_TICKS(100));\n    \n    \/\/ Create tasks for sending and receiving\n    xTaskCreate(uart_tx_task, \"uart_tx_task\", 2048, NULL, 5, NULL);\n    xTaskCreate(uart_rx_task, \"uart_rx_task\", 2048, NULL, 5, NULL);\n    \n    ESP_LOGI(TAG, \"UART tasks created\");\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4ee3\u78bc\u89e3\u91cb\"><strong>\u4ee3\u78bc\u89e3\u91cb<\/strong><\/h2>\n\n\n\n<p>\u9019\u6bb5\u4ee3\u78bc\u914d\u7f6e\u4e86&nbsp;<strong>ESP32-PICO-KIT V4<\/strong>&nbsp;\u7684&nbsp;<strong>UART2<\/strong>\uff0c\u4f7f\u7528&nbsp;<strong>GPIO21<\/strong>&nbsp;\u4f5c\u70ba TX (\u50b3\u9001\u8173\u4f4d) \u548c&nbsp;<strong>GPIO22<\/strong>&nbsp;\u4f5c\u70ba RX (\u63a5\u6536\u8173\u4f4d)\u3002\u5be6\u73fe\u4e86\u4e00\u500b\u7c21\u55ae\u7684\u901a\u4fe1\u7cfb\u7d71\uff0c\u5177\u9ad4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>UART \u521d\u59cb\u5316 (<code>uart_init<\/code>)<\/strong>\uff1a\u914d\u7f6e\u4e86 UART \u7684\u53c3\u6578\uff0c\u5982\u6ce2\u7279\u7387\u3001\u6578\u64da\u4f4d\u3001\u505c\u6b62\u4f4d\u548c\u6d41\u63a7\u5236\uff0c\u4e26\u8a2d\u7f6e\u4e86 TX \u548c RX \u8173\u4f4d\uff08GPIO21 \u548c GPIO22\uff09\uff0c\u6700\u5f8c\u5b89\u88dd\u4e86 UART \u9a45\u52d5\u7a0b\u5f0f\u3002<\/li>\n\n\n\n<li><strong>UART \u767c\u9001\u4efb\u52d9 (<code>uart_tx_task<\/code>)<\/strong>\uff1a\u6bcf\u9694 2 \u79d2\u767c\u9001\u4e00\u6b21\u5b57\u7b26\u4e32&nbsp;<code>\"Hi UART\\n\"<\/code>\u3002\u5982\u679c\u50b3\u9001\u6210\u529f\uff0c\u6703\u8a18\u9304\u5df2\u767c\u9001\u7684\u8a0a\u606f\uff1b\u5982\u679c\u5931\u6557\uff0c\u5247\u8a18\u9304\u932f\u8aa4\u8a0a\u606f\u3002<\/li>\n\n\n\n<li><strong>UART \u63a5\u6536\u4efb\u52d9 (<code>uart_rx_task<\/code>)<\/strong>\uff1a\u6301\u7e8c\u76e3\u807d UART2 \u7684\u8f38\u5165\u8cc7\u6599\u3002\u5982\u679c\u63a5\u6536\u5230\u7684\u8a0a\u606f\u4ee5&nbsp;<code>\"Hi UART\"<\/code>&nbsp;\u958b\u982d\uff0c\u5247\u56de\u50b3&nbsp;<code>\"Hello, welcome!\\n\"<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"data-collection-and-processing\">\u8f38\u51fa\u8aaa\u660e<\/h2>\n\n\n\n<p><strong>ESP32 UART \u521d\u59cb\u5316\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6210\u529f\u521d\u59cb\u5316 UART \u5f8c\uff0c\u6703\u8a18\u9304\u76f8\u95dc\u8a0a\u606f\uff0c\u986f\u793a\u8a2d\u7f6e\u4e86 TX \u8173\u4f4d (GPIO21) \u548c RX \u8173\u4f4d (GPIO22)\u3002<\/li>\n\n\n\n<li>\u82e5\u5728\u914d\u7f6e\u904e\u7a0b\u4e2d\u767c\u751f\u932f\u8aa4\uff0c\u5247\u6703\u986f\u793a\u932f\u8aa4\u8a0a\u606f\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>ESP32 UART \u767c\u9001\u4efb\u52d9 (<code>uart_tx_task<\/code>)\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6bcf 2 \u79d2\u767c\u9001\u4e00\u6b21\u5b57\u7b26\u4e32&nbsp;<code>\"Hi UART\\n\"<\/code>\u3002\u5982\u679c\u767c\u9001\u6210\u529f\uff0c\u6703\u8a18\u9304\u767c\u9001\u7684\u8a0a\u606f\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">I (698413) uart_test: Sent: Hi UART<\/code><\/pre>\n\n\n\n<p><strong>ESP32 UART \u63a5\u6536\u4efb\u52d9 (<code>uart_rx_task<\/code>)\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6301\u7e8c\u76e3\u807d\u63a5\u6536\u5230\u7684\u8cc7\u6599\u3002\u5982\u679c\u63a5\u6536\u5230\u7684\u8a0a\u606f\u662f&nbsp;<code>\"Hi UART\"<\/code>\uff0c\u6703\u56de\u61c9&nbsp;<code>\"Hello, welcome!\\n\"<\/code>&nbsp;\u4e26\u8a18\u9304\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">I (722413) uart_test: Received 7 bytes: Hi UART\nI (726413) uart_test: Sent welcome message<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u7bc4\u4f8b\u8f38\u51fa\u65e5\u5fd7\uff1a-1\">\u7d50\u679c<strong>\u8f38\u51fa<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>GPIO \u8173\u4f4d<\/strong>\uff1aTX \u548c RX \u8173\u4f4d\u5206\u5225\u8a2d\u70ba&nbsp;<strong>GPIO21<\/strong>&nbsp;\u548c&nbsp;<strong>GPIO22<\/strong>\uff0c\u9019\u4e9b\u8173\u4f4d\u53ef\u7528\u65bc UART \u901a\u4fe1\u3002<\/li>\n\n\n\n<li><strong>\u5de5\u5177<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528 Tera Term\u3001CoolTerm \u6216 PuTTY \u7b49\u7d42\u7aef\u7a0b\u5f0f\u4f86\u8207 ESP32 \u9032\u884c\u4e32\u884c\u901a\u4fe1\uff0c\u4e26\u67e5\u770b ESP32 \u7684\u8f38\u51fa\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">I (0) uart_test: UART initialized successfully\nI (1) uart_test: Sent: Hi UART\nI (2000) uart_test: Received 7 bytes: Hi UART\nI (2001) uart_test: Sent welcome message<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">\u7d50\u8ad6<\/h2>\n\n\n\n<p>\u638c\u63e1 <a href=\"https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/latest\/esp32\/\" target=\"_blank\" rel=\"noopener\">ESP32 \u7684 UART<\/a> \u901a\u4fe1\u70ba\u60a8\u7684\u9805\u76ee\u958b\u555f\u4e86\u7121\u9650\u53ef\u80fd\u3002\u901a\u904e\u7406\u89e3\u57fa\u790e\u77e5\u8b58\u4e26\u5be6\u65bd\u672c\u6587\u63d0\u4f9b\u7684\u793a\u4f8b\uff0c\u60a8\u5c07\u80fd\u5920\u5728\u8a2d\u8a08\u4e2d\u96c6\u6210\u53ef\u9760\u4e14\u9ad8\u6548\u7684\u4e32\u884c\u901a\u4fe1\u3002\u7121\u8ad6\u662f\u7528\u65bc\u7c21\u55ae\u7684\u6578\u64da\u50b3\u8f38\u9084\u662f\u66f4\u8907\u96dc\u7684\u61c9\u7528\uff0cUART \u90fd\u662f\u5d4c\u5165\u5f0f\u7cfb\u7d71\u4e16\u754c\u4e2d\u4e00\u500b\u591a\u529f\u80fd\u4e14\u5bf6\u8cb4\u7684\u5de5\u5177\u3002<\/p>\n\n\n\n<p>ESP32 \u63d0\u4f9b\u4e86\u5f37\u5927\u7684\u786c\u9ad4\u652f\u6301\uff0c\u64c1\u6709\u591a\u500b UART \u7aef\u53e3\uff0c\u4f7f\u5176\u6210\u70ba\u9700\u8981\u4e32\u884c\u901a\u4fe1\u7684\u9805\u76ee\u7684\u7406\u60f3\u9078\u64c7\u3002\u6211\u5011\u5e0c\u671b\u9019\u7bc7\u6307\u5357\u80fd\u5e6b\u52a9\u60a8\u5feb\u901f\u5165\u9580\uff0c\u4e26\u5728\u60a8\u7684\u4e0b\u4e00\u500b ESP32 \u9805\u76ee\u4e2d\u9806\u5229\u5be6\u73fe UART \u529f\u80fd\uff01<\/p>\n\n\n\n<hr class=\"wp-block-separator alignwide has-text-color has-palette-color-1-color has-alpha-channel-opacity has-palette-color-1-background-color has-background is-style-wide\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ESP32 UART\uff08\u901a\u7528\u975e\u540c\u6b65\u6536\u767c\u5668\uff09\u5728\u9019\u500b\u5b8c\u6574\u7684\u6307\u5357\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e&nbsp;UART&nbsp;\u7684\u57fa\u790e\u77e5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3005,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,53,83],"tags":[61,27,63,20,60,10,64,11,62],"class_list":["post-2993","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-module","category-esp32","category-featured","tag-bluetooth","tag-c","tag-firmware","tag-hardware","tag-iot","tag-mcu","tag-module","tag-tutorial","tag-wifi"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/posts\/2993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/comments?post=2993"}],"version-history":[{"count":19,"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/posts\/2993\/revisions"}],"predecessor-version":[{"id":3076,"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/posts\/2993\/revisions\/3076"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/media\/3005"}],"wp:attachment":[{"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/media?parent=2993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/categories?post=2993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/saludpcb.com\/zh\/wp-json\/wp\/v2\/tags?post=2993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}