{"id":3848,"date":"2025-10-10T12:11:29","date_gmt":"2025-10-10T12:11:29","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=3848"},"modified":"2025-10-10T12:11:31","modified_gmt":"2025-10-10T12:11:31","slug":"stm32-uart-part-7-1-wire-protocol-receiving-data","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=3848","title":{"rendered":"STM32 UART Part 7: 1- Wire Protocol Receiving Data"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-1024x683.png\" alt=\"\" class=\"wp-image-3849\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-1024x683.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-300x200.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-768x512.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-1150x767.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-750x500.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-400x267.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-250x167.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In this part, we dive into how the\u00a0<strong>STM32 receives data from a 1-Wire sensor<\/strong>, interpreting the precise timing signals that represent logical bits. Understanding the reception phase is crucial, as it ensures accurate communication and reliable data retrieval from devices like the DS18B20 temperature sensor.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>In this guide, we shall cover the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>STM32CubeIDE setup.<\/li>\n\n\n\n<li>Hardware connection.<\/li>\n\n\n\n<li>Firmware development.<\/li>\n\n\n\n<li>Results.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">1. STM32CubeIDE Setup:<\/h2>\n\n\n\n<p>Open STM32CubeIDE after selecting the workspace and create new project as following:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"355\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-1024x355.jpg\" alt=\"\" class=\"wp-image-2940\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-1024x355.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-300x104.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-768x266.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-1536x532.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-2048x709.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-1150x398.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-750x260.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-400x139.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-26-00-250x87.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Select the MCU:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"832\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-1024x832.jpg\" alt=\"\" class=\"wp-image-2941\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-1024x832.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-300x244.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-768x624.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-1536x1248.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-2048x1664.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-1150x934.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-750x609.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-400x325.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/10\/2024-10-26_16-27-14-250x203.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Give the project a name and click on finish:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"813\" height=\"1024\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-38-59-813x1024.jpg\" alt=\"\" class=\"wp-image-3850\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-38-59-813x1024.jpg 813w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-38-59-238x300.jpg 238w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-38-59-768x968.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-38-59-750x945.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-38-59-400x504.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-38-59-250x315.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-38-59.jpg 984w\" sizes=\"(max-width: 813px) 100vw, 813px\" \/><\/figure>\n\n\n\n<p>Once the project has been created, STM32CubeMX shall appear.<\/p>\n\n\n\n<p>From connectivity, select USART1 (Or any other serial you want) and set the mode as Single-Wire (Half-duplex) as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"637\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28-1024x637.jpg\" alt=\"\" class=\"wp-image-3825\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28-1024x637.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28-300x186.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28-768x477.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28-1536x955.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28-1150x715.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28-750x466.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28-400x249.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28-250x155.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-33-28.jpg 1792w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This wil set PA9 as UART1_TX pin as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"930\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16-1024x930.jpg\" alt=\"\" class=\"wp-image-3828\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16-1024x930.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16-300x272.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16-768x697.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16-1536x1395.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16-1150x1044.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16-750x681.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16-400x363.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16-250x227.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-55-16.jpg 1764w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In the configuration, leave everything as is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1011\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-36-06-1024x1011.jpg\" alt=\"\" class=\"wp-image-3826\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-36-06-1024x1011.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-36-06-300x296.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-36-06-768x758.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-36-06-750x740.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-36-06-400x395.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-36-06-250x247.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-36-06.jpg 1088w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, from GPIO Settings, enable the Pullup resistor as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"838\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-37-48-1024x838.jpg\" alt=\"\" class=\"wp-image-3827\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-37-48-1024x838.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-37-48-300x246.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-37-48-768x629.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-37-48-1150x941.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-37-48-750x614.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-37-48-400x327.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-37-48-250x205.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-02_17-37-48.jpg 1300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, from DMA settings, add DMA stream as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Mode to Normal.<\/li>\n\n\n\n<li>Data width is byte for peripheral and memory.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"834\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-42-20-1-1024x834.jpg\" alt=\"\" class=\"wp-image-3853\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-42-20-1-1024x834.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-42-20-1-300x244.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-42-20-1-768x626.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-42-20-1-1150x937.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-42-20-1-750x611.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-42-20-1-400x326.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-42-20-1-250x204.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-42-20-1.jpg 1468w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, from NVIC, enable USART1 global interrupt as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"412\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-45-50-1024x412.jpg\" alt=\"\" class=\"wp-image-3852\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-45-50-1024x412.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-45-50-300x121.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-45-50-768x309.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-45-50-1150x462.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-45-50-750x301.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-45-50-400x161.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-45-50-250x100.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-45-50.jpg 1488w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, enable USART2 which will allow us to on board ST-Link VCOM to print the received data as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Keep the configuration as is.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"946\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33-1024x946.jpg\" alt=\"\" class=\"wp-image-3854\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33-1024x946.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33-300x277.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33-768x709.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33-1536x1419.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33-1150x1062.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33-750x693.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33-400x370.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33-250x231.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-48-33.jpg 1810w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Thats all for the configuration. Save the project and this will generate the code.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Connection:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>The connection as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Connect PA9 of sender to PA9 of the receiver.<\/li>\n\n\n\n<li>Connect GND of first MCU to the GND of the second MCU. <\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"573\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-1024x573.jpg\" alt=\"\" class=\"wp-image-3855\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-1024x573.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-300x168.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-768x430.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-1536x860.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-2048x1146.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-1150x644.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-750x420.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-400x225.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_14-52-52-250x141.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Firmware Development:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>Once the code has been generated, main.c shall be opened.<\/p>\n\n\n\n<p>In main.c, in user begin PV section, declare the following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#define BufferSize 100\n\nuint8_t uart_buffer[BufferSize];<\/pre><\/div>\n\n\n\n<p>This will be the buffer to hold the received data from UART in 1 wire mode.<\/p>\n\n\n\n<p>Next, in user code begin 2 in main function, set the UART in the reception mode as follows:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">HAL_HalfDuplex_EnableReceiver(&amp;huart1);<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, start the reception of the data using DMA and detect the end of the message using IDLE line as follows:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">HAL_UARTEx_ReceiveToIdle_DMA(&amp;huart1, uart_buffer, BufferSize);<\/pre><\/div>\n\n\n\n<p>This function will call the following function under two conditions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The UART received 100 characters.<\/li>\n\n\n\n<li>IDLE line has been detected.<\/li>\n<\/ul>\n\n\n\n<p>Once one of the conditions have been met, the following function shall be called:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)\n{\n\tif(huart-&gt;Instance==USART1)\n\t{\n\t\tHAL_UART_Transmit(&amp;huart2, uart_buffer, Size, 100);\n\t\tHAL_UARTEx_ReceiveToIdle_IT(&amp;huart1, uart_buffer, 30);\n\t}\n}<\/pre><\/div>\n\n\n\n<p>For more information about this method, please refer to this guide <a href=\"https:\/\/blog.embeddedexpert.io\/?p=3769\" data-type=\"link\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=3769\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p>For how to transmit data, please refer to this guide <a href=\"https:\/\/blog.embeddedexpert.io\/?p=3822\" data-type=\"link\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=3822\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p>Thats all for the reception. Build the project and run it.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Results:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>After following the connection, open your favourite terminal application, set the baud rate to 115200, you should get the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"707\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31-1024x707.jpg\" alt=\"\" class=\"wp-image-3856\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31-1024x707.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31-300x207.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31-768x530.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31-1536x1060.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31-1150x794.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31-750x518.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31-400x276.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31-250x173.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-10_10-03-31.jpg 1866w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We have successfully received data from another MCU using 1-wire. Next, we shall communicate with 1-wire enabled sensor.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Stay tuned.<\/p>\n\n\n\n<p>Happy coding \ud83d\ude09 <\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this part, we dive into how the\u00a0STM32 receives data from a 1-Wire sensor, interpreting the precise timing signals that represent logical bits. Understanding the reception phase is crucial, as it ensures accurate communication and reliable data retrieval from devices like the DS18B20 temperature sensor. In this guide, we shall cover the following: 1. STM32CubeIDE [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11,12],"tags":[],"class_list":["post-3848","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-peripheral-drivers","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3848"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3848"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3848\/revisions"}],"predecessor-version":[{"id":3857,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3848\/revisions\/3857"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}