{"id":82427,"date":"2025-01-21T17:50:47","date_gmt":"2025-01-21T22:50:47","guid":{"rendered":"https:\/\/www.engineersgarage.com\/?p=82427"},"modified":"2025-01-21T17:50:47","modified_gmt":"2025-01-21T22:50:47","slug":"how-to-design-a-distance-meter-using-esp32","status":"publish","type":"post","link":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/","title":{"rendered":"How to design a distance meter using ESP32"},"content":{"rendered":"<p>The <a href=\"https:\/\/www.engineersgarage.com\/tutorials\/iot-tutorials\/\">Internet of Things<\/a> (IoT) has transformed how we interact with one another and our environment. As devices become smarter and more connected, <a href=\"https:\/\/www.engineersgarage.com\/projects-and-tutorials\/\">do-it-yourself<\/a> (DIY) projects have become increasingly popular. One such project involves developing a distance meter using the <a href=\"https:\/\/www.engineersgarage.com\/electronic-projects\/esp8266-electronic-projects\/\">ESP32<\/a>, a versatile microcontroller with built-in Wi-FI, Bluetooth connectivity, and diverse capabilities.<\/p>\n<p>This project highlights the potential of IoT technology while serving as a gateway for creators to advance their skills in smart device development.<\/p>\n<div id=\"attachment_82433\" style=\"width: 750px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-1.-the-project.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-82433\" class=\"size-large wp-image-82433\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-1.-the-project-1024x428.jpg\" alt=\"\" width=\"740\" height=\"309\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-1.-the-project-1024x428.jpg 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-1.-the-project-300x125.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-1.-the-project-768x321.jpg 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-1.-the-project-1536x642.jpg 1536w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-1.-the-project-368x154.jpg 368w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-1.-the-project.jpg 1776w\" sizes=\"auto, (max-width: 740px) 100vw, 740px\" \/><\/a><p id=\"caption-attachment-82433\" class=\"wp-caption-text\"><strong>Figure 1.<\/strong>\u00a0The prototype<\/p><\/div>\n<h3>Understanding the project<\/h3>\n<p>Before diving into the technical implementation, it\u2019s important to understand how a distance meter works. It determines the distance between itself and an object using a sensor to emit and receive signals.<\/p>\n<p>In this project, we\u2019ll use an ultrasonic sensor, which transmits high-frequency sound waves and calculates the time it takes to reflect back after hitting an object. Knowing the speed of sound allows for accurate distance measurement.<\/p>\n<p>The HC-SR04, a widely used and cost-effective ultrasonic sensor, operates by transmitting and receiving ultrasonic waves. Its measurement is based on the time it takes for the sound waves to reach an object and return to the sensor. The process works as follows:<\/p>\n<ol>\n<li><strong>Triggering:<\/strong> The ESP32 microcontroller sends a brief trigger signal to the HC-SR04 sensor.<\/li>\n<li><strong>Wave emission:<\/strong> The sensor emits an ultrasonic wave upon receiving the trigger signal.<\/li>\n<li><strong>Reflection:<\/strong> When the wave encounters an object, it reflects back toward the sensor.<\/li>\n<li><strong>Echo detection:<\/strong> The sensor detects the returning wave and generates an echo signal.<\/li>\n<li><strong>Distance calculation:<\/strong> By calculating the time interval between wave emission and echo detection and factoring in the speed of sound, the distance to the object is determined.<\/li>\n<\/ol>\n<h3>Components<\/h3>\n<p>For this project, you&#8217;ll require:<\/p>\n<ul>\n<li><strong style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">ESP32 development board<\/strong><span style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">: It&#8217;s responsible for processing data and controlling the system.<\/span><\/li>\n<\/ul>\n<div id=\"attachment_82428\" style=\"width: 663px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Development-board.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-82428\" class=\"wp-image-82428\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Development-board-1024x579.jpg\" alt=\"\" width=\"653\" height=\"369\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Development-board-1024x579.jpg 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Development-board-300x170.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Development-board-768x434.jpg 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Development-board-368x208.jpg 368w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Development-board.jpg 1072w\" sizes=\"auto, (max-width: 653px) 100vw, 653px\" \/><\/a><p id=\"caption-attachment-82428\" class=\"wp-caption-text\"><strong>Figure 2.<\/strong> ESP32 development board<\/p><\/div>\n<ul>\n<li><strong>Ultrasonic sensor (HC-SR04)<\/strong>: It measures distance by sending and receiving ultrasonic waves.<\/li>\n<\/ul>\n<div id=\"attachment_82429\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Ultrasonic-sensor.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-82429\" class=\" wp-image-82429\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Ultrasonic-sensor.jpg\" alt=\"\" width=\"600\" height=\"440\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Ultrasonic-sensor.jpg 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Ultrasonic-sensor-300x220.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Ultrasonic-sensor-768x563.jpg 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Ultrasonic-sensor-325x238.jpg 325w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-82429\" class=\"wp-caption-text\"><strong>Figure 3.<\/strong> Ultrasonic sensor<\/p><\/div>\n<ul>\n<li><strong>OLED display:<\/strong> It displays the distance measured by the sensor and controller.<\/li>\n<\/ul>\n<div id=\"attachment_82430\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-17-at-12.43.31\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-82430\" class=\" wp-image-82430\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-17-at-12.43.31\u202fPM.png\" alt=\"\" width=\"500\" height=\"489\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-17-at-12.43.31\u202fPM.png 548w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-17-at-12.43.31\u202fPM-300x293.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-17-at-12.43.31\u202fPM-243x238.png 243w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><p id=\"caption-attachment-82430\" class=\"wp-caption-text\"><strong>Figure 4.<\/strong> OLED display<\/p><\/div>\n<ul>\n<li><strong>Jumper wires<\/strong>: These wires are used for connecting various components to the breadboard.<\/li>\n<li><strong style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">Breadboard<\/strong><span style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">: It provides a platform for easy circuit prototyping.<\/span><\/li>\n<li><strong style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">USB cable<\/strong><span style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">: This cable is used for programming and powering the ESP32 board.<\/span><\/li>\n<li><strong style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">Computer\/laptop<\/strong><span style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">: Required for programming the ESP32.<\/span><\/li>\n<\/ul>\n<h3><strong>Building the circuit<\/strong><\/h3>\n<div id=\"attachment_82431\" style=\"width: 750px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-5-circuit.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-82431\" class=\"size-large wp-image-82431\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-5-circuit-1024x547.jpg\" alt=\"\" width=\"740\" height=\"395\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-5-circuit-1024x547.jpg 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-5-circuit-300x160.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-5-circuit-768x410.jpg 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-5-circuit-1536x820.jpg 1536w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-5-circuit-368x197.jpg 368w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Figure-5-circuit.jpg 1756w\" sizes=\"auto, (max-width: 740px) 100vw, 740px\" \/><\/a><p id=\"caption-attachment-82431\" class=\"wp-caption-text\"><strong>Figure 5.<\/strong> Circuit diagram<\/p><\/div>\n<p><strong>1. Connect the ultrasonic sensor to ESP32<\/strong>:<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>VCC to 5V pin on the ESP32<\/li>\n<li>GND to GND pin on the ESP32<\/li>\n<li>Trig to GPIO pin (e.g., GPIO 5)<\/li>\n<li>Echo to GPIO pin (e.g., GPIO 18)<strong>\u00a0<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>2. Connect the OLED display to ESP32<\/strong>:<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>VCC to 5V pin on the ESP32<\/li>\n<li>GND to GND pin on the ESP32<\/li>\n<li>SCK to GPIO pin (e.g., GPIO 21)<\/li>\n<li>SDA to GPIO pin (e.g., GPIO 22)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u00a0<\/strong><strong>3. Power on the ESP32<\/strong><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Connect ESP32 to your computer using the USB cable<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Coding the distance meter<\/strong><\/p>\n<p>After the circuit is completed, it&#8217;s time to program ESP32. We&#8217;ll use the Arduino IDE for this task.<\/p>\n<p>Here are the steps:<\/p>\n<p><strong>1. Install the ESP32 board package:<\/strong><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Open the Arduino IDE by navigateing to File &gt; Preferences<\/li>\n<li>In the Additional Board Manager URLs field, paste <strong>https:\/\/dl.espressif.com\/dl\/package_esp32_index.json<\/strong><\/li>\n<li>Go to Tools &gt; Board &gt; Boards Manager, search for &#8220;ESP32,&#8221; and install the package<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>2. Write the code:<\/strong><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Below is the sketch to get you started<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>3. Connect ESP32 to your computer:<\/strong><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Select the correct board and port from the Tools menu<\/li>\n<li>Click the upload button<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<style>\n.gist-data{    height:250px; \/\/ Any height    overflow: auto;<br \/>}<\/style>\n<p><script src=\"https:\/\/gist.github.com\/Ajak58a\/3ee0e73d1b6cac7a320dd789af1f47b1.js\"><\/script><\/p>\n<h3 class=\"Body\"><b><span lang=\"EN-US\">Testing and calibration<\/span><\/b><\/h3>\n<p class=\"Body\"><span lang=\"EN-US\">Once the code is uploaded successfully, open the Serial Monitor in Arduino IDE. You should see the distance measurements displayed in centimeters. To test its accuracy, simply place objects in front of the ultrasonic sensor.<\/span><\/p>\n<div id=\"attachment_82432\" style=\"width: 668px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Test-project.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-82432\" class=\" wp-image-82432\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Test-project-1024x753.jpg\" alt=\"\" width=\"658\" height=\"484\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Test-project-1024x753.jpg 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Test-project-300x220.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Test-project-768x564.jpg 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Test-project-324x238.jpg 324w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Test-project.jpg 1290w\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" \/><\/a><p id=\"caption-attachment-82432\" class=\"wp-caption-text\"><strong>Figure 6.<\/strong> Test set-up<\/p><\/div>\n<div class=\"group\/conversation-turn relative flex w-full min-w-0 flex-col agent-turn\">\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex max-w-full flex-col flex-grow\">\n<div class=\"min-h-8 text-message flex w-full flex-col items-end gap-2 whitespace-normal break-words text-start [.text-message+&amp;]:mt-5\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"8031ba04-ec83-4a9a-b73d-378c055b6bd7\" data-message-model-slug=\"gpt-4o\">\n<div class=\"flex w-full flex-col gap-1 empty:hidden first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert dark\">\n<h3>Conclusion<\/h3>\n<p>Integrating the HC-SR04 ultrasonic sensor with an ESP32 microcontroller delivers a reliable and efficient solution for distance measurement across various applications. Its versatility and ease of use make it a valuable tool in robotics, IoT projects, and automation.<\/p>\n<p>By providing accurate, real-time data, this system proves indispensable in advancing smart technologies and enhancing the functionality of modern innovations.<\/p>\n<\/div>\n<h3>Video<\/h3>\n<div style=\"width: 678px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-82427-1\" width=\"678\" height=\"848\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Distance_meter_final-1-1.mp4?_=1\" \/><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Distance_meter_final-1-1.mp4\">https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Distance_meter_final-1-1.mp4<\/a><\/video><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Internet of Things (IoT) has transformed how we interact with one another and our environment. As devices become smarter and more connected, do-it-yourself (DIY) projects have become increasingly popular. One such project involves developing a distance meter using the ESP32, a versatile microcontroller with built-in Wi-FI, Bluetooth connectivity, and diverse capabilities. This project highlights&hellip;<\/p>\n","protected":false},"author":409,"featured_media":82436,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[13,1871],"tags":[204,4497,2078,4612,4289,4339,3337,4611,660],"class_list":{"2":"type-post","18":"entry","19":"has-post-thumbnail"},"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.2 (Yoast SEO v25.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to design a distance meter using ESP32<\/title>\n<meta name=\"description\" content=\"How to build an IoT distance meter using ESP32 and an ultrasonic sensor for accurate real-time measurements.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to design a distance meter using ESP32\" \/>\n<meta property=\"og:description\" content=\"How to build an IoT distance meter using ESP32 and an ultrasonic sensor for accurate real-time measurements.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/\" \/>\n<meta property=\"og:site_name\" content=\"Engineers Garage\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/engineersgarage\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"505\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ayush Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@EngineersGarage\" \/>\n<meta name=\"twitter:site\" content=\"@EngineersGarage\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ayush Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/\"},\"author\":{\"name\":\"Ayush Jain\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/f5e457ba68d983ca6ce696db9b2304b9\"},\"headline\":\"How to design a distance meter using ESP32\",\"datePublished\":\"2025-01-21T22:50:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/\"},\"wordCount\":728,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png\",\"keywords\":[\"bluetooth\",\"circuitdesign\",\"connectivity\",\"distancemeter\",\"diy\",\"electronicproject\",\"ESP32\",\"meter\",\"video\"],\"articleSection\":[\"Electronic Projects\",\"Video\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/\",\"url\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/\",\"name\":\"How to design a distance meter using ESP32\",\"isPartOf\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png\",\"datePublished\":\"2025-01-21T22:50:47+00:00\",\"description\":\"How to build an IoT distance meter using ESP32 and an ultrasonic sensor for accurate real-time measurements.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#primaryimage\",\"url\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png\",\"contentUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png\",\"width\":800,\"height\":505},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.engineersgarage.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to design a distance meter using ESP32\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.engineersgarage.com\/#website\",\"url\":\"https:\/\/www.engineersgarage.com\/\",\"name\":\"Engineers Garage\",\"description\":\"Electronic Projects, Electrical Engineering Resources, Makers Articles and Product News\",\"publisher\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.engineersgarage.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\",\"name\":\"Engineer's Garage - WTWH Media\",\"url\":\"https:\/\/www.engineersgarage.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png\",\"contentUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png\",\"width\":372,\"height\":52,\"caption\":\"Engineer's Garage - WTWH Media\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/engineersgarage\",\"https:\/\/x.com\/EngineersGarage\",\"https:\/\/www.youtube.com\/channel\/UC0VITh11JSYk-UW7toLebUw\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/f5e457ba68d983ca6ce696db9b2304b9\",\"name\":\"Ayush Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7e29cf2f63779dd4d485ccf8638b08081e75b68b0ed80716dceaadda8a0dc40e?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7e29cf2f63779dd4d485ccf8638b08081e75b68b0ed80716dceaadda8a0dc40e?s=96&r=g\",\"caption\":\"Ayush Jain\"},\"url\":\"https:\/\/www.engineersgarage.com\/author\/ayush-jain\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to design a distance meter using ESP32","description":"How to build an IoT distance meter using ESP32 and an ultrasonic sensor for accurate real-time measurements.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/","og_locale":"en_US","og_type":"article","og_title":"How to design a distance meter using ESP32","og_description":"How to build an IoT distance meter using ESP32 and an ultrasonic sensor for accurate real-time measurements.","og_url":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/","og_site_name":"Engineers Garage","article_publisher":"https:\/\/www.facebook.com\/engineersgarage","og_image":[{"width":800,"height":505,"url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png","type":"image\/png"}],"author":"Ayush Jain","twitter_card":"summary_large_image","twitter_creator":"@EngineersGarage","twitter_site":"@EngineersGarage","twitter_misc":{"Written by":"Ayush Jain","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#article","isPartOf":{"@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/"},"author":{"name":"Ayush Jain","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/f5e457ba68d983ca6ce696db9b2304b9"},"headline":"How to design a distance meter using ESP32","datePublished":"2025-01-21T22:50:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/"},"wordCount":728,"commentCount":0,"publisher":{"@id":"https:\/\/www.engineersgarage.com\/#organization"},"image":{"@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#primaryimage"},"thumbnailUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png","keywords":["bluetooth","circuitdesign","connectivity","distancemeter","diy","electronicproject","ESP32","meter","video"],"articleSection":["Electronic Projects","Video"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/","url":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/","name":"How to design a distance meter using ESP32","isPartOf":{"@id":"https:\/\/www.engineersgarage.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#primaryimage"},"image":{"@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#primaryimage"},"thumbnailUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png","datePublished":"2025-01-21T22:50:47+00:00","description":"How to build an IoT distance meter using ESP32 and an ultrasonic sensor for accurate real-time measurements.","breadcrumb":{"@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#primaryimage","url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png","contentUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example.png","width":800,"height":505},{"@type":"BreadcrumbList","@id":"https:\/\/www.engineersgarage.com\/how-to-design-a-distance-meter-using-esp32\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.engineersgarage.com\/"},{"@type":"ListItem","position":2,"name":"How to design a distance meter using ESP32"}]},{"@type":"WebSite","@id":"https:\/\/www.engineersgarage.com\/#website","url":"https:\/\/www.engineersgarage.com\/","name":"Engineers Garage","description":"Electronic Projects, Electrical Engineering Resources, Makers Articles and Product News","publisher":{"@id":"https:\/\/www.engineersgarage.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.engineersgarage.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.engineersgarage.com\/#organization","name":"Engineer's Garage - WTWH Media","url":"https:\/\/www.engineersgarage.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png","contentUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png","width":372,"height":52,"caption":"Engineer's Garage - WTWH Media"},"image":{"@id":"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/engineersgarage","https:\/\/x.com\/EngineersGarage","https:\/\/www.youtube.com\/channel\/UC0VITh11JSYk-UW7toLebUw"]},{"@type":"Person","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/f5e457ba68d983ca6ce696db9b2304b9","name":"Ayush Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7e29cf2f63779dd4d485ccf8638b08081e75b68b0ed80716dceaadda8a0dc40e?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7e29cf2f63779dd4d485ccf8638b08081e75b68b0ed80716dceaadda8a0dc40e?s=96&r=g","caption":"Ayush Jain"},"url":"https:\/\/www.engineersgarage.com\/author\/ayush-jain\/"}]}},"featured_image_src":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example-600x400.png","featured_image_src_square":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/ROTATOR-project-example-600x505.png","author_info":{"display_name":"Ayush Jain","author_link":"https:\/\/www.engineersgarage.com\/author\/ayush-jain\/"},"_links":{"self":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts\/82427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/users\/409"}],"replies":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/comments?post=82427"}],"version-history":[{"count":0,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts\/82427\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/media\/82436"}],"wp:attachment":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/media?parent=82427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/categories?post=82427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/tags?post=82427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}