Skip to content

Commit 0c03f9c

Browse files
committed
Article content update
1 parent 1ee18da commit 0c03f9c

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

content/hardware/04.pro/boards/portenta-x8/tutorials/multi-protocol-gateway/content.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ hardware:
2020

2121
Portenta X8 has the NXP® i.MX 8M Mini MPU (Linux) and STM32H747XI dual Cortex®-M7+M4 32bit low power ARM® MCU (Arduino) stacked together and can be used to design different work loads for these two different microprocessors. We will use the Portenta Max Carrier to lend its onboard the CMWX1ZZABZ-078 LoRaWAN® module from Murata®, and WiFi connectivity from Portenta X8 to build a Multi-Protocol Gateway.
2222

23-
In this tutorial we will go through the steps of how to setup both Linux and Arduino side. A device collecting sensor data will transfer the data via WiFi Connectivity, receive the data and exchange between Arduino and Linux layers to use the LoRaWAN to finally send the information to The Things Network.
23+
In this tutorial we will go through the steps on how to setup both Linux and Arduino side. A device collecting sensor data will transfer the data via WiFi Connectivity, receive the data and exchange between Arduino and Linux layers to use the LoRaWAN to finally send the information to The Things Network. We will also configure and expose local communication lane to further expand its capability if a local sensor is desired.
2424

2525
## Goals
2626

27-
- Establish Sensor readings from Arduino part on Portenta X8.
28-
- Obtain data from sensor using WiFi connection from Arduino part on Portenta X8.
29-
- Establish LoRa connection to send sensor data to The Things Network from Linux part on Portenta X8.
27+
- Build a Arduino layer script using RPC to handle bi-directional sensor readings or data traffic on Portenta X8.
28+
- Build a multi-protocol script to manage WiFi and LoRa connectivity to handle data traffic on Linux layer of Portenta X8.
29+
- Assemble both layer scripts to build an operational multi-protocol gateway using Portenta X8 and Max Carrier.
3030

3131
### Required Hardware and Software
3232

@@ -66,9 +66,13 @@ The Arduino layer is extended within the M4 Core and the layer to go on developm
6666

