Skip to content

Commit

Permalink
fixes on review
Browse files Browse the repository at this point in the history
  • Loading branch information
karlsoderby committed Dec 18, 2024
1 parent 8caedb7 commit 66e8593
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 1 addition & 5 deletions content/micropython/01.basics/00.digital-io/digital-io.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 1 addition & 5 deletions content/micropython/01.basics/01.analog-io/analog-io.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 1 addition & 5 deletions content/micropython/01.basics/02.loops/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 1 addition & 5 deletions content/micropython/01.basics/03.data-logger/data-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 7 additions & 7 deletions content/micropython/02.environment/01.code-editor/code-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down
26 changes: 13 additions & 13 deletions content/micropython/02.environment/02.file-system/file-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion content/micropython/02.environment/04.runtime/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 4 additions & 0 deletions content/micropython/02.environment/05.repl/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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).***
```
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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).***
```

0 comments on commit 66e8593

Please sign in to comment.