diff --git a/content/micropython/00.first-steps/01.install-guide/installing-micropython.md b/content/micropython/00.first-steps/01.install-guide/installing-micropython.md index ffc5877187..8848312c00 100644 --- a/content/micropython/00.first-steps/01.install-guide/installing-micropython.md +++ b/content/micropython/00.first-steps/01.install-guide/installing-micropython.md @@ -24,14 +24,10 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o - [Portenta H7](https://store.arduino.cc/products/portenta-h7) - [Portenta H7 Lite](https://store.arduino.cc/products/portenta-h7-lite) - [Portenta H7 Lite Connected](https://store.arduino.cc/products/portenta-h7-lite-connected) -- [Opta](https://store.arduino.cc/products/opta) -- [Opta Wifi](https://store.arduino.cc/products/opta-wifi) -- [Opta RS485](https://store.arduino.cc/products/opta-rs485) - [Arduino Nano RP2040 Connect](https://store.arduino.cc/products/arduino-nano-rp2040-connect) - [Nicla Vision](https://store.arduino.cc/products/nicla-vision) - [Arduino Nano 33 BLE](https://store.arduino.cc/products/arduino-nano-33-ble) -- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-rev2) -- [Arduino Nano 33 BLE Sense](https://store.arduino.cc/products/arduino-nano-33-ble-sense) +- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/nano-33-ble-rev2) - [Arduino Nano 33 BLE Sense Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-sense-rev2) - [Arduino Nano ESP32](https://store.arduino.cc/products/arduino-nano-esp32) diff --git a/content/micropython/00.first-steps/02.first-script/first-script.md b/content/micropython/00.first-steps/02.first-script/first-script.md index 02e1feac0b..07436709c6 100644 --- a/content/micropython/00.first-steps/02.first-script/first-script.md +++ b/content/micropython/00.first-steps/02.first-script/first-script.md @@ -21,14 +21,10 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o - [Portenta H7](https://store.arduino.cc/products/portenta-h7) - [Portenta H7 Lite](https://store.arduino.cc/products/portenta-h7-lite) - [Portenta H7 Lite Connected](https://store.arduino.cc/products/portenta-h7-lite-connected) -- [Opta](https://store.arduino.cc/products/opta) -- [Opta Wifi](https://store.arduino.cc/products/opta-wifi) -- [Opta RS485](https://store.arduino.cc/products/opta-rs485) - [Arduino Nano RP2040 Connect](https://store.arduino.cc/products/arduino-nano-rp2040-connect) - [Nicla Vision](https://store.arduino.cc/products/nicla-vision) - [Arduino Nano 33 BLE](https://store.arduino.cc/products/arduino-nano-33-ble) -- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-rev2) -- [Arduino Nano 33 BLE Sense](https://store.arduino.cc/products/arduino-nano-33-ble-sense) +- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/nano-33-ble-rev2) - [Arduino Nano 33 BLE Sense Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-sense-rev2) - [Arduino Nano ESP32](https://store.arduino.cc/products/arduino-nano-esp32) diff --git a/content/micropython/01.basics/00.digital-io/digital-io.md b/content/micropython/01.basics/00.digital-io/digital-io.md index 965db85dc2..b7a241aa06 100644 --- a/content/micropython/01.basics/00.digital-io/digital-io.md +++ b/content/micropython/01.basics/00.digital-io/digital-io.md @@ -32,14 +32,10 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o - [Portenta H7](https://store.arduino.cc/products/portenta-h7) - [Portenta H7 Lite](https://store.arduino.cc/products/portenta-h7-lite) - [Portenta H7 Lite Connected](https://store.arduino.cc/products/portenta-h7-lite-connected) -- [Opta](https://store.arduino.cc/products/opta) -- [Opta Wifi](https://store.arduino.cc/products/opta-wifi) -- [Opta RS485](https://store.arduino.cc/products/opta-rs485) - [Arduino Nano RP2040 Connect](https://store.arduino.cc/products/arduino-nano-rp2040-connect) - [Nicla Vision](https://store.arduino.cc/products/nicla-vision) - [Arduino Nano 33 BLE](https://store.arduino.cc/products/arduino-nano-33-ble) -- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-rev2) -- [Arduino Nano 33 BLE Sense](https://store.arduino.cc/products/arduino-nano-33-ble-sense) +- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/nano-33-ble-rev2) - [Arduino Nano 33 BLE Sense Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-sense-rev2) - [Arduino Nano ESP32](https://store.arduino.cc/products/arduino-nano-esp32) diff --git a/content/micropython/01.basics/01.analog-io/analog-io.md b/content/micropython/01.basics/01.analog-io/analog-io.md index d733d3e060..f15090565d 100644 --- a/content/micropython/01.basics/01.analog-io/analog-io.md +++ b/content/micropython/01.basics/01.analog-io/analog-io.md @@ -25,14 +25,10 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o - [Portenta H7](https://store.arduino.cc/products/portenta-h7) - [Portenta H7 Lite](https://store.arduino.cc/products/portenta-h7-lite) - [Portenta H7 Lite Connected](https://store.arduino.cc/products/portenta-h7-lite-connected) -- [Opta](https://store.arduino.cc/products/opta) -- [Opta Wifi](https://store.arduino.cc/products/opta-wifi) -- [Opta RS485](https://store.arduino.cc/products/opta-rs485) - [Arduino Nano RP2040 Connect](https://store.arduino.cc/products/arduino-nano-rp2040-connect) - [Nicla Vision](https://store.arduino.cc/products/nicla-vision) - [Arduino Nano 33 BLE](https://store.arduino.cc/products/arduino-nano-33-ble) -- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-rev2) -- [Arduino Nano 33 BLE Sense](https://store.arduino.cc/products/arduino-nano-33-ble-sense) +- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/nano-33-ble-rev2) - [Arduino Nano 33 BLE Sense Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-sense-rev2) - [Arduino Nano ESP32](https://store.arduino.cc/products/arduino-nano-esp32) diff --git a/content/micropython/01.basics/02.loops/loops.md b/content/micropython/01.basics/02.loops/loops.md index c03751ebd8..173f24910d 100644 --- a/content/micropython/01.basics/02.loops/loops.md +++ b/content/micropython/01.basics/02.loops/loops.md @@ -22,14 +22,10 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o - [Portenta H7](https://store.arduino.cc/products/portenta-h7) - [Portenta H7 Lite](https://store.arduino.cc/products/portenta-h7-lite) - [Portenta H7 Lite Connected](https://store.arduino.cc/products/portenta-h7-lite-connected) -- [Opta](https://store.arduino.cc/products/opta) -- [Opta Wifi](https://store.arduino.cc/products/opta-wifi) -- [Opta RS485](https://store.arduino.cc/products/opta-rs485) - [Arduino Nano RP2040 Connect](https://store.arduino.cc/products/arduino-nano-rp2040-connect) - [Nicla Vision](https://store.arduino.cc/products/nicla-vision) - [Arduino Nano 33 BLE](https://store.arduino.cc/products/arduino-nano-33-ble) -- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-rev2) -- [Arduino Nano 33 BLE Sense](https://store.arduino.cc/products/arduino-nano-33-ble-sense) +- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/nano-33-ble-rev2) - [Arduino Nano 33 BLE Sense Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-sense-rev2) - [Arduino Nano ESP32](https://store.arduino.cc/products/arduino-nano-esp32) diff --git a/content/micropython/01.basics/03.data-logger/data-logger.md b/content/micropython/01.basics/03.data-logger/data-logger.md index 9702e4eeb5..2a9dae2391 100644 --- a/content/micropython/01.basics/03.data-logger/data-logger.md +++ b/content/micropython/01.basics/03.data-logger/data-logger.md @@ -24,14 +24,10 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o - [Portenta H7](https://store.arduino.cc/products/portenta-h7) - [Portenta H7 Lite](https://store.arduino.cc/products/portenta-h7-lite) - [Portenta H7 Lite Connected](https://store.arduino.cc/products/portenta-h7-lite-connected) -- [Opta](https://store.arduino.cc/products/opta) -- [Opta Wifi](https://store.arduino.cc/products/opta-wifi) -- [Opta RS485](https://store.arduino.cc/products/opta-rs485) - [Arduino Nano RP2040 Connect](https://store.arduino.cc/products/arduino-nano-rp2040-connect) - [Nicla Vision](https://store.arduino.cc/products/nicla-vision) - [Arduino Nano 33 BLE](https://store.arduino.cc/products/arduino-nano-33-ble) -- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-rev2) -- [Arduino Nano 33 BLE Sense](https://store.arduino.cc/products/arduino-nano-33-ble-sense) +- [Arduino Nano 33 BLE Rev2](https://store.arduino.cc/products/nano-33-ble-rev2) - [Arduino Nano 33 BLE Sense Rev2](https://store.arduino.cc/products/arduino-nano-33-ble-sense-rev2) - [Arduino Nano ESP32](https://store.arduino.cc/products/arduino-nano-esp32) diff --git a/content/micropython/02.environment/01.code-editor/code-editor.md b/content/micropython/02.environment/01.code-editor/code-editor.md index 7c958d8aa0..5cfe6053ea 100644 --- a/content/micropython/02.environment/01.code-editor/code-editor.md +++ b/content/micropython/02.environment/01.code-editor/code-editor.md @@ -28,11 +28,11 @@ As we get familiar with the editor, remember that MicroPython has a few syntax r The Arduino Lab for MicroPython editor provides several essential tools to make coding intuitive and efficient: -1.**Connect/Disconnect Board**: Use this button to connect or disconnect your MicroPython-compatible board. This allows the code editor to communicate with your board for running and testing code. -2.**Run/Stop Script**: Click this button to run or stop your script. The output will be displayed in the REPL, providing immediate feedback or error messages. -3.**File Management**: This option lets you manage files on your MicroPython board. You can upload, download, and organize your scripts. -4.**Edit Script**: The main area of the editor where you write and modify your MicroPython code. It provides features like syntax highlighting to enhance readability. -5.**Expand Terminal**: Use this button to expand or collapse the terminal section, which displays the REPL output, helping you debug and interact with your code in real time. +1. **Connect/Disconnect Board**: Use this button to connect or disconnect your MicroPython-compatible board. This allows the code editor to communicate with your board for running and testing code. +2. **Run/Stop Script**: Click this button to run or stop your script. The output will be displayed in the REPL, providing immediate feedback or error messages. +3. **File Management**: This option lets you manage files on your MicroPython board. You can upload, download, and organize your scripts. +4. **Edit Script**: The main area of the editor where you write and modify your MicroPython code. It provides features like syntax highlighting to enhance readability. +5. **Expand Terminal**: Use this button to expand or collapse the terminal section, which displays the REPL output, helping you debug and interact with your code in real time. ![Overview of the code editor.](assets/IDEOverview.png) @@ -51,10 +51,10 @@ Managing files in the Arduino Lab for MicroPython is straightforward and allows ### REPL -The REPL can be found by expanding the terminal. Here you can interact with the terminal. The buttons allow for basic features like copy and pasting as the shortcuts like ```CTRL+C will´´´ not work on this window. +The REPL can be found by expanding the terminal. Here you can interact with the terminal. The buttons allow for basic features like copy and pasting as the shortcuts like `CTRL+C will` not work on this window. ![The REPL.](assets/consoleTerminal.png) -***For a detailed tutorial on using the file system, please refer to the [File System Tutorial](/micropython/environment/file-system).*** +***For a detailed tutorial on using the REPL, please refer to the [REPL Tutorial](/micropython/environment/repl).*** ## Code Editor diff --git a/content/micropython/02.environment/02.file-system/file-system.md b/content/micropython/02.environment/02.file-system/file-system.md index 6fabba3fb2..f5975ff91b 100644 --- a/content/micropython/02.environment/02.file-system/file-system.md +++ b/content/micropython/02.environment/02.file-system/file-system.md @@ -52,26 +52,26 @@ To run code from a separate script in our `main.py` file, we can follow the inst 1. Create a file named `my_new_script.py`, and add the following function: -```python -def test(): - print("This runs from my_new_script.py") -``` + ```python + def test(): + print("This runs from my_new_script.py") + ``` 2. In `main.py`, we run some initial code and then switches to executing a function from `my_new_script.py`. Here's an example: -```python -import my_new_script -print("This runs from main.py") + ```python + import my_new_script + print("This runs from main.py") -my_new_script.test() -``` + my_new_script.test() + ``` 3. Check the REPL, we should see: -```bash -This runs from main.py # executed from main.py -This runs from my_new_script #executed from my_new_script -``` + ```bash + This runs from main.py # executed from main.py + This runs from my_new_script #executed from my_new_script + ``` Essentially, this is how [modules](/micropython/environment/modules) work. You import a module, and use a function from that module. diff --git a/content/micropython/02.environment/04.runtime/runtime.md b/content/micropython/02.environment/04.runtime/runtime.md index 352ac984a4..8f777f7759 100644 --- a/content/micropython/02.environment/04.runtime/runtime.md +++ b/content/micropython/02.environment/04.runtime/runtime.md @@ -32,12 +32,13 @@ MicroPython's runtime environment consists of several key components: 1. **REPL (Read-Eval-Print Loop)**: One of the standout features of MicroPython's runtime is the REPL. The REPL is an interactive shell where we can type and execute Python code line by line, get immediate feedback, and test ideas quickly. It’s especially useful for debugging and learning how the hardware responds to different commands. 2. **Boot and Main Scripts**: When the microcontroller starts up, the MicroPython runtime automatically looks for two scripts: + - **`boot.py`**: This script is executed first and is typically used for system configuration, such as setting up Wi-Fi or initializing hardware settings. - **`main.py`**: After `boot.py` runs, `main.py` is executed. This is where we typically put our main application logic. 3. **Concurrency with `uasyncio`**: MicroPython provides support for asynchronous programming using the `uasyncio` module. This allows us to handle multiple tasks concurrently, such as reading a sensor while controlling an LED, without blocking the main program. -### Micro vs Python +### MicroPython vs Python While MicroPython aims to be as compatible as possible with standard Python, there are some important differences due to the limited resources available on microcontrollers: diff --git a/content/micropython/02.environment/05.repl/repl.md b/content/micropython/02.environment/05.repl/repl.md index d6399be315..a92081357c 100644 --- a/content/micropython/02.environment/05.repl/repl.md +++ b/content/micropython/02.environment/05.repl/repl.md @@ -11,6 +11,8 @@ In this guide, we’ll go through how the REPL functions, why it’s useful, and ## What is REPL? +![REPL.](assets/replcover.png) + The REPL process involves four basic steps: - **R - ead**: Reads and accepts your code input line-by-line. @@ -46,6 +48,8 @@ When writing `name` in the REPL, (after `name = "Pedro"`), we should get: 'Pedro' ``` +![How the REPL works.](assets/replgif.gif) + ## Example: Perform a Calculation in the REPL Now let's create a REPL session that performs a calculation, by adding two numbers together: diff --git a/content/micropython/04.board-examples/nano-ble-sense/nano-ble-sense.md b/content/micropython/04.board-examples/nano-ble-sense/nano-ble-sense.md index 941eb5cf50..89a97ed334 100644 --- a/content/micropython/04.board-examples/nano-ble-sense/nano-ble-sense.md +++ b/content/micropython/04.board-examples/nano-ble-sense/nano-ble-sense.md @@ -28,10 +28,8 @@ The Nano BLE Sense has a number of board-specific features that can be accessed - **Microphone (MP34DT05)** - a microphone for recording audio samples. - **Gesture Sensor (APDS9960)** - measure ambient light and proximity. - **Pressure Sensor (LPS22)** - measure air pressure for weather applications. -- **Temperature and Humidity (HTS221 & HS3003)** - record temperature and relative humidity. -- **IMU (LSM9DS1, BMI270 + BMM150)** - read gyroscope and accelerometer data. - -***Note that there are multiple revisions of the Nano BLE Sense (Rev1 and Rev2), where different sensors are used.*** +- **Temperature and Humidity - HTS221 (Rev1), HS3003 (Rev2)** - record temperature and relative humidity. +- **IMU - LSM9DS1 (Rev1), BMI270 + BMM150 (Rev2)** - read gyroscope and accelerometer data. ## RGB LED @@ -315,8 +313,6 @@ data = uart.read() print("Received:", data) ``` -***Read more about SPI in [this article](/micropython/communication/spi).*** - ### SPI The Nano BLE Sense supports **SPI** through the following pins: @@ -334,6 +330,4 @@ from machine import Pin, SPI spi = SPI(1, baudrate=1000000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(23), miso=Pin(19)) print("SPI initialized") -``` - -***Read more about UART in [this article](/micropython/communication/uart).*** \ No newline at end of file +``` \ No newline at end of file diff --git a/content/micropython/04.board-examples/nano-esp32/nano-esp32.md b/content/micropython/04.board-examples/nano-esp32/nano-esp32.md index 5fc2c26804..35186c000c 100644 --- a/content/micropython/04.board-examples/nano-esp32/nano-esp32.md +++ b/content/micropython/04.board-examples/nano-esp32/nano-esp32.md @@ -99,8 +99,6 @@ data = uart.read() print("Received:", data) ``` -***Read more about UART in [this article](/micropython/communication/uart).*** - ### SPI SPI communication is also supported on the Nano ESP32, which is useful for high-speed data transfer with peripherals: @@ -114,8 +112,6 @@ spi = SPI(1, baudrate=1000000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(23), m print("SPI initialized") ``` -***Read more about SPI in [this article](/micropython/communication/spi).*** - ## Additional Features The Nano ESP32 includes other features that can be explored: diff --git a/content/micropython/04.board-examples/nano-rp2040-connect/nano-rp2040-connect.md b/content/micropython/04.board-examples/nano-rp2040-connect/nano-rp2040-connect.md index bcdb8a7b7c..0889954314 100644 --- a/content/micropython/04.board-examples/nano-rp2040-connect/nano-rp2040-connect.md +++ b/content/micropython/04.board-examples/nano-rp2040-connect/nano-rp2040-connect.md @@ -186,8 +186,6 @@ data = uart.read() print("Received:", data) ``` -***Read more about SPI in [this article](/micropython/communication/spi).*** - ### SPI The Nano RP2040 Connect supports **SPI** through the following pins: @@ -205,6 +203,4 @@ from machine import Pin, SPI spi = SPI(1, baudrate=1000000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(23), miso=Pin(19)) print("SPI initialized") -``` - -***Read more about UART in [this article](/micropython/communication/uart).*** \ No newline at end of file +``` \ No newline at end of file