{"id":7844,"date":"2026-04-18T21:16:27","date_gmt":"2026-04-18T21:16:27","guid":{"rendered":"https:\/\/hishamghanayem.com\/?p=7844"},"modified":"2026-07-12T21:24:04","modified_gmt":"2026-07-12T21:24:04","slug":"esp32-led-blink","status":"publish","type":"post","link":"https:\/\/hishamghanayem.com\/en\/data-analysis\/data-storytelling\/esp32-led-blink","title":{"rendered":"My First ESP32 Project: Making an LED Blink"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"7844\" class=\"elementor elementor-7844\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-50af30d2 e-flex e-con-boxed e-con e-parent\" data-id=\"50af30d2\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-046275d elementor-widget elementor-widget-image\" data-id=\"046275d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"768\" height=\"1024\" src=\"https:\/\/hishamghanayem.com\/wp-content\/uploads\/2026\/04\/ESP32-Blink-Project-1-768x1024.jpeg\" class=\"attachment-large size-large wp-image-7845\" alt=\"ESP32 LED blink project showing an ESP32-S3 board connected to an LED and resistor on a breadboard\" srcset=\"https:\/\/hishamghanayem.com\/wp-content\/uploads\/2026\/04\/ESP32-Blink-Project-1-768x1024.jpeg 768w, https:\/\/hishamghanayem.com\/wp-content\/uploads\/2026\/04\/ESP32-Blink-Project-1-225x300.jpeg 225w, https:\/\/hishamghanayem.com\/wp-content\/uploads\/2026\/04\/ESP32-Blink-Project-1-1152x1536.jpeg 1152w, https:\/\/hishamghanayem.com\/wp-content\/uploads\/2026\/04\/ESP32-Blink-Project-1-9x12.jpeg 9w, https:\/\/hishamghanayem.com\/wp-content\/uploads\/2026\/04\/ESP32-Blink-Project-1-600x800.jpeg 600w, https:\/\/hishamghanayem.com\/wp-content\/uploads\/2026\/04\/ESP32-Blink-Project-1.jpeg 1536w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-450b0869 elementor-widget elementor-widget-text-editor\" data-id=\"450b0869\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h2 style=\"font-size: 24px; font-weight: 600;\">Introduction to my ESP32 LED blink project<\/h2>\n<p>I recently started learning embedded systems and robotics using an ESP32-S3 starter kit and <a href=\"https:\/\/docs.micropython.org\/en\/latest\/esp32\/quickref.html\" target=\"_blank\" rel=\"noopener\">MicroPython<\/a>.<br \/>My first project was a classic ESP32 LED blink \u2014 making a single LED turn on and off. Although it sounds simple, it turned out to be<br \/>a valuable introduction to how hardware and software interact.<\/p>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">The Goal<\/h2>\n<p>The objective of this project was:<\/p>\n<ul>\n<li>Connect an LED to the ESP32<\/li>\n<li>Write a simple program<\/li>\n<li>Make the LED turn ON and OFF repeatedly<\/li>\n<\/ul>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">Components Used<\/h2>\n<ul>\n<li>ESP32-S3 board<\/li>\n<li>USB cable (for power and programming)<\/li>\n<li>LED<\/li>\n<li>Resistor<\/li>\n<li>Breadboard or extension board<\/li>\n<li>Jumper wires<\/li>\n<\/ul>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">Understanding the Circuit<\/h2>\n<p>To light an LED, you need a complete electrical loop:<\/p>\n<pre id=\"loop1\" style=\"background: #f6f8fa; padding: 14px; border-radius: 8px; overflow-x: auto;\"><code>GPIO \u2192 LED \u2192 Resistor \u2192 GND<\/code><\/pre>\n<ul>\n<li>GPIO provides controlled power<\/li>\n<li>The LED emits light when current flows<\/li>\n<li>The resistor limits current to prevent damage<\/li>\n<li>GND completes the circuit<\/li>\n<\/ul>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">The ESP32 LED blink code<\/h2>\n<p>Here is the MicroPython code used:<\/p>\n<pre style=\"background: #f6f8fa; padding: 14px; border-radius: 8px; overflow-x: auto;\"><code id=\"code1\" class=\"language-python\">from machine import Pin\nimport time\n\nled = Pin(4, Pin.OUT)\n\nwhile True:\n    led.value(1)\n    time.sleep(0.5)\n    led.value(0)\n    time.sleep(0.5)<\/code><\/pre>\n<p>This program continuously turns the LED ON and OFF every half second.<\/p>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">Challenges Faced<\/h2>\n<h3 style=\"font-size: 19px; font-weight: 600;\">1. Running Code in the Wrong Environment<\/h3>\n<p>Initially, I tried running the code using standard Python on my computer, which resulted in:<\/p>\n<pre style=\"background: #f6f8fa; padding: 14px; border-radius: 8px; overflow-x: auto;\"><code id=\"err1\">ModuleNotFoundError: No module named 'machine'<\/code><\/pre>\n<p>This happened because MicroPython code must run on the ESP32, not on a regular Python interpreter.<\/p>\n<h3 style=\"font-size: 19px; font-weight: 600;\">2. Confusion Between Arduino and MicroPython<\/h3>\n<p>I switched between Arduino IDE and Thonny, which caused confusion. Each uses a different programming language and workflow.<br \/>Choosing one environment and sticking with it resolved this issue.<\/p>\n<h3 style=\"font-size: 19px; font-weight: 600;\">3. Breadboard Misunderstanding<\/h3>\n<p>At first, I did not understand how breadboard connections work. The key realization was:<\/p>\n<ul>\n<li>Rows are connected horizontally<\/li>\n<li>The center gap separates the two sides<\/li>\n<\/ul>\n<p>My initial wiring did not form a complete circuit.<\/p>\n<h3 style=\"font-size: 19px; font-weight: 600;\">4. Unstable Connections<\/h3>\n<p>At one point, the LED only turned on when I manually touched wires together.<br \/>This indicated that the circuit worked, but the connections were not properly secured.<\/p>\n<h3 style=\"font-size: 19px; font-weight: 600;\">5. Invalid GPIO Pins<\/h3>\n<p>Using certain pins resulted in errors such as:<\/p>\n<pre style=\"background: #f6f8fa; padding: 14px; border-radius: 8px; overflow-x: auto;\"><code id=\"err2\">ValueError: invalid pin<\/code><\/pre>\n<p>This showed that not all GPIO pins are available or usable on every ESP32 board.<\/p>\n<h3 style=\"font-size: 19px; font-weight: 600;\">6. Physical Layout Constraints<\/h3>\n<p>The ESP32 board covered many breadboard rows, limiting access to certain pins.<br \/>I had to adjust my wiring and choose accessible GPIO pins.<\/p>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">The Breakthrough<\/h2>\n<p>The project worked when I:<\/p>\n<ul>\n<li>Used a valid GPIO pin<\/li>\n<li>Connected the LED correctly:\n<ul>\n<li>Long leg to GPIO<\/li>\n<li>Short leg to resistor and GND<\/li>\n<\/ul>\n<\/li>\n<li>Ensured all connections were firm and properly placed<\/li>\n<\/ul>\n<p>The LED finally blinked as expected, and my first ESP32 LED blink was working.<\/p>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">Key Learnings<\/h2>\n<p>This project helped me understand:<\/p>\n<ul>\n<li>How GPIO pins control hardware<\/li>\n<li>The importance of GND in completing a circuit<\/li>\n<li>How current flows in a loop<\/li>\n<li>Why resistors are necessary<\/li>\n<li>The need for alignment between software and hardware<\/li>\n<\/ul>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">Conclusion<\/h2>\n<p>Although simple, this ESP32 LED blink project provided a strong foundation in embedded systems.<br \/>It highlighted the importance of careful wiring, correct configuration, and systematic debugging. Next, I took on a bigger challenge in my <a href=\"https:\/\/hishamghanayem.com\/en\/data-analysis\/data-storytelling\/4-hours-10-leds-a-lot-of-patience\">ESP32-S3 10-LED flowing light project<\/a>.<\/p>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">Next Steps<\/h2>\n<ul>\n<li>Control the LED using a button<\/li>\n<li>Read input from sensors<\/li>\n<li>Connect the ESP32 to WiFi<\/li>\n<\/ul>\n<hr \/>\n<h2 style=\"font-size: 24px; font-weight: 600;\">Advice for Beginners<\/h2>\n<ul>\n<li>Focus on one tool at a time<\/li>\n<li>Test small parts of the system incrementally<\/li>\n<li>Expect errors and use them as learning opportunities<\/li>\n<li>Pay close attention to wiring and connections<\/li>\n<\/ul>\n<hr \/>\n<p>This project marks the beginning of my journey into embedded systems and robotics. If you are planning your own ESP32 LED blink, my biggest tip is to test each connection in small steps instead of wiring everything at once. Double-check that your chosen GPIO pin is actually usable, keep your ground and power rails clear, and read the error messages carefully \u2014 most of them point straight to the problem. A simple blinking LED may look basic, but it teaches the exact debugging habits you will rely on for every embedded project that follows.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-0516bb7 e-flex e-con-boxed e-con e-parent\" data-id=\"0516bb7\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Introduction to my ESP32 LED blink project I recently started learning embedded systems and robotics using an ESP32-S3 starter kit and MicroPython.My first project was a classic ESP32 LED blink \u2014 making a single LED turn on and off. Although it sounds simple, it turned out to bea valuable introduction to how hardware and software [&hellip;]<\/p>","protected":false},"author":1,"featured_media":7845,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"postBodyCss":"","postBodyMargin":[],"postBodyPadding":[],"postBodyBackground":{"backgroundType":"classic","gradient":""},"footnotes":""},"categories":[70,10],"tags":[],"class_list":["post-7844","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-case-study","category-data-storytelling"],"_links":{"self":[{"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/posts\/7844","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/comments?post=7844"}],"version-history":[{"count":14,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/posts\/7844\/revisions"}],"predecessor-version":[{"id":7891,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/posts\/7844\/revisions\/7891"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/media\/7845"}],"wp:attachment":[{"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/media?parent=7844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/categories?post=7844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/tags?post=7844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}