6767
***To learn about how to exchange data using RPC between Arduino and Linux layer, please read ["Data Exchange Between Python on Linux and an Arduino Sketch"](https://docs.arduino.cc/tutorials/portenta-x8/python-arduino-data-exchange)***
6868

69-
In this tutorial, you will learn how to involve the RPC to expose the data received at the Linux layer on Arduino layer if further development requirement requires to feed the data at devices interfaced communicating with M4 core. We will leave the tasks running and open to be interfaced for expanding the capability of the Portenta X8 and Max Carrier.
69+
In this tutorial, you will learn how to use the RPC to expose the data received at the Linux layer on Arduino layer if further development requirement requires to feed the data at devices interfaced communicating with M4 core. We will leave the tasks running and open to be interfaced for expanding the capability of the Portenta X8 and Max Carrier.
7070

71-
To showcase the ability of the Arduino layer extended by M4 Core, we will explore two scenarios as example. One scenario is where the Arduino layer will be the terminal to expose the received sensor data to a local end-device to be controlled. While other scenario has a local end-device that transfers data to Linux layer for further networking process, hence the multi-protocol architecture will help to handle the data for transmitting in a desired protocol.
71+
To showcase the ability of the Arduino layer extended by M4 Core, we will explore two scenarios as example:
72+
1. A scenario where the Arduino layer will be the terminal to expose the received sensor data to a local end-device to be controlled.
73+
2. While other scenario has a local end-device that transfers data to Linux layer for further networking process.
74+
75+
Hence the multi-protocol architecture will process and manage the data traffic in desired protocol with given case.
7276

7377
## Linux Layer
7478

@@ -92,6 +96,8 @@ First things first, we will need to configure the hardware to be able to develop
9296

9397
## Pre-Requisites
9498

99+
### For Portenta X8
100+
95101
Before we begin diving deep into creating Multi-protocol gateway, and having understood we will frequently communicate between Arduino and Linux layer, we will have to know how to debug and observe the way these 2 layers interact.
96102

97103
The `m4-proxy` is a service that manages data exchange between these layers. You can use the following command in the terminal to observe if the service is running correctly.
@@ -123,11 +129,31 @@ To access the logs of `py-serialrpc` service, while maintaining at same director
123129
sudo docker-compose logs -f --tail 20
124130
```
125131

132+
You will be able to in the terminal as following image.
133+
134+
![py-serialrpc Terminal Log](assets/serialrpc.png)
135+
126136
***For more detail about how data exchange between Arduino and Linux layer works and to understand how to debug, please read [Data Exchange Between Python on Linux and an Arduino Sketch](https://docs.arduino.cc/tutorials/portenta-x8/python-arduino-data-exchange)***
127137

128-
Let us now dive into develop a multi-protocol gateway using Portenta X8 and Max Carrier!
138+
In case you have not configured internal WiFi connectivity within the system, please use following command line.
139+
140+
```
141+
nmcli device wifi connect "SSID" password "PASSWORD"
142+
```
143+
144+
### For The Things Network
129145

130-
## Coding Multi-Protocol Gateway
146+
We have the pre-requisites for the Portenta X8 ready, but as we are using the LoRa connectivity, we will need a platform that has the capability to receive data transmitted from the Portenta X8 and Max Carrier. **The Things Network** will be the platform we are going to use communicate using LoRaWAN. In the platform, we will need to create an application to add the Portenta Max Carrier as an End-Device.
147+
148+
When adding the End-Device, at the moment we will have to use the **Manual** option. The Portenta Max Carrier will be added under Arduino SA in near future update to be included in the LoRaWAN Device Repository. The LoRaWAN version and parameters compatible with the Portenta MAx Carrier are as follows. The frequency plan will depend on the region you are going install the device.
149+
150+
![General End-Device Configuration](assets/ttn-end-device.png)
151+
152+
***To learn more about LoRa and LoRaWAN, please have a look at our [Arduino Guide to LoRa® and LoRaWAN®](https://docs.arduino.cc/learn/communication/lorawan-101). Additionally, if you wish to learn on how to properly setup the End-Device in The Things Network, please read [this tutorial](https://docs.arduino.cc/tutorials/mkr-wan-1310/the-things-network) reference***
153+
154+
Let us now dive into developing a multi-protocol gateway using Portenta X8 and Max Carrier!
155+
156+
## Building Multi-Protocol Gateway
131157

132158
Everything sounds beautiful, but now it is important to land all the requirements into a operational task that will orchestrate every protocols we are going to use. We will create the following files and the required codes for multi-protocol gateway.
133159

@@ -163,7 +189,7 @@ paho-mqtt
163189
...
164190
```
165191

166-
### Multi-Protocol
192+
### Multi-Protocol Script
167193

168194
This is the main Python script that will handle overall networking process. We will highlight important fragments of the code to help you understand how these codes pieces together to build a gateway based on multiple protocol.
169195

@@ -217,6 +243,7 @@ With these parameters configured, we have secured the connection between The Thi
217243

218244
```
219245
# WiFi - MQTT protocol handler
246+
-> WIP
220247
```
221248

222249
This will help to receive sensor data from any external device, for example using Arduino MKR WiFi 1010 with a sensor attached, using MQTT protocol. This capability will help to increase the scalability of the multi-protocol gateway. For this to work, we will also need sketch for Arduino layer that will help us expose and retrieve the data in between Arduino and Linux layer.
@@ -225,15 +252,14 @@ This will help to receive sensor data from any external device, for example usin
225252
# Arduino side sketch
226253
#include <RPC.h>
227254
#include <SerialRPC.h>
255+
-> WIP
228256
```
229257

230258
The sketch above will help to expose and transfer the data that is processed within the Linux side. By exposing, it means you will bring forth the data received within the Linux side to the Arduino side to feed the loca-device as a control input. It can be used to display the data if you wish to for instance. Transferring data to Linux side can be seen as a direct communication, as the sensor connected and monitored via Arduino side will send this data to send over LoRa connectivity. The sketch will have both options open to assist you on further extending the possibilities within.
231259

232-
<WIP - Arduino Code & additional Python script>
233-
234-
## Mounting the Multi-Protocol Gateway Container
260+
## Mounting the Multi-Protocol Gateway
235261

236-
It is now time make the multi-protocol gateway run, we will need to build the Docker container that will help us operate in the background on the Linux layer. Using the terminal, we will use the following commands to get the multi-protocol gatewya container up and running.
262+
It is now time to make the multi-protocol gateway run, we will need to build the Docker container that will help us operate in the background on the Linux layer. Using the terminal, we will use the following commands to get the multi-protocol gatewya container up and running.
237263

238264
You will need to have the files ready in a folder inside the `adb` directory within Arduino root.
239265

@@ -255,6 +281,10 @@ cd ../home/fio/multi-protocol-gateway
255281
#multi-protocol-gateway sudo docker build . -t multi-protocol-gateway
256282
```
257283

284+
You will be able to see following results when it successfully built the image.
285+
286+
![Docker Build Terminal Log](assets/docker-build.png)
287+
258288
***If you have created the Docker container previously and want to re-create with new changes made outside the shell, please check that the container and its build directory is stopped and removed. This is for the convenience of having clean working environment***
259289

260290
After a successful container build, we will have make the image run. To do that, we will use the following command. This command will immediately output in your terminal how the Python script is running. If you know or wish to have it run on the background, please add `-d` flag at the end of the command.
@@ -276,11 +306,12 @@ docker ps -a
276306
docker images
277307
```
278308

279-
<WIP>
309+
With all this, you have built and a running multi-protocol gateway based on Portenta X8 and Max Carrier.
280310

281311
## Conclusion
282312

283-
In this tutorial you learned how to set up a Multi-Protocol Gateway composed of WiFi connectivity and LoRaWAN, by using the Portenta X8 and the Portenta Max Carrier.
313+
In this tutorial you learned how to set up a Multi-Protocol Gateway composed of WiFi connectivity and LoRaWAN, by using the Portenta X8 and the Portenta Max Carrier. You have built the gateway in which it will connect the The Things Network to send the desired data. Also, the gateway is capable of exchanging data between Arduino and Linux layer using RPC, in which you have exposed the ports to be able to control a locally attached device or receive data from the local sensor to be sent directly to The Things Network.
284314

285315
### Next Steps
286-
- Now that you have established a multi-protocol gateway, using WiFi and LoRaWAN connectivity, expand the gateway's capability by adding other connectivity types or ground a proper gateway with extended functionalities for data processing.
316+
- Now that you have established a multi-protocol gateway, using WiFi and LoRaWAN connectivity, expand the gateway's capability by adding other connectivity types such as Cat-M1 and NB-IoT
317+
- Expand functionalities for data processing using RPC while using multi-protocol architecture.

0 commit comments

Comments
 (0)