|
| 1 | +--- |
| 2 | +title: "MicroPython Jupyter Notebooks in the Browser with ESP32-C3-DevKit-RUST-2" |
| 3 | +date: 2025-10-17 |
| 4 | +showAuthor: false |
| 5 | +series: ["WS00M"] |
| 6 | +series_order: 1 |
| 7 | +tags: ["Workshop", "MicroPython", "Jupyter", "Browser"] |
| 8 | +authors: |
| 9 | + - "daniel-paul" |
| 10 | +showTableOfContents: false |
| 11 | +showAuthor: false |
| 12 | +summary: "In this workshop, you will learn how to program Espressif SoCs directly in your browser using MicroPython and Jupyter notebooks. We will primarily be using ESP32-C3-DevKit-RUST-2 development board. In the process, we will cover LED control, wireless communication, sensors, and MQTT." |
| 13 | +--- |
| 14 | + |
| 15 | +Welcome to the workshop on MicroPython Jupyter Notebooks in the browser! In this session, you will see how modern web technologies enable direct hardware programming without the need to install local development tools. You'll learn how to flash firmware, execute code interactively, and build IoT applications using only a browser and a USB connection. |
| 16 | + |
| 17 | +## About the workshop |
| 18 | + |
| 19 | +This workshop covers both fundamental and advanced MicroPython programming for ESP32-C3-DevKit-RUST-2 development board through hands-on assignments: |
| 20 | + |
| 21 | +<!-- no toc --> |
| 22 | + |
| 23 | +- **Setup** - Flash MicroPython firmware and understand the development environment |
| 24 | +- **Assignment 1: Blink** -- Control NeoPixel LED |
| 25 | +- **Assignment 2: Button Input** -- Read button presses and create interactive responses |
| 26 | +- **Assignment 3: ESP-NOW Communication** -- Implement wireless Morse code communication between two ESP32-C3-DevKit-RUST-2 development boards |
| 27 | +- **Assignment 4: IMU Sensor and MQTT Communication** -- Read orientation data from an IMU and publish it to MQTT broker |
| 28 | + |
| 29 | + |
| 30 | +## Prerequisites |
| 31 | + |
| 32 | +### Hardware |
| 33 | + |
| 34 | +- Computer running Windows, macOS or Linux |
| 35 | +- Chromium-based browser (Google Chrome, Microsoft Edge, Opera, Brave, Vivaldi) |
| 36 | +- ESP32-C3-DevKit-RUST-2 development board (Provided by us) |
| 37 | +- USB-C cable (data + power) compatible with the board |
| 38 | + |
| 39 | +### Software |
| 40 | + |
| 41 | +- Modern Chromium-based browser with WebSerial API support |
| 42 | +- [Mosquitto](https://mosquitto.org/download/) message broker |
| 43 | + |
| 44 | +### Effort |
| 45 | + |
| 46 | +{{< alert icon="mug-hot">}} |
| 47 | +**Estimated time: 120 min** |
| 48 | +{{< /alert >}} |
| 49 | + |
| 50 | +## Introduction |
| 51 | + |
| 52 | +As it has already been announced, this workshop will be using MicroPython and Jupyter Notebooks. Let's quickly introduce them. |
| 53 | + |
| 54 | +### MicroPython |
| 55 | + |
| 56 | +MicroPython is a lean implementation of Python 3 optimized for microcontrollers. It provides an interactive REPL (Read-Eval-Print Loop) and supports most Python standard library features, making embedded development accessible to Python programmers. |
| 57 | + |
| 58 | +### Jupyter Notebook |
| 59 | + |
| 60 | +Jupyter Notebook is a web-based interactive computing environment that allows you to create documents that contain live code, and narrative text. It is composed from a kernel, which is a program that executes the code, and a frontend, which is a user interface that allows you to interact with the kernel. |
| 61 | + |
| 62 | +The code is composed of cells, which can be executed independently or sequentially, either by clicking on the cell and pressing the run button or using a keyboard shortcut `Shift + Enter`. If the code executes a `while True` loop, it can be interrupted by clicking on the stop button in the toolbar. |
| 63 | + |
| 64 | +### Why MicroPython Jupyter Notebooks in the Browser? |
| 65 | +Traditional embedded development requires installing toolchains, IDEs, and drivers. Browser-based Jupyter notebooks eliminate this setup by leveraging the WebSerial API, which allows web applications to communicate directly with serial devices. This approach offers several advantages: |
| 66 | + |
| 67 | +- **Zero installation**: No local toolchain required |
| 68 | +- **Interactive development**: Execute code cells individually and see immediate results |
| 69 | +- **Educational value**: Clear separation of concepts into notebook cells |
| 70 | +- **Cross-platform**: Works identically on Windows, macOS, and Linux |
| 71 | +- **Version control friendly**: Notebooks can be easily shared and versioned |
| 72 | + |
| 73 | +### How It Works |
| 74 | +The browser connects to your ESP32-C3-DevKit-RUST-2 development board via USB using the WebSerial API. Jupyter notebooks send Python code to the MicroPython REPL running on the device. The device executes the code and returns output, which displays in the notebook interface. |
| 75 | + |
| 76 | +### Related documentation |
| 77 | + |
| 78 | +- [MicroPython Documentation](https://docs.micropython.org/en/latest/) |
| 79 | +- [ESP32 MicroPython Guide](https://docs.micropython.org/en/latest/esp32/quickref.html) |
| 80 | +- [ESP-NOW Protocol](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_now.html) |
| 81 | +- [ESP-NOW in MicroPython](https://docs.micropython.org/en/latest/library/espnow.html) |
| 82 | + |
| 83 | +## Workshop |
| 84 | + |
| 85 | +Without further ado, let's dive into the exciting world of ESP microcontrollers and MicroPython! Please follow along as we explore the capabilities of this powerful platform. |
| 86 | + |
| 87 | +* [Setup](setup/) |
| 88 | +* [Assignment 1 - Blink](assignment-1/) |
| 89 | +* [Assignment 2 - Button Input](assignment-2/) |
| 90 | +* [Assignment 3 - ESP-NOW Communication](assignment-3/) |
| 91 | +* [Assignment 4 - IMU Sensor and MQTT Communication](assignment-4/) |
| 92 | + |
| 93 | +## Conclusion |
| 94 | + |
| 95 | +You've learned to program ESP32-C3-DevKit-RUST-2 development board using browser-based Jupyter notebooks, covering: |
| 96 | + |
| 97 | +- MicroPython firmware flashing and interactive development |
| 98 | +- GPIO control for LEDs and button input |
| 99 | +- ESP-NOW wireless communication protocol |
| 100 | +- IMU sensor data acquisition and processing |
| 101 | +- MQTT protocol for IoT messaging |
| 102 | + |
| 103 | +These skills form the foundation for building sophisticated IoT applications. The browser-based approach eliminates toolchain complexity while maintaining full access to MicroPython's capabilities. |
| 104 | + |
| 105 | +## FAQ |
| 106 | +- I have been prompted to select a kernel in Jupyter Notebook. Which kernel should I use? |
| 107 | + - Select `Embedded Kernel`. |
| 108 | +- How do I connect my device to the Jupyter notebook? |
| 109 | + - Click on the ESP Control Panel, click `Connect` and select your device. |
| 110 | +- Which of the devices is my ESP board? |
| 111 | + - The ESP board usually appears as `USB JTAG`. |
| 112 | +- I cannot connect to a different Jupyter notebook. |
| 113 | + - Disconnect from the previous notebook and connect the new one. |
| 114 | +- The notebook isn’t running my code, what should I do |
| 115 | + - In the ESP Control Panel, click `Disconnect device`, then reopen the notebook and connect again. |
0 commit comments