Skip to content

Commit 9a9d886

Browse files
committed
Tutorial documentation update
1 parent 851ba3f commit 9a9d886

File tree

3 files changed

+36
-33
lines changed

3 files changed

+36
-33
lines changed

content/hardware/04.pro/boards/portenta-x8/tutorials/04.python-arduino-data-exchange/content.md

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ While all peripherals are accessible from the iMX8 processor running the Linux e
2020

2121
You will be guided on how to set up this. It is recommended to familiarize yourself with the foundational elements of the Portenta X8 and its infrastructure by reading [fundamentals of the Portenta X8](https://docs.arduino.cc/tutorials/portenta-x8/x8-fundamentals) if you have not already done so.
2222

23+
***Public Docker images are available on [Docker Hub](https://hub.docker.com/u/arduino) for simplified deployment.***
24+
2325
## Goals
2426

2527
- Learn how the RPC mechanism on the X8 works
@@ -117,9 +119,14 @@ Alternatively, you could bind the name to an existing named function. The data c
117119

118120
![The iMX8 and the STM32H747 processor communicate via SPI](assets/component-placement.svg)
119121

120-
You can find the sketch and complete example [here](https://github.com/arduino/portenta-containers/tree/main/python-rpc-sensors). You may need to change the sketch depending on the sensor you choose to read from. If you are using an I<sup>2</sup>C sensor, you can connect SCL to **PWM6** and SDA to **PWM8** on the Portenta breakout.
122+
You can find the sketch and complete example available for download [here](assets/python-rpc-sensors.zip), or access the source code in the [GitHub repository](https://github.com/arduino/portenta-containers/tree/main/python-rpc-sensors).
123+
124+
The example uses preset sensor values for demonstration. If you want to connect a real sensor, you may need to modify the sketch depending on which sensor you choose. For I<sup>2</sup>C sensors like the BME680 or BME280, you can connect:
125+
126+
- **SCL** to **PWM6** (I<sup>2</sup>C SCL on M4 side)
127+
- **SDA** to **PWM8** (I<sup>2</sup>C SDA on M4 side)
121128

122-
That is because the labeled I<sup>2</sup>C pins on the Portenta Breakout are only available on the Linux side. If you are using an analog sensor, you can connect it to any analog pin. Please refer to the pinout diagram on the Portenta Breakout [documentation page](/hardware/portenta-breakout).
129+
These pins provide I<sup>2</sup>C access from the M4 core. The labeled I<sup>2</sup>C pins on the Portenta Breakout are only available on the Linux side. If you are using an analog sensor, you can connect it to any analog pin accessible by the M4. Please refer to the pinout diagram on the Portenta Breakout [documentation page](/hardware/portenta-breakout).
123130

124131
![Wiring diagram of an I2C sensor attached to the X8 via Portenta Breakout](assets/sensor-wiring-breakout.svg)
125132

@@ -131,7 +138,31 @@ Make sure you have installed the **Arduino Mbed OS Portenta Boards** core and up
131138

132139
To check if the Arduino sketch is working correctly, you may want to read the messages from the `Serial.println` statements. You cannot currently read them directly from the Arduino IDE's serial monitor. Instead, you can use the **`python-rpc-serial`** container, which listens for those messages and prints them to the console.
133140

134-
This container needs to run on the Linux side of the X8. You can get the files [here](https://github.com/arduino/portenta-containers/tree/main/python-rpc-serial). Clone or download the repository to your local machine, then from the command prompt, navigate to the adb tool folder and upload the files to the X8 with the command:
141+
You have two options to run this container. By pulling the pre-built image or building from the source.
142+
143+
Using the pre-built image is recommended process. Log into the X8 via `adb shell` and pull the pre-built image:
144+
145+
```bash
146+
docker pull arduino/python-rpc-serial
147+
```
148+
149+
Then run using the following command:
150+
151+
```bash
152+
docker run -d \
153+
--name python-rpc-serial \
154+
--restart unless-stopped \
155+
-e PYTHONUNBUFFERED=1 \
156+
--tty \
157+
--read-only \
158+
-p 5002-5020:5002-5020 \
159+
-v /tmp:/tmp \
160+
--device /dev/ttyGS0 \
161+
--add-host m4-proxy:host-gateway \
162+
arduino/python-rpc-serial:latest
163+
```
164+
165+
If you want to modify the container or learn how it is built, you can build it from source. Download the files [**here**](assets/python-rpc-serial.zip). Extract the files to your local machine, then from the command prompt, navigate to the adb tool folder and upload the files to the X8 with the command:
135166

136167
```bash
137168
adb push <local directory path>/python-rpc-serial /home/fio
@@ -151,21 +182,7 @@ docker compose up -d
151182

152183
The `-d` flag detaches the container so it runs in the background. Note that this will run the Docker Compose app and have the container built persistently across reboots by registering it as a systemd service.
153184

154-
The provided `docker-compose.yml` files are preconfigured to pull images from a specific container registry (`hub.foundries.io/${FACTORY}/python-rpc-serial:latest`). When building locally, the `${FACTORY}` environment variable may not be defined in your environment, causing `invalid reference format` errors. For local development with locally-built images, it is recommended to use `docker run` directly as shown below:
155-
156-
```bash
157-
docker run -d \
158-
--name python-rpc-serial \
159-
--restart unless-stopped \
160-
-e PYTHONUNBUFFERED=1 \
161-
--tty \
162-
--read-only \
163-
-p 5002-5020:5002-5020 \
164-
-v /tmp:/tmp \
165-
--device /dev/ttyGS0 \
166-
--add-host m4-proxy:host-gateway \
167-
python-rpc-serial:latest
168-
```
185+
The provided `docker-compose.yml` files are preconfigured to pull images from a specific container registry (`hub.foundries.io/${FACTORY}/python-rpc-serial:latest`). When building locally, the `${FACTORY}` environment variable may not be defined in your environment, causing `invalid reference format` errors. For local development with locally-built images, it is recommended to use `docker run` directly as shown above.
169186

170187
To stop the container, run:
171188

@@ -215,21 +232,7 @@ get_value = lambda value: RpcClient(rpc_address).call(value)
215232
temperature = get_value('temperature')
216233
```
217234

218-
You have two options to run the Python® application.
219-
220-
### Using the Pre-Built Docker Image
221-
222-
For a quick setup, you can use the pre-built `arduino/python-rpc-sensors` image that Arduino maintains. This way, you always have the latest compatible version. Log into the X8 via `adb shell` and then pull and run the pre-built image using the following command:
223-
224-
```bash
225-
docker run --rm --network=host arduino/python-rpc-sensors
226-
```
227-
228-
This approach is recommended for most as it is simpler and always uses the latest tested version compatible with the current OS.
229-
230-
### Building the Image From Source
231-
232-
If you want to modify the Python® script or learn how the container is built, you can build the image from source. The complete Python® application files are available in the repository [here](https://github.com/arduino/portenta-containers/tree/main/python-rpc-sensors). Clone or download the repository to your local machine, then upload the `python-rpc-sensors` folder to the Portenta X8 via:
235+
The complete Python® application files are available for download [**here**](assets/python-rpc-sensors.zip). Download and extract the files to your local machine, then upload the `python-rpc-sensors` folder to the Portenta X8 via:
233236

234237
```bash
235238
adb push <local directory path>/python-rpc-sensors /home/fio

0 commit comments

Comments
 (0)