Skip to content

Commit f6af638

Browse files
authored
Merge pull request #1203 from arduino/jacobhylen/number-micropython101chapters
[MKC-1061]MicroPython 101 revision
2 parents 7b05089 + 485754c commit f6af638

File tree

19 files changed

+83
-36
lines changed

19 files changed

+83
-36
lines changed

content/micropython-course/course/00.introduction-arduino/intro-to-arduino.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
featured: micropython-101
3-
title: 'Introduction to Arduino'
3+
title: '1. Introduction to Arduino'
44
description: 'Learn about the Arduino platform'
55
author: 'Karl Söderby'
66
hero_image: "./hero-banner.png"

content/micropython-course/course/01.introduction-python/02.intro-to-micropython.md

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ author: 'Karl Söderby'
33
hero_image: "./hero-banner.png"
44
micropython_type: "101"
55
featured: micropython-101
6-
title: 'Introduction to MicroPython'
6+
title: '2. Introduction to MicroPython'
77
description: 'Learn about the Arduino platform'
88
---
99

@@ -146,39 +146,67 @@ For example, to use a module for a specific sensor, we need to install it **exte
146146

147147
### Install External Modules
148148

149-
To install an external module, we are going to use something called `mip`. With `mip`, we can install a module on the board directly, by connecting to Wi-Fi and downloading the module directly to the board. So how do we do this?
149+
To install an external module, we are going to use a package manager called `mip`. With `mip`, we can install a module on the board by connecting to Wi-Fi® and downloading the module directly to the board. Installing external modules is done in two steps:
150150

151-
Below is a script that first connects to Wi-Fi®, and then downloads a specific module. In this case, we will provide a URL to a file stored on GitHub (the raw file). In this case, we will install the `lis3dh` module, which will be used later on in this course.
151+
1. Establish a Wi-Fi connection.
152152

153-
Please note that you need to add your own Wi-Fi® network and password in the `WIFI_NETWORK` and `WIFI_PASSWORD` fields.
153+
2. Download the module from a specific URL using `mip`.
154+
155+
To connect to your local Wi-Fi you can upload the following script to `boot.py` file. We choose `boot.py` because we want to make sure our board connects to the internet as soon as it boots up.
156+
157+
**Connect to Wi-Fi**
158+
159+
![Wi-Fi script inside boot.py](./assets/boot.png)
160+
161+
***Please note that you need to add your own Wi-Fi network and password in the `WIFI_NETWORK` and `WIFI_PASSWORD` fields.***
154162

155163
```python
156164
"""
157-
This script first connects to Wi-Fi,
158-
then installs the module specified
159-
in the URL variable.
165+
This script connects to Wi-Fi
160166
"""
161167

162168
import network
163-
import mip
164169

165170
WIFI_NETWORK='YOUR_NETWORK_NAME'
166171
WIFI_PASSWORD='YOUR_NETWORK_PASSWORD'
167172

168-
# add the URL of the module you want to install
169-
URL = "https://raw.githubusercontent.com/tinypico/tinypico-micropython/master/lis3dh%20library/lis3dh.py"
170-
171173
wlan = network.WLAN(network.STA_IF)
172174
wlan.active(True)
173175
wlan.connect(WIFI_NETWORK, WIFI_PASSWORD)
174176

175177
print()
176178
print("Connected to ",WIFI_NETWORK)
179+
```
180+
Press run and you should see `Connected to <your Wi-Fi>` being printed inside the REPL.
181+
182+
![Successful connection](./assets/wifiConnected.png)
183+
184+
**Install external modules**
185+
186+
Next, you need to run a script that installs the external module from a specific URL. Upload the following script to `main.py`.
177187

178-
mip.install(URL)
188+
![Module installation script inside main.py](./assets/main.png)
189+
190+
```python
191+
'''
192+
This script installs external modules using mip
193+
'''
194+
195+
import mip
196+
mip.install("https://raw.githubusercontent.com/tinypico/tinypico-micropython/master/lis3dh%20library/lis3dh.py")
179197
```
180198

