{"id":4583,"date":"2026-07-12T05:05:07","date_gmt":"2026-07-12T05:05:07","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=4583"},"modified":"2026-07-12T05:05:09","modified_gmt":"2026-07-12T05:05:09","slug":"uart-based-sensor-emulation-part-1-introduction-and-environment-setup","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=4583","title":{"rendered":"UART Based Sensor Emulation Part 1: Introduction and Environment Setup"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"559\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/Gemini_Generated_Image_m0nfr5m0nfr5m0nf-1024x559.png\" alt=\"\" class=\"wp-image-4584\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/Gemini_Generated_Image_m0nfr5m0nfr5m0nf-1024x559.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/Gemini_Generated_Image_m0nfr5m0nfr5m0nf-300x164.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/Gemini_Generated_Image_m0nfr5m0nfr5m0nf-768x419.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/Gemini_Generated_Image_m0nfr5m0nfr5m0nf-1150x627.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/Gemini_Generated_Image_m0nfr5m0nfr5m0nf-750x409.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/Gemini_Generated_Image_m0nfr5m0nfr5m0nf-400x218.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/Gemini_Generated_Image_m0nfr5m0nfr5m0nf-250x136.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/Gemini_Generated_Image_m0nfr5m0nfr5m0nf.png 1408w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>UART-based sensor emulation on an STM32F4 provides a cost-effective and highly controlled method to validate data processing algorithms and communication protocols without requiring the actual physical sensor hardware. This approach is essential for accelerating the development lifecycle by allowing engineers to simulate various environmental conditions, edge cases, and failure modes in a repeatable, deterministic software environment.<\/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>Introduction.<\/li>\n\n\n\n<li>STM32CubeMX configuration.<\/li>\n\n\n\n<li>Hardware connection.<\/li>\n\n\n\n<li>Importing the project to STM32CubeIDE.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Introduction:<\/h2>\n\n\n\n<p>In the realm of embedded systems development, the integration of physical sensors often introduces a significant bottleneck. Developers frequently find themselves waiting for hardware arrival, troubleshooting intermittent signal noise, or struggling to create repeatable environmental conditions required to trigger specific edge-case logic. UART-based sensor emulation serves as a powerful architectural solution to these challenges, involving the use of a secondary microcontroller\u2014in this case, an STM32F4 Nucleo-64\u2014to mimic the data stream and behavioral characteristics of a target peripheral. By acting as a &#8220;software-defined sensor,&#8221; the emulator can stream pre-recorded or algorithmically generated data to a primary target device, creating a controlled, deterministic testing environment that mirrors real-world communication protocols.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Why Sensor Emulation is Necessary<\/h4>\n\n\n\n<p>Sensor emulation is necessary because it decouples software development from hardware availability and physical limitations. In complex systems, such as flight controllers or autonomous platforms, debugging sensor-fusion algorithms with raw physical data is inherently difficult because the physical world is rarely perfectly repeatable. Emulation allows engineers to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Accelerate Prototyping:<\/strong>\u00a0Development begins immediately without waiting for custom PCBs or external components.<\/li>\n\n\n\n<li><strong>Isolate Variables:<\/strong>\u00a0You can inject &#8220;perfect&#8221; data to verify code, then introduce controlled errors (e.g., CRC errors, signal drift, or packet loss) to test the robustness of your error-handling routines.<\/li>\n\n\n\n<li><strong>Safety and Cost:<\/strong>\u00a0It is safer and significantly cheaper to test how a system reacts to &#8220;critical failure&#8221; readings when the sensor is merely an emulator rather than a physical part that might break or trigger real-world machinery.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Advantages and Disadvantages of Sensor Emulation<\/h4>\n\n\n\n<p>Understanding the trade-offs is crucial for determining if this approach fits your specific development cycle.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Advantages<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Deterministic Testing:<\/strong>\u00a0Unlike physical sensors which are susceptible to ambient noise and physical interference, an emulator provides identical datasets every time the code runs. This is vital for regression testing.<\/li>\n\n\n\n<li><strong>Protocol Flexibility:<\/strong>\u00a0The emulator can be programmed to simulate various sensors on the same pins simply by changing the firmware, reducing the need to swap physical hardware modules during development.<\/li>\n\n\n\n<li><strong>Accessibility to Rare Scenarios:<\/strong>\u00a0Simulating &#8220;impossible&#8221; or rare events, such as a sensor overheating or failing during a specific transmission phase, is straightforward in software but nearly impossible to replicate reliably in the physical world.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Disadvantages<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Potential for Over-Simplification:<\/strong>\u00a0An emulator may perfectly mimic a datasheet&#8217;s output but fail to replicate the subtle physical noise characteristics or non-linearities of a real component, potentially hiding bugs that only appear in hardware.<\/li>\n\n\n\n<li><strong>Development Overhead:<\/strong>\u00a0Building an emulator requires extra firmware development time and an additional MCU, which might not be justifiable for projects with very simple, off-the-shelf sensors.<\/li>\n\n\n\n<li><strong>Timing Latency:<\/strong>\u00a0Because the data is being serialized and sent over a UART line between two MCUs, there may be small overheads or jitter that do not exist if the sensor were directly connected to the target\u2019s local bus.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. STM32CubeMX Configuration:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>Please note that Master and emulated sensor has the same configuration expect the emulated sensor will omit  USART2.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Open STM32CubeMX as start a new project as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-1024x662.jpg\" alt=\"\" class=\"wp-image-3990\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-1024x662.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-300x194.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-768x497.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-1536x993.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-2048x1324.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-1150x744.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-750x485.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-400x259.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-250x162.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Search for your STM32 MCU, select the MCU and click on Start New Project as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"724\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-1024x724.jpg\" alt=\"\" class=\"wp-image-3991\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-1024x724.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-300x212.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-768x543.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-1536x1087.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-2048x1449.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-1150x814.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-750x531.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-400x283.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-06-08-250x177.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We shall use USART1 to communicate with the emulated sensor while USART2 to be used to print to the terminal.<\/p>\n\n\n\n<p>From STM32CubeMX configuration, from communication, select USART1 and enable it in Asynchronous mode and keep the configuration as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-1024x662.png\" alt=\"\" class=\"wp-image-4585\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-1024x662.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-300x194.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-768x497.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-1536x993.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-2048x1324.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-1150x744.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-750x485.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-400x259.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-40-34-250x162.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, from DMA tab, enable DMA for USART1_RX and configure the DMA 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 to Byte.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-1024x662.png\" alt=\"\" class=\"wp-image-4586\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-1024x662.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-300x194.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-768x497.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-1536x993.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-2048x1324.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-1150x744.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-750x485.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-400x259.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-45-58-250x162.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, from NIVC settings of USART1, 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=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-1024x662.png\" alt=\"\" class=\"wp-image-4587\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-1024x662.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-300x194.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-768x497.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-1536x993.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-2048x1324.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-1150x744.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-750x485.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-400x259.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-48-37-250x162.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, we shall enable USART2 to print text to terminal (For main MCU only). <\/p>\n\n\n\n<p>From communication, select USART2 and enable it in Asynchronous mode and keep the configuration as is as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-1024x662.png\" alt=\"\" class=\"wp-image-4588\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-1024x662.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-300x194.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-768x497.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-1536x993.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-2048x1324.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-1150x744.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-750x485.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-400x259.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-50-51-250x162.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, from Project Manager tab, Code Generation, enable Generate peripheral initialization as pair .c\/.h files per peripheral as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-1024x662.png\" alt=\"\" class=\"wp-image-4589\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-1024x662.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-300x194.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-768x497.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-1536x993.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-2048x1324.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-1150x744.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-750x485.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-400x259.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-53-22-250x162.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, from Project tab, give the project a name, select toolchain\/IDE to STM32CubeIDE and click on generate code as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-1024x662.png\" alt=\"\" class=\"wp-image-4590\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-1024x662.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-300x194.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-768x497.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-1536x993.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-2048x1324.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-1150x744.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-750x485.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-400x259.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_07-55-30-250x162.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Thats all for STM32CubeMX.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Hardware Setup:<\/h2>\n\n\n\n<p>The setup as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"579\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-1024x579.png\" alt=\"\" class=\"wp-image-4591\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-1024x579.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-300x170.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-768x434.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-1536x869.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-2048x1158.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-1150x650.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-750x424.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-400x225.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/07\/2026-07-12_08-01-01-250x141.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Connect TX of USART1 of main MCU to RX of USART1 of Emulated Sensor.<\/p>\n\n\n\n<p>Connect RX of USART1 of main MCU to TX of USART1 of Emulated Sensor.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Importing the Project to SMT32CubeIDE:<\/h2>\n\n\n\n<p>pen STM32CubeIDE, select your workspace and click on Launch.<\/p>\n\n\n\n<p>From the IDE, click File and select STM32 Project Create\/Import as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"873\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-1024x873.jpg\" alt=\"\" class=\"wp-image-3997\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-1024x873.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-300x256.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-768x655.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-1150x981.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-750x640.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-400x341.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-250x213.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21.jpg 1524w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, from Import STM32 Project, select STM32CubeMX\/STM32CubeIDE Project and click on Next as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"769\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-1024x769.jpg\" alt=\"\" class=\"wp-image-3998\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-1024x769.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-300x225.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-768x577.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-1150x863.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-750x563.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-400x300.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-250x188.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37.jpg 1172w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, select the folder that contains the .ioc file and click on Finish as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"652\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41-1024x652.jpg\" alt=\"\" class=\"wp-image-4360\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41-1024x652.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41-300x191.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41-768x489.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41-1536x977.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41-1150x732.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41-750x477.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41-400x255.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41-250x159.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/04\/2026-04-11_11-31-41.jpg 1760w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Note: Project name is for reference only.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Next part we shall start communicating between both before se start the emulation part.<\/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\n\n\n<p> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>UART-based sensor emulation on an STM32F4 provides a cost-effective and highly controlled method to validate data processing algorithms and communication protocols without requiring the actual physical sensor hardware. This approach is essential for accelerating the development lifecycle by allowing engineers to simulate various environmental conditions, edge cases, and failure modes in a repeatable, deterministic software [&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-4583","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\/4583"}],"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=4583"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/4583\/revisions"}],"predecessor-version":[{"id":4592,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/4583\/revisions\/4592"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}