Skip to content

Small QA of pro tutorials [PC-900] #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ featuredImage: 'board'

![The Nano 33 BLE](assets/hero.png)

The [Nano 33 BLE board](https://store.arduino.cc/arduino-nano-33-ble-sense) board can be programmed using the popular **Python** programming language. More specifically, it supports [OpenMV's fork of MicroPython](https://github.com/openmv/micropython), where MicroPython is an implementation of the Python language, designed to run on microcontrollers. In this article, you will find a lot of sample scripts that will work directly with your Nano 33 BLE, such as general GPIO control, reading data from the IMU module and testing Bluetooth® Low Energy connection.
The [Nano 33 BLE](https://store.arduino.cc/arduino-nano-33-ble-sense) board can be programmed using the popular **Python** programming language. More specifically, it supports [OpenMV's fork of MicroPython](https://github.com/openmv/micropython), where MicroPython is an implementation of the Python language, designed to run on microcontrollers. In this article, you will find a lot of sample scripts that will work directly with your Nano 33 BLE, such as general GPIO control, reading data from the IMU module and testing Bluetooth® Low Energy connection.

- If you want to read more about Arduino & Python, you can visit the [Python with Arduino](/learn/programming/arduino-and-python) article. Here you will find a lot of useful examples, such as how to use delays, interrupts, reading pins and more general functions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The goals of this tutorial are:
- Use QSPI or SD card storage to load the firmware downloaded using the OTA feature.

## Hardware and Software Needed
- Arduino Portenta H7 (https://store.arduino.cc/portenta-h7)
- [Arduino Portenta H7](https://store.arduino.cc/portenta-h7)
- Arduino IDE 1.8.10+ or Arduino Pro IDE 0.0.4+
- USB-C type cable (either USB-A to USB-C or USB-C to USB-C)
- Arduino IoT Cloud and Arduino_Portenta_OTA libraries
Expand Down Expand Up @@ -94,7 +94,7 @@ void loop()
}
```

This script will light up the RGB LED with 3 different colors in sequence. This code will need to be uploaded to the Arduino Portenta H7 firsthand. This is to verify the sketch compiles and is working correctly. After verifying this, in Arduino IDE, you will search for Sketch -> Export Compiled Binary.
This script will light up the RGB LED with 3 different colors in sequence. This code will need to be uploaded to the Arduino Portenta H7 firsthand. This is to verify the sketch compiles and is working correctly. After verifying this, in Arduino IDE, you will search for **Sketch > Export Compiled Binary**.

![Exporting Binary for the Sketch](assets/binary_export.png)

Expand All @@ -105,6 +105,7 @@ With the binary file created, we can now create the ota file needed to complete
You will have to have to extract the library at a preferred location to be able to use the tools. Then you will need to run on the terminal following commands in sequence to be able to create the ota file.

Copy the binary file into the library tool's folder

```cpp
// Mac/Linux
cp OTA_Usage_Portenta.ino.PORTENTA_H7_M7.bin ~/Arduino/libraries/ArduinoIoTCloud/extras/tools/
Expand All @@ -114,6 +115,7 @@ copy OTA_Usage_Portenta.ino.PORTENTA_H7_M7.bin <userPath>/Documents/Arduino/libr
```

Go inside that directory

```cpp
// Mac/Linux
cd ~/Arduino/libraries/ArduinoIoTCloud/extras/tools
Expand All @@ -123,6 +125,7 @@ cd <yourUserPath>/Documents/Arduino/libraries/ArduinoIoTCloud/extras/tools
```

Encode your binary file into `OTA_Usage_Portenta.ino.PORTENTA_H7_M7.lzss`

```cpp
// Mac/Linux
./lzss.py --encode OTA_Usage_Portenta.ino.PORTENTA_H7_M7.bin OTA_Usage_Portenta.ino.PORTENTA_H7_M7.lzss
Expand All @@ -132,6 +135,7 @@ lzss.py --encode OTA_Usage_Portenta.ino.PORTENTA_H7_M7.bin OTA_Usage_Portenta.in
```

Convert your encoded file into `.ota` format

```cpp
// Mac/Linux
./bin2ota.py [PORTENTA_H7_M7] OTA_Usage_Portenta.ino.PORTENTA_H7_M7.lzss OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota
Expand All @@ -142,7 +146,7 @@ bin2ota.py [PORTENTA_H7_M7] OTA_Usage_Portenta.ino.PORTENTA_H7_M7.lzss OTA_Usage

We are using `OTA_Usage_Portenta.ino.PORTENTA_H7_M7` as a sketch name and for facilitated identification of the file. After this you will have the `.ota` file of the sketch that we would like to use with the OTA process.

***Now you have two options to choose, use QSPI, or use an SD Card to storage your OTA file. You can use the left side index to jump to the option that you may need***
***Now you have two options to choose, use QSPI, or use an SD Card to storage your OTA file. You can use the left side index to jump to the option that you may need.***

### QSPI Storage Mode

Expand All @@ -152,9 +156,9 @@ To use internal **QSPI** storage for downloading the binary file via OTA (Over-T
![Arduino Portenta H7 Board Connection](assets/portenta_h7_board_selection.png)

#### Writing the Script
To proceed with a OTA using the QSPI flash, you can open the sketch from **Examples ->Arduino_Portenta_OTA -> OTA_Qspi_Flash**.
To proceed with a OTA using the QSPI flash, you can open the sketch from **Examples >Arduino_Portenta_OTA > OTA_Qspi_Flash**.

***Do not forget to fill your Wi-Fi AP SSID, and password on the `arduino_secrets.h` tab***
***Do not forget to fill your Wi-Fi AP SSID, and password on the `arduino_secrets.h` tab.***

This sketch will connect to your Wi-Fi, check if the OTA feature is available by checking the installed firmware on your Portenta.

Expand All @@ -170,10 +174,9 @@ To use the **SD card** as the preferred OTA (Over-The-Air) storage device, we wi
With this, you will need the Arduino Portenta H7 board connected to the computer with the Arduino IDE. You will need to have selected the **Arduino Portenta H7 (M7 Core)** with the Flash split of **1MB M7 + 1MB M4** for the purpose of this tutorial and the corresponding port.

#### Writing the Script
As same as QSPI storage mode, to proceed with a OTA using the SD Card, you can open the sketch from **Examples > Arduino_Portenta_OTA > OTA_SD_Portenta**.

As same as QSPI storage mode, to proceed with a OTA using the SD Card, you can open the sketch from **Examples ->Arduino_Portenta_OTA -> OTA_SD_Portenta**.

***Do not forget to fill your Wi-Fi AP SSID, and password on the `arduino_secrets.h` tab***
***Do not forget to fill your Wi-Fi AP SSID, and password on the `arduino_secrets.h` tab.***

This sketch will connect to your Wi-Fi, check if the OTA feature is available by checking the installed firmware on your Portenta.

Expand Down Expand Up @@ -394,7 +397,8 @@ void loop()
}
```

## Troubleshooting
## Troubleshooting
For troubleshooting the issues that might have arose following the tutorial, you can use following tips to solve the issue.

- If it logs there has been an issue with Wi-Fi module, means the device may have suffered from losing the Wi-Fi firmware partition. To solve this, you will have to use **PortentaWiFiFirmwareupdater** sketch found on Arduino IDE examples to fix the issue.
- QSPI storage may throw error -3 while running Portenta H7 OTA QSPI example. To fix this you can use this guide of [Reading and Writing Flash Memory](https://docs.arduino.cc/tutorials/portenta-h7/por-ard-flash/) in the section **Programming the QSPI Flash**. After this, run the example and it should have been solved by eliminating error -3 (OTA Storage initialization error).
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@ software:
Portenta H7 comes with an on-board Wi-Fi and a Bluetooth® Module that allows to develop IoT applications that require wireless connectivity and Internet access. Turning the board into an access point allows it to create a Wi-Fi network on its own and allows other devices to connect to it. In this tutorial you will learn to set up your board as an access point web server and remotely control the red, green and blue LEDs on the built-in RGB LED by accessing an HTML page on your mobile device’s browser.

## Goals

- About the built-in Wi-Fi + Bluetooth® module.
- How a client-server model works
- How to create an HTTP communication channel between the board and an external device.

### Required Hardware and Software
- Portenta H7 (ABX00042) or Portenta H7 Lite Connected (ABX00046) board (<https://store.arduino.cc/portenta-h7>)
- One USB C cable (either USB A to USB C or USB C to USB C)
- Arduino IDE 1.8.10+ or Arduino Pro IDE 0.0.4 +
- A smart phone

- [Portenta H7 (ABX00042)](https://store.arduino.cc/portenta-h7) or [Portenta H7 Lite Connected (ABX00046)](https://store.arduino.cc/products/portenta-h7-lite-connected)
- One USB C cable (either USB A to USB C or USB C to USB C)
- Arduino IDE 1.8.10+ or Arduino Pro IDE 0.0.4 +
- A smart phone

## Access Point Configuration
The Portenta H7 features a [Murata 1DX](https://wireless.murata.com/type-1dx.html), which is a high performance chipset which supports Wi-Fi 802.11b/g/n + Bluetooth® 5.1 BR/EDR/LE up to 65Mbps PHY data rate on Wi-Fi and 3Mbps PHY data rate on Bluetooth®. This module helps to configure the Portenta into three different modes of operation - an Access Point, a Station, or both. In this tutorial we will only focus on the access point configuration.
The Portenta H7 features a [Murata 1DX](https://wireless.murata.com/type-1dx.html), which is a high performance chipset which supports Wi-Fi 802.11b/g/n + Bluetooth® 5.1 BR/EDR/LE up to 65Mbps PHY data rate on Wi-Fi and 3Mbps PHY data rate on Bluetooth®. This module helps to configure the Portenta into three different modes of operation - an Access Point, a Station, or both. In this tutorial we will only focus on the access point configuration.

When the board is configured to operate as an access point, it can create its own wireless LAN ( WLAN ) network. In this mode, the board transmits and receives signals at 2.4 GHz allowing other electronic devices with Wi-Fi capabilities using the same bandwidth to connect to the board.
When the board is configured to operate as an access point, it can create its own wireless LAN (WLAN) network. In this mode, the board transmits and receives signals at 2.4 GHz allowing other electronic devices with Wi-Fi capabilities using the same bandwidth to connect to the board.

With the access point set up you create a client server architecture where the board provides a web server communicating with the client devices over HTTP. The connected devices can then make HTTP GET requests to the server to retrieve web pages served by the web server on the board. This makes the Portenta H7 an ideal board for developing IoT solutions where external client devices can send and receive information while more complex processing tasks take place on the server.

Expand All @@ -46,7 +48,7 @@ With the access point set up you create a client server architecture where the b
## Instructions

### Setting Up the Web Server
In this tutorial you are going to convert the board into an access point and use it to set up a web server which provides a HTML webpage. This page contains buttons to toggle the red, green and blue colour of the built-in LED. You will then connect your mobile device to this access point and access this web page through the browser on your mobile phone. Once retrieved, you will be able to control the state of the red, green and blue LED on the built-in RGB LED from your mobile device.
In this tutorial you are going to convert the board into an access point and use it to set up a web server which provides a HTML webpage. This page contains buttons to toggle the red, green and blue color of the built-in LED. You will then connect your mobile device to this access point and access this web page through the browser on your mobile phone. Once retrieved, you will be able to control the state of the red, green and blue LED on the built-in RGB LED from your mobile device.

![A mobile device controlling the different LEDs on the board ](assets/por_ard_ap_tutorial_overview.svg)

Expand All @@ -58,7 +60,7 @@ Begin by plugging in your Portenta board to your computer using a USB-C cable an
### 2. Create the Web Server Sketch
Next we need to create a web server sketch that will handle the HTTP GET requests and provide the client devices with the HTML web page. The [Wi-Fi](https://www.arduino.cc/en/Reference/WiFi) library provides all necessary methods that allows Arduino boards to use their Wi-Fi features provided by the on-board Wi-Fi module. To set up the web server copy the following code, paste it into a new sketch file and name it **SimpleWebServer.ino**.

**Note:** You can access the final sketch inside the library: **Examples -> Arduino_Pro_Tutorials -> Portenta H7 as a Wi-Fi Access Point -> SimpleWebServer**
**Note:** You can access the final sketch inside the library: **Examples > Arduino_Pro_Tutorials > Portenta H7 as a Wi-Fi Access Point > SimpleWebServer**

```cpp
#include <WiFi.h>
Expand Down Expand Up @@ -255,7 +257,7 @@ Once you’ve created the new tab, you will see an empty page in the IDE. Define
# define SECRET_PASS "123Qwerty"
```

***The SSID (PortentaAccessPoint) and password (123Qwerty) are placeholder strings made for this tutorial. For security reasons you should rename them to something memorisable but not easy to guess. Keep in mind that the password must be at least 8 characters long.***
***The SSID (PortentaAccessPoint) and password (123Qwerty) are placeholder strings made for this tutorial. For security reasons you should rename them to something memorable but not easy to guess. Keep in mind that the password must be at least 8 characters long.***

In order to access the `SECRET_SSID` and `SECRET_PASS` constants in the **simpleWebServer.ino** sketch file, the header file that you’ve just created needs to be included. In your sketch file this has already been taken care of by the following line at the beginning of the sketch:

Expand Down
Loading