181-
Once you run the script successfully, you will have installed the module on your board.
199+
Press run and you should see the following inside the REPL:
200+
201+
![Successful download](./assets/download.png)
202+
203+
In this case, we will provide a URL to a file stored on GitHub (the raw file). The script installs the `lis3dh` module, which will be used later on in this course.
204+
205+
You can verify that the module was installed correctly by pressing `Files` and checking inside the `lib` folder. You should see a file called `lis3dh.py` inside.
206+
207+
![Installed module](./assets/libFolderIn.png)
208+
209+
When asked later in the course to install external modules simply paste the provided script into `main.py` and press run.
182210

183211
### Removing Modules
184212

@@ -215,9 +243,9 @@ OSError: -202
215243

216244
Some things to check are:
217245
- Did you enter your network credentials properly?
218-
- Did you already connect to Wi-Fi®?
246+
- Did you already connect to Wi-Fi?
219247

220-
If the error persist, you can try to "soft-reset" the board, by clicking the **"Reset"** button, and run the script again.
248+
If the error persists, you can try to "soft-reset" the board, by clicking the **"Reset"** button, and run the script again.
221249

222250
![](assets/reset.png)
223251

136 KB
Loading
142 KB
Loading
103 KB
Loading
104 KB
Loading
157 KB
Loading
Binary file not shown.

content/micropython-course/course/02.installation/installation-tools.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ author: 'Jacob Hylen'
33
hero_image: "./hero-banner.png"
44
micropython_type: "101"
55
featured: micropython-101
6-
title: 'MicroPython Installation Guide'
6+
title: '3. MicroPython Installation Guide'
77
description: 'Learn how to install a code editor needed to program your board with MicroPython.'
88
---
99

@@ -33,15 +33,7 @@ First, [download the app here](https://labs.arduino.cc/en/labs/micropython). It
3333

3434
If you're on macOS, move the application to your **Applications** folder.
3535

36-
**2. Put the Board in Bootloader Mode**
37-
38-
Before we can install MicroPython, we need to place our board in a "bootloader" mode as we call it. This will make it possible to send a new firmware to it.
39-
40-
Connect your board to your computer, and connect B1 to GND with a jumper wire, tweezers, or something else metallic you have handy. Once you see a green light on the board, press the reset button on the board. If you remove the connection between B1 and GND, you should see a dim purple light if this step was successful. If not, then try again.
41-
42-
![Bootloader Mode](./assets/bootloader.png)
43-
44-
**3. Download the Firmware Installer**
36+
**2. Download the Firmware Installer**
4537

4638
The **Firmware Installer** program will help install MicroPython on your board.
4739

@@ -51,21 +43,21 @@ First [download the app here](), and extract the files to a folder on your compu
5143

5244
If you're on macOS, move the application to your **Applications** folder.
5345

54-
**4. Flash Firmware**
46+
**3. Flash Firmware**
5547

5648
Now open the Firmware Installer tool, select the Arduino Nano ESP32, and press **"Install MicroPython"**. Wait for the installer to do its magic and after some seconds, we are ready to go!
5749

5850
![Installer with Board Selected](./assets/installer.png)
5951

6052
If the installer doesn't find the MicroPython firmware automatically, you can download it manually from [here](./assets/nanoesp32_micropython.bin)
6153

62-
**5. Connect your Code Editor and Board**
54+
**4. Connect your Code Editor and Board**
6355

6456
In the Arduino Lab for MicroPython app, press **connect** in the top left corner and choose the serial port that comes up. This is your Nano ESP32.
6557

6658
![Connect to your Board](./assets/connect.png)
6759

68-
**6. Verify**
60+
**5. Verify**
6961

7062
Now, to verify things are working as they should, copy the script script below into your `main.py` file, and run it by clicking the **"Run"** button.
7163

content/micropython-course/course/03.python-cc/python-cc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
author: 'Karl Söderby'
33
hero_image: "./hero-banner.png"
44
featured: micropython-101
5-
title: 'Python Crash Course'
5+
title: '4. Python Crash Course'
66
description: 'Learn some Python fundamentals that will help you create MicroPython scripts.'
77
---
88

0 commit comments

Comments
 (0)