diff --git a/content/hardware/04.pro/boards/portenta-h7/tutorials/secure-boot/secure-boot.md b/content/hardware/04.pro/boards/portenta-h7/tutorials/secure-boot/secure-boot.md index 005f646a79..ebd35d51b8 100644 --- a/content/hardware/04.pro/boards/portenta-h7/tutorials/secure-boot/secure-boot.md +++ b/content/hardware/04.pro/boards/portenta-h7/tutorials/secure-boot/secure-boot.md @@ -47,7 +47,8 @@ This can be done with **imgtool**. You can download and install it directly from ***`imgtool` is already installed by the mbed platform and can be found in the `%LOCALAPPDATA%\Arduino15\packages\arduino\tools\imgtool` directory on Windows, in `~/.arduino15/packages/arduino/tools/imgtool` on Linux and in `~/Library/Arduino15/packages/arduino/tools/imgtool` on macOS.*** To generate the new keys you can use this command line: -``` + +```bash imgtool keygen --key my-sign-keyfile.pem -t ecdsa-p256 imgtool keygen --key my-encrypt-keyfile.pem -t ecdsa-p256 ``` @@ -57,7 +58,8 @@ Remember to **save the keys and keep them in a secure location** and not to lose ### 2. Upload the Custom Keys to the Board Once the keys have been generated, they have to be uploaded to the Portenta H7. This procedure has to be done only once, because it is persistent. To extract the public\private key and encode it in to a "C" byte array inside a `.h` header file you can use: -``` + +```bash imgtool getpriv -k my-encrypt-keyfile.pem > ecsda-p256-encrypt-priv-key.h imgtool getpub -k my-sign-keyfile.pem > ecsda-p256-signing-pub-key.h ``` @@ -71,7 +73,8 @@ To do so, just save the sketch to another location and replace the `ecsda-p256-e Since the default keys have been changed in favour of custom generated ones, the new ones have to be used when compiling and uploading a sketch, because the compiled sketch is signed and encrypted using such keys. To override the security keys used during the compile, you have to use the Arduino CLI and specify the keys with: -``` + +```bash arduino-cli compile -b arduino:mbed_portenta:envie_m7 --board-options security=sien --keys-keychain --sign-key ecdsa-p256-signing-priv-key.pem --encrypt-key ecdsa-p256-encrypt-pub-key.pem /home/user/Arduino/MySketch ``` diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/03.uploading-sketches-m4/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/03.uploading-sketches-m4/content.md index d8175e04a5..ec5f5c4f65 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/03.uploading-sketches-m4/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/03.uploading-sketches-m4/content.md @@ -66,7 +66,7 @@ To upload the firmware, you can use the ADB tool that has been installed as part From that directory, you can use the `adb` tool. To upload your compiled sketch, you will need to use the following command: -``` +```bash adb push /tmp/arduino/m4-user-sketch.elf ``` diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/04.python-arduino-data-exchange/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/04.python-arduino-data-exchange/content.md index 3d3f6ca366..bbcf9b798e 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/04.python-arduino-data-exchange/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/04.python-arduino-data-exchange/content.md @@ -99,7 +99,7 @@ temperature = rpc_client.call('temperature') The complete Python® application files are in the same package as the Arduino sketch (see above). Like in the previous step, upload the `python-sensor-rpc` folder to the X8 via `adb push /python-sensor-rpc /home/fio`. Log into the X8 via `adb shell`. Then navigate into the `python-sensor-rpc` folder and execute `sudo docker build . -t python-sensor-rpc`. When it is finished, you can run the container with `sudo docker-compose up`. After a few seconds, you should see the output from the Python application featuring the sensor readings on the M4 that exchanges through the RPC mechanism. The output should look similar to the following: -``` +```bash python-sensor-rpc_1 | ============================================ python-sensor-rpc_1 | == Portenta X8 Sensor reading == python-sensor-rpc_1 | ============================================ @@ -116,7 +116,9 @@ Whenever you change anything in the Python® script on your computer, you will h ```bash # On your computer adb push python-sensor-rpc /home/fio +``` +```bash # On X8 sudo docker-compose down sudo docker build . -t python-sensor-rpc diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/05.docker-container/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/05.docker-container/content.md index 0a51c339f9..2d840c52db 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/05.docker-container/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/05.docker-container/content.md @@ -43,7 +43,7 @@ In this tutorial, we will go through the steps of how to install, run and remove The Portenta X8 provides Docker CLI by default. The following command will help you verify if it is installed correctly: -``` +```bash docker -v ``` @@ -63,7 +63,7 @@ First, you will need to search for ["Hello World" container image](https://hub.d The following command must be used to pull the `hello-world` image. The Docker hub page for images has the instructions to pull the image and deploy the container. -``` +```bash docker pull hello-world ``` @@ -73,7 +73,7 @@ docker pull hello-world This is the command to begin the container instance. -``` +```bash docker run hello-world ``` @@ -85,7 +85,7 @@ docker run hello-world The following command will display the active containers and will show the `hello-world` container if it was able to run successfully. The `STATUS` message will let you know if the container is active or has finished operation depending on its purpose. -``` +```bash docker ps -a ``` @@ -93,7 +93,7 @@ docker ps -a The list of available images, including installed `hello-world` image, can be verified using the following command: -``` +```bash docker images ``` @@ -103,7 +103,7 @@ docker images You will need to obtain an assigned `CONTAINER ID` to be able to remove a container of your choice. The list of active containers provides this information. The remove (`rm`) command is then used with the desired container identifier to proceed with the removal process. -``` +```bash docker container rm ``` @@ -111,7 +111,7 @@ For this example, the command `docker ps -a` will show the `CONTAINER ID` of the Granted that this is the case, you will need to stop the container and verify with `STATUS` message that it has exited successfully. To do this, the following command is used: -``` +```bash docker stop ``` @@ -123,7 +123,7 @@ Using the `docker ps -a` after container removal, the `hello-world` container sh The same goes for the images if you would like to free some space. The removal command will now be as follows using `IMAGE ID` found within the image table: -``` +```bash docker rmi ``` diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/06.waves-fleet-managment/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/06.waves-fleet-managment/content.md index cc1a021a16..adf4fe68d1 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/06.waves-fleet-managment/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/06.waves-fleet-managment/content.md @@ -46,19 +46,19 @@ For security purposes, we recommend that you rotate your FoundriesFactory keys. First, we will rotate the root keys. These are the most important keys, as they are used to create new target keys. Rotate them with the command: -``` +```bash fioctl keys rotate-root --initial /absolute/path/to/root.keys.tgz ``` Now we can rotate the target-only keys with following command: -``` +```bash fioctl keys rotate-targets /absolute/path/to/root.keys.tgz ``` And finally, for security reasons, we separating the target keys from the root using the following command: -``` +```bash fioctl keys copy-targets /absolute/path/to/root.keys.tgz /path/to/target.only.key.tgz ``` @@ -68,13 +68,13 @@ Now we can move on to creating our Wave. Before a Factory can start making production OTAs, an initial production Targets file must be created. For more information, please check out [here](https://docs.foundries.io/latest/reference-manual/ota/production-targets.html). We can begin by creating a dummy wave with the command: -``` +```bash fioctl wave init -k /absolute/path/to/targets.only.key.tgz populate-targets ``` Then complete the Wave with: -``` +```bash fioctl wave complete populate-targets ``` @@ -84,19 +84,19 @@ This creates a new `targets.json` file for production devices, subscribing to th Now we can start creating our Wave. The command below will create a Wave that is pushable to our devices. To create a Wave, we will sign it with a key, and here we will use the targets-only key. Then we give the Wave a name, target number, and tag. The `target number` needs to correspond to the target that we want the Wave to contain for our devices. The `tag` can be set as production or development. -``` +```bash fioctl wave init -k /absolute/path/to/targets.only.key.tgz ``` And then we can complete the Wave by passing the name to the "complete" function: -``` +```bash fioctl wave complete ``` If you decide to cancel, the following command will help you to do that: -``` +```bash fioctl waves cancel ``` @@ -108,13 +108,13 @@ After creating the Wave, you should see it on your Factory page. It should also With this command, we create our group, giving it a name and a short description: -``` +```bash fioctl config device-group create "" ``` The name and the short description should be as explicit and concise as possible to highlight its group. Now to assign a device to our group we use the following command: -``` +```bash fioctl device config group ``` @@ -124,7 +124,7 @@ On your FoundriesFactory device page, you can sort and view devices by the group To roll out our Wave to our device group, use the following command: -``` +```bash fioctl waves rollout ``` diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/07.custom-container/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/07.custom-container/content.md index abb7d43c44..2ea2c6d1aa 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/07.custom-container/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/07.custom-container/content.md @@ -147,7 +147,7 @@ To pull or push repositories, you have to generate an API key. This is done by g Use the following command in git on your machine. To get the repository on your machine, replace "YOUR_FACTORY" with the name of your Factory. The "-b" parameter specifies a branch to checkout after cloning the repository. Running this command will get the container repository, where we will put our folder. -``` +```bash git clone https://source.foundries.io/factories/YOUR_FACTORY/containers.git -b devel ``` @@ -157,13 +157,13 @@ Put the "x8-custom-test" folder in the repository and push it with git. When you After the build finishes, it can take up to 10 minutes for your device to update over-the-air to this new version. You can inspect it via the "Devices" tab of your FoundriesFactory. After your device takes the update, navigate into the "x8-custom-test" folder, which should be located on your board now. This allows us to build our container with a simple command. Using ```docker build``` with a ```--tag``` will let us give the container a tag so we can easily keep track of what version of the build this is. -```python +```bash docker build --tag "x8-custom-test:latest" . ``` Now that it is built, we can run it with ```docker run```, finding it with the tag that we chose to give to the build we want to run. Here we need to enter the user information into the --user tag. This information is found inside the "docker-compose.yml" file. -```python +```bash docker run -it --rm --user "63" x8-custom-test:latest ``` @@ -171,19 +171,19 @@ docker run -it --rm --user "63" x8-custom-test:latest An option for testing an app or container is to use "docker-compose". It is helpful when we have a lot of settings in our "docker-compose.yml" file since we don't have to use those settings in the run argument with this method. First, navigate into the container folder. -```python +```bash cd /home/fio/x8-custom-test ``` This docker-compose command will start your application and register it as a systemd service that will persist even when a reboot occurs. So at the next boot, your docker-compose app will run automatically. -```python +```bash docker-compose up --detach ``` To stop the docker-compose app from running, use the following command: -```python +```bash docker-compose stop ``` @@ -191,14 +191,17 @@ docker-compose stop An alternative method to deploy the custom container is by using the Docker Hub platform. For this, it needs a [Docker Hub account](https://hub.docker.com/) to have your own repository to have the custom container uploaded. When you have the repository ready, the following command will let you upload the custom container image. -``` +```bash docker push HUB_USERNAME/x8-custom-test ``` The custom container image can now be found within `HUB_USERNAME` Docker Hub repository. The image can be accessed whenever any connectivity type grants access to the container image. To pull the image and deploy the container, you will need to connect the Portenta X8 via ADB and use following commands in sequence: -``` +```bash adb shell +``` + +```bash docker pull x8-custom-test ``` diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/08.image-building/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/08.image-building/content.md index dd9f98b320..adca8dcac1 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/08.image-building/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/08.image-building/content.md @@ -44,7 +44,7 @@ You will create a Docker image that has the dependencies needed to build your de First, clone the lmp-manifest repository with the following command: -``` +```bash git clone https://github.com/arduino/lmp-manifest.git ``` @@ -52,8 +52,11 @@ git clone https://github.com/arduino/lmp-manifest.git After cloning the lmp-manifest repository successfully, we will proceed to build the Docker Image using following command sequence: -``` +```bash cd lmp-manifest +``` + +```bash docker build -t yocto-build ./lmp-manifest ``` @@ -69,13 +72,13 @@ Once the *Docker Image* is ready, we will run the image with the `-v` argument t Run the `yocto-build` builder image with following command: -``` +```bash docker run -v :/dockerVolume -it yocto-build bash ``` We need to switch to the `builder` user with the following command after the previous process, and the password is **builder**: -``` +```bash su builder ``` @@ -89,7 +92,7 @@ Now that you are running inside the Docker Image, you can use tools like **git-r First, configure git with your credentials. They don't need to be the real ones but are required by `git-repo` to pull. The following commands can be used for this example: -``` +```bash git config --global user.email "you@example.com" git config --global user.name "Your Name" ``` @@ -98,7 +101,7 @@ git config --global user.name "Your Name" Change to the home directory, and initialize the repository using **repo**: -``` +```bash cd /dockerVolume repo init -u https://github.com/arduino/lmp-manifest.git -m arduino.xml -b release ``` @@ -107,7 +110,7 @@ repo init -u https://github.com/arduino/lmp-manifest.git -m arduino.xml -b relea Then pull the needed files with: -``` +```bash repo sync ``` @@ -149,7 +152,7 @@ You will be able to see similar output as following after the previous steps: To start building the image, following command is used: -``` +```bash bitbake lmp-partner-arduino-image ``` @@ -174,7 +177,7 @@ If possible, it is a good practice to understand the available threads of your c To flash your board, you will need to compile **lmp-mfgtool distro** to get additional tools. First, go into your home folder and change `DISTRO` following the command sequence: -``` +```bash cd .. DISTRO=lmp-mfgtool MACHINE=portenta-x8 . setup-environment echo "ACCEPT_FSL_EULA = \"1\"" >> conf/local.conf @@ -189,7 +192,7 @@ You should be able to see similar results as following image when successful: To compile and get the tools required, we will use following command: -``` +```bash bitbake mfgtool-files ``` @@ -205,7 +208,7 @@ After completion: After a successful build, save the needed files to the host volume you mounted with `docker run`. Use the following commands to copy the files to your storage unit: -``` +```bash cd .. mkdir ../../dockerVolume/flashing DEPLOY_FOLDER=../../dockerVolume/flashing diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/09.image-flashing/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/09.image-flashing/content.md index 4d38954c4c..7a636d7eea 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/09.image-flashing/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/09.image-flashing/content.md @@ -91,19 +91,19 @@ You must connect one USB-C® end to the Portenta X8 and the other (USB-C® or US If *Portenta Breakout* or *Portenta Max Carrier* is unavailable, the Portenta X8 can be configured for programming mode using a few command lines inside the Portenta X8's terminal via ADB. Please use the following commands in exact sequence while in the root environment with root permission. -```arduino +```bash echo 0 > /sys/block/mmcblk2boot0/force_ro ``` -```arduino +```bash dd if=/dev/zero of=/dev/mmcblk2boot0 bs=1024 count=4096 && sync ``` -```arduino +```bash echo 0 > /sys/block/mmcblk2boot1/force_ro ``` -```arduino +```bash dd if=/dev/zero of=/dev/mmcblk2boot1 bs=1024 count=4096 && sync ``` @@ -113,7 +113,7 @@ This sequence of commands will allow you to reset Portenta X8's bootloader secto To flash the Portenta X8, you need to begin by opening a terminal. Within the terminal, you need to change the directory to where the `mfgtool-files-portenta-x8` file is located using the `cd` command. Once it is inside the directory where the previous file is included, the following command is used: -``` +```bash uuu full_image.uuu ``` diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/10.datalogging-iot/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/10.datalogging-iot/content.md index 89c52e8457..acc65cf956 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/10.datalogging-iot/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/10.datalogging-iot/content.md @@ -77,23 +77,23 @@ Let's start by configuring the MQTT broker! Let's start by creating a new directory in our Portenta X8 `home` directory called `mqtt`; inside this directory, we are going to make a file named `docker-compose.yml` using the following commands: -``` +```bash mkdir mqtt ``` -``` +```bash cd mqtt ``` -``` +```bash export TERM=xterm ``` -``` +```bash stty rows 36 cols 150 ``` -``` +```bash sudo vi docker-compose.yml ``` @@ -101,7 +101,7 @@ sudo vi docker-compose.yml Inside the VI editor, copy and paste the following: -``` +```yaml services: mqtt: container_name: mosquitto @@ -125,7 +125,7 @@ volumes: Save the file and exit the VI editor. Return to the `mqtt` directory and run the following command: -``` +```bash docker-compose up -d ``` @@ -133,13 +133,13 @@ The Mosquitto broker should be available on your Portenta X8 `IP address`. You c We should see inside the `mqtt` directory three folders (`config`, `data`, and `log`) and the `docker-compose.yml` file we created before. When we launch the Mosquitto container using the `docker-compose up -d` command, the logs will fill with errors about being unable to open the configuration file. To fix this issue, we can download a default configuration file and store it in the newly created `config` directory: -``` +```bash sudo wget https://raw.githubusercontent.com/eclipse/mosquitto/master/mosquitto.conf ``` Let's add the following lines at the end of the `config` file -``` +```bash # Listen on port 1883 listener 1883 listener 9001 @@ -159,7 +159,7 @@ Save the file and exit the VI editor. Now, let's restart the Mosquitto container Now, we need to manage password files by adding a user to a new password file. For this, we need to run the `sh` command in the mosquitto container with the mosquitto `CONTAINER ID` found before, as shown below: -``` +```bash docker exec -it CONTAINER ID sh ``` @@ -170,20 +170,20 @@ Let's dissect that command: Now, in the terminal session with the Mosquitto container, run the following command: -``` +```bash mosquitto_passwd -c /mosquitto/config/mosquitto.passwd guest ``` This command creates a new password file (`mosquitto.passwd`); if the file already exists, it will overwrite; `guest` is the username. After entering the `username` we want, we must define a password for the username and then exit the terminal session with the `exit` command. Now, let's return to the `config` directory; you should see now inside this directory the `mosquitto.passwd` file. Open the `mosquitto.config` file and add the following information to it: -``` +```bash password_file /mosquitto/config/mosquitto.passwd allow_anonymous true ``` The file should see now like this: -``` +```bash # Password file password_file /mosquitto/config/mosquitto.passwd allow_anonymous true @@ -225,7 +225,7 @@ When MQTTBox client connects to the local Mosquitto broker deployed in our Porte Node-RED is an open-source programming tool that connects hardware with API's and online services. It is a visual tool designed for Internet of Things devices and applications, but it can also be used for other applications. The simplest form to run Node-RED with Docker is by using the following command: -``` +```bash docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red ``` @@ -284,7 +284,7 @@ InfluxDB is an open-source, high-performance, time series database; with InfluxD The simplest form to run InfluxDB with Docker is by using the following command: -``` +```bash docker run --detach --name influxdb -p 8086:8086 influxdb:2.2.0 ``` @@ -353,7 +353,7 @@ Grafana is an open-source, multi-platform data analytics and interactive data vi The simplest form to run Grafana with Docker is by using the following command: -``` +```bash docker run -d --name=grafana -p 3000:3000 grafana/grafana ``` diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/11.display-output-webgl/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/11.display-output-webgl/content.md index 0a63f556f1..a279efd22f 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/11.display-output-webgl/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/11.display-output-webgl/content.md @@ -46,7 +46,7 @@ There are two ways to get the container, either through `foundriesFactories` or If you use [Foundries.io](https://www.foundries.io), you can switch the current `target` of your device to `x-kiosk-imx8-webgl` by switching the app from a terminal on your computer: -``` +```bash //Change the app to an existing one fioctl devices config updates --apps "x-kiosk-imx8-webgl" -f @@ -71,7 +71,7 @@ If you downloaded the [portenta-containers repository](https://github.com/arduin Check the available Wi-Fi® access points by using the `nmcli de wifi` command. You will be able to see an output laying out `BSSID`, `SSID`, and its other elements. -``` +```bash nmcli de wifi //Output @@ -81,7 +81,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BAR The Wi-Fi® details can be saved using the following commands in sequence: -``` +```bash nmcli c add type wifi con-name ifname wlan0 ssid nmcli con modify wifi-sec.key-mgmt wpa-psk nmcli con modify wifi-sec.psk @@ -96,7 +96,7 @@ nmcli c delete If the LED is illuminating Green, then we know it has been correctly connected. If you want to check it in your terminal, you can use the following commands: -``` +```bash nmcli de //Output @@ -113,7 +113,7 @@ The output table will display information regarding active connections as well a The IP information of the board can be obtained using `ifconfig wlan0` command. It will show different IP information composed of `inet`, `netmask`, and `broadcastIP`. -``` +```bash ifconfig wlan0 //Output @@ -123,7 +123,7 @@ wlan0: flags=4163 mtu 1500 Test your IP connection by exiting the `adb shell`, you can use **CTRL+Z** or type `exit`, then try to connect through **SSH** using following command: -``` +```bash ssh fio@ ``` @@ -133,7 +133,7 @@ ssh fio@ You can push the container from your computer using a terminal on the container's directory. The following command is used to send the container to the Portenta X8: -``` +```bash scp fio@: ``` @@ -159,13 +159,13 @@ To get started in modifying the resolution of your display, connect to your Port At this point, you are ready to modify the `/etc/xdg/weston/weston.ini` file with `Vim` command as follows: -```arduino +```bash sudo vim /etc/xdg/weston/weston.ini ``` You can now add the following lines to the `weston.ini` file: -```arduino +```bash [output] name=DP-1 mode=98.00 1600 1680 1840 2080 758 761 771 787 -hsync +vsync @@ -178,7 +178,7 @@ If you obtained the container from **Foundries.io**, it will run automatically a On the other hand, if you copied from the repository, you will need to initialize with **docker** by accessing your Portenta X8 through SSH, going to the directory where you have copied it, and running it from that directory using following commands: -``` +```bash //Connect to your device ssh fio@ @@ -196,7 +196,7 @@ docker-compose stop It is possible to change the web output URL by editing the `docker-compose.yml` file, using the following commands: -``` +```bash //Connect to your device ssh fio@ @@ -226,6 +226,6 @@ In this tutorial, we went through how to connect the board and display something - If you tried to connect with `ssh` and you get a **fingerprint** issue, you will need to remove the IP and fingerprint on your `.ssh` file. On Windows, the file is located at `C:\Users\\.ssh\known_hosts` and try again with the **ssh** connection. An example is as follows: -``` +```bash $portenta-x8: ssh-keygen -R ``` diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/12.multi-protocol-gateway/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/12.multi-protocol-gateway/content.md index 923cd849e9..0d152e7067 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/12.multi-protocol-gateway/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/12.multi-protocol-gateway/content.md @@ -173,7 +173,7 @@ You can access the files [here](assets/Multi_Protocol_Gateway_X8.zip). Meanwhile The `docker-compose.yml` file is where you define permissions and settings for the involved container. This helps to define service dependencies and provide an easy configuration. It will allow to deploy and configure for multiple containers within its defined instructions. -``` +```yaml version: '3.6' services: @@ -196,7 +196,7 @@ In this scenario, we are granting the Portenta a major permission if it needs to Here you will define which additional components are required to run the script built inside the container. If you decide to develop further with a different protocol, you will have to add the package to be able to use them for development. -``` +```cpp msgpack-rpc-python pyserial==3.4 python-periphery==2.3.0 @@ -511,7 +511,7 @@ You will now build the container using the following commands. The following com ```bash cd ../home/fio/Multi_Protocol_Gateway_X8 -Multi_Protocol_Gateway_X8 sudo docker build . -t multi_gateway +sudo docker build . -t multi_gateway ``` You will be able to see the following results when the image is built successfully. @@ -523,19 +523,22 @@ You will be able to see the following results when the image is built successful After a successful container build, you will run the image. To do that, you can use the following command. This command will immediately give an output in your terminal, telling you how the Python® script is running. If you wish to have it running in the background, please add the `-d` flag at the end of the command. ```bash -Multi_Protocol_Gateway_X8 sudo docker-compose up +sudo docker compose up ``` Finally, you will have the multi-protocol gateway running, which uses Wi-Fi® and LoRa® connectivity. Also, RPC for exchanging data between its layers. However, there are cases where you would wish to make changes by adding more functionalities, such as including Cat. M1 or NB-IoT to expand its communication spectrum. For this, you will need to stop the image. To stop the image from running, you can use the following command. ```bash -Multi_Protocol_Gateway_X8 sudo docker-compose down +sudo docker compose down ``` Getting to know the status of the image is also crucial as it is the indicator of the state of operation. The following command brings up **active** containers and shows the status if the container restarted or stopped due to certain reasons. The second command lists built images and it will show you the components that go with the main image that you're building. ```bash docker ps -a +``` + +```bash docker images ``` diff --git a/content/hardware/04.pro/boards/portenta-x8/tutorials/13.wordpress-webserver/content.md b/content/hardware/04.pro/boards/portenta-x8/tutorials/13.wordpress-webserver/content.md index 51a50c88d8..b56e05fabe 100644 --- a/content/hardware/04.pro/boards/portenta-x8/tutorials/13.wordpress-webserver/content.md +++ b/content/hardware/04.pro/boards/portenta-x8/tutorials/13.wordpress-webserver/content.md @@ -44,7 +44,7 @@ This container can run on the Portenta X8's architecture. To start using these c In this section, you can find the complete **docker-compose.yml** file that we will be using for this tutorial. -``` +```yaml version: "3.9" services: @@ -90,13 +90,13 @@ First, we create a directory where we want to add our **docker-compose.yml** fil To create the file, we can use `cat > docker-compose.yml`, this will create the file, so you can copy the content of the file from above and paste it. Push enter once to go to a new line and press `ctrl C` to exit the file editor. To copy the file from your computer onto the device use: -``` +```bash adb push /home/fio/wordpress-test ``` Alternatively, you could place the `docker-compose.yml` file inside the `wordpress-test` directory and push the file using the following command: -``` +```bash adb push .\wordpress-test\ /home/fio ``` @@ -120,7 +120,7 @@ When the command is executed it will start installing the **WordPress** and **Ma To connect to the WordPress setup site, you simply need to access it with your Portenta X8's unique id and port. So we can use the following address format: -``` +```bash http://portenta-x8-.local: ``` @@ -142,13 +142,13 @@ If you want to remove the container, you have to go to ```/home/fio/wordpress-te Remove the container but preserves your WordPress database: -``` +```bash docker compose down ``` Remove the container and the database: -``` +```bash docker compose down --volumes ``` diff --git a/content/hardware/04.pro/carriers/portenta-hat-carrier/tutorials/user-manual/content.md b/content/hardware/04.pro/carriers/portenta-hat-carrier/tutorials/user-manual/content.md index 3e5f438d4c..da0a483e6f 100644 --- a/content/hardware/04.pro/carriers/portenta-hat-carrier/tutorials/user-manual/content.md +++ b/content/hardware/04.pro/carriers/portenta-hat-carrier/tutorials/user-manual/content.md @@ -275,7 +275,7 @@ The following commands will help you set and control the GPIO3, which connects t Let us begin with the commands to access the Portenta X8's shell: -``` +```bash adb shell sudo su - ``` @@ -290,37 +290,37 @@ The aforementioned commands allow you to access the Portenta X8's shell with ele Subsequently, use the following command to export the gpio device located under `/sys/class/`. In this context, _GPIO3_ corresponds to _GPIO 163_, which is associated with the user-programmable LED we aim to access. -``` +```bash echo 163 > /sys/class/gpio/export ``` Using the following commands will help you verify the available GPIO elements. -``` +```bash ls /sys/class/gpio ``` It lists all the GPIOs previously initialized by the system. Meanwhile, the following command lists the details of _GPIO 163_, corresponding to _GPIO3_, which was previously imported: -``` +```bash ls /sys/class/gpio/gpio163 ``` The GPIO can now be configured verifying that GPIO3 elements were successfully exported. The following command with the `I/O` field will set the I/O state of the pin. The pin can be set either as Input using `in` or Output using `out` value. -``` +```bash echo >/sys/class/gpio/gpio163/direction ``` For this example, we will replace the `` field with `out` value within the following command: -``` +```bash echo out >/sys/class/gpio/gpio163/direction ``` To verify the pin setting, use the `cat` command. If correctly configured, this command will display the set value: -``` +```bash cat /sys/class/gpio/gpio163/direction ``` @@ -330,26 +330,25 @@ To set the pin High, you need to assign the value `1`, or `0` to set the pin `HI To set the pin to `HIGH`: -``` +```bash echo 1 >/sys/class/gpio/gpio163/value -echo 0 >/sys/class/gpio/gpio163/value ``` To set the pin to `LOW`: -``` +```bash echo 0 >/sys/class/gpio/gpio163/value ``` If you have finished controlling the GPIO, you can use the following command to _unexport_ it, ensuring it no longer appears in the userspace: -``` +```bash echo 163 >/sys/class/gpio/unexport ``` To confirm that the specified GPIO has been properly unexported, you can use the following command: -``` +```bash ls /sys/class/gpio ``` @@ -969,13 +968,13 @@ Please, refer to the [board pinout section](#pinout) of the user manual to find Using the Portenta X8, you can obtain a voltage reading that falls within a _0 - 65535_ range. This reading corresponds to a voltage between 0 and 3.3 V. To fetch this reading, use the command: -``` +```bash cat /sys/bus/iio/devices/iio\:device0/in_voltage_raw ``` Where `` is the number of the analog pin to read. For example, in the case of `A0`: -``` +```bash cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw ``` @@ -1123,14 +1122,14 @@ The following commands, using the Portenta X8 environment, allow you to capture First, we need to set environment variables and specify the overlays for our camera and board setup: -``` +```bash fw_setenv carrier_custom 1 fw_setenv overlays ov_som_lbee5kl1dx ov_som_x8h7 ov_carrier_rasptenta_base ov_carrier_rasptenta_ov5647_camera_mipi ``` The U-Boot environment variables are modified with the above commands and `fw_setenv` sets the changes which are already persistent. The following command sequences can be used on the U-boot shell. -``` +```bash setenv carrier_custom 1 setenv overlays ov_som_lbee5kl1dx ov_som_x8h7 ov_carrier_rasptenta_base ov_carrier_rasptenta_ov5647_camera_mipi saveenv @@ -1138,28 +1137,28 @@ saveenv Define the runtime directory for `Wayland` and load the necessary module for the OV5647 camera: -``` +```bash export XDG_RUNTIME_DIR=/run # location of wayland-0 socket modprobe ov5647_mipi ``` Before capturing or streaming, we need to check the supported formats and controls of the connected video device: -``` +```bash v4l2-ctl --list-formats-ext --device /dev/video0 v4l2-ctl -d /dev/video0 --list-ctrls ``` Using `GStreamer`, capture a single frame in `JPEG` format: -``` +```bash export GST_DEBUG=3 gst-top-1.0 gst-launch-1.0 -v v4l2src device=/dev/video0 num-buffers=1 ! "video/x-bayer, format=bggr, width=640, height=480, bpp=8, framerate=30/1" ! bayer2rgbneon reduce-bpp=t ! jpegenc ! filesink location=/tmp/test.jpg ``` This command allows the user to capture one frame and save it as `/tmp/test.jpg`. The following command is used to stream video at 30FPS for approximately 10 seconds using `GStreamer`: -``` +```bash gst-top-1.0 gst-launch-1.0 -v v4l2src device=/dev/video0 num-buffers=300 ! "video/x-bayer, format=bggr, width=640, height=480, bpp=8, framerate=30/1" ! bayer2rgbneon reduce-bpp=t ! queue ! waylandsink ``` @@ -1192,31 +1191,31 @@ The fan's speed can be controlled using the following code sequence when you are Export the PWM channel: -``` +```bash echo 9 > /sys/class/pwm/pwmchip0/export ``` Set the PWM period. By defining the period, you determine the duration of one PWM "cycle". Here, we set it to 100,000, representing 100,000 nanoseconds or 100 microseconds: -``` +```bash echo 100000 > /sys/class/pwm/pwmchip0/pwm9/period ``` The following command sets the "ON" duration within the given period. A 50% duty cycle, for instance, means the signal is on for half the period and off for the other half: -``` +```bash echo 50000 > /sys/class/pwm/pwmchip0/pwm9/duty_cycle #50% duty ``` We will then enable the PWM channel exported previously: -``` +```bash echo 1 > /sys/class/pwm/pwmchip0/pwm9/enable ``` You can use the following command if you want to monitor the temperature of the device or environment (optional step): -``` +```bash cat /sys/devices/virtual/thermal/thermal_zone0/temp ``` @@ -1258,25 +1257,25 @@ if __name__ == "__main__": If you are logged in with normal privileges, the speed of the fan can be controlled using the following instruction sequence. Export the PWM channel using the command below: -``` +```bash echo 9 | sudo tee /sys/class/pwm/pwmchip0/export ``` Set the PWM period: -``` +```bash echo 100000 | sudo tee /sys/class/pwm/pwmchip0/pwm9/period ``` Determine the duty cycle at 50%: -``` +```bash echo 50000 | sudo tee /sys/class/pwm/pwmchip0/pwm9/duty_cycle #50% duty ``` And activate the PWM channel: -``` +```bash echo 1 | sudo tee /sys/class/pwm/pwmchip0/pwm9/enable ``` @@ -1856,13 +1855,13 @@ chmod 700 ~/bin/iperf3 Once installed, _iperf3_ will be ready on your device. To ensure it operates without issues, run: -``` +```bash chmod +x iperf3 ``` By following the provided instructions, the tool should be located in the Linux shell at: -``` +```bash # ~bin/ ``` @@ -3010,20 +3009,20 @@ Please, refer to the [board pinout section](#pinout) of the user manual to find With admin (root) access, you can use the following commands within the shell for the Portenta X8: -``` +```bash sudo modprobe spidev ``` Present sequence of commands is used to enable the SPI device interface on the Portenta X8. After adding the `spidev` module to the system's configuration, the system is rebooted to apply the changes. -``` +```bash echo "spidev" | sudo tee > /etc/modules-load.d/spidev.conf sudo systemctl reboot ``` Following section configures a service named `my_spi_service` to use the SPI device available at `/dev/spidev0.0`. -``` +```yaml services: my_spi_service: devices: @@ -3141,20 +3140,20 @@ Please, refer to the [pinout section](#pinout) of the user manual to find them o For the Portenta X8, it is possible to use the following commands within the shell when you have admin (root) access: -``` +```bash sudo modprobe i2c-dev ``` Present sequence of commands is used to enable the I2C device interface on the Portenta X8. After adding the `i2c-dev` module to the system's configuration, the system is rebooted to apply the changes. -``` +```bash echo "i2c-dev" | sudo tee > /etc/modules-load.d/i2c-dev.conf sudo systemctl reboot ``` Following section configures a service named `my_i2c_service` to use the I2C device available at `/dev/i2c-3`. -``` +```yaml services: my_i2c_service: devices: @@ -3327,7 +3326,7 @@ Since the CAN bus pins are integrated within the High-Density connectors, they a For the Portenta X8, when you have admin (root) access, you can execute the following commands within the shell to control the CAN bus protocol. The CAN transceiver can be enabled using the following command -``` +```bash echo 164 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio164/direction && echo 0 > /sys/class/gpio/gpio164/value ``` @@ -3335,13 +3334,13 @@ This command sequence activates the CAN transceiver. It does so by exporting _GP For Portenta X8, it is possible to use the following commands: -``` +```bash sudo modprobe can-dev ``` The necessary modules for CAN (Controller Area Network) support on the Portenta X8 are loaded. The `can-dev` module is added to the system configuration, after which the system is rebooted to apply the changes. -``` +```bash echo "can-dev" | sudo tee > /etc/modules-load.d/can-dev.conf sudo systemctl reboot ``` @@ -3642,8 +3641,11 @@ Please, refer to the board pinout section of the user manual to find them on the For the Portenta X8, when you have admin (root) access, you can execute the command `ls /dev/ttyUSB* /dev/ttyACM* /dev/ttymxc*` within the shell to list available serial ports in Linux. Typically, USB serial devices could appear as _/dev/ttyUSBx_, _/dev/ttyACMx_, or _/dev/ttymxcx_. -``` +```bash ls /dev/ttyUSB* /dev/ttyACM* /dev/ttymxc* +``` + +```bash /dev/ttymxc2 // Something similar ``` diff --git a/content/hardware/04.pro/carriers/portenta-max-carrier/tutorials/x8-getting-started/content.md b/content/hardware/04.pro/carriers/portenta-max-carrier/tutorials/x8-getting-started/content.md index b82f004beb..d2626dc6ec 100644 --- a/content/hardware/04.pro/carriers/portenta-max-carrier/tutorials/x8-getting-started/content.md +++ b/content/hardware/04.pro/carriers/portenta-max-carrier/tutorials/x8-getting-started/content.md @@ -62,7 +62,8 @@ To make use of the Portenta Max Carrier you will need to power it through either The Portenta Max Carrier equips two different memory units onboard, a flash memory and a mini SD card slot. The Flash memory onboard the Portenta Max Carrier has 2 MB of storage via QSPI. The Mini SD card interface makes it possible to extend the storage size. It can be used to process log data, from sensors or programmed on-board computer registry. If you have an SD card connected to the Max Carrier you can create a directory on the SD card by using the following command: -```python + +```bash mkdir -p /tmp/sdcard ``` @@ -73,7 +74,8 @@ The Portenta Max Carrier features the CS42L52 from Cirrus Logic®, a stereo CODE ![Audio connections on the Portenta Max Carrier](assets/audio-interface-max-carrier.svg) To use this feature with Linux, you could use something like the [alsa-lib](https://github.com/alsa-project/alsa-lib). You can run it with this command: -```python + +```bash apk update && apk add alsa-utils alsa-utils-doc alsa-lib alsaconf alsa-ucm-conf && speaker-test -t sine -f 440 -c 2 -r 48000 -D hw:0,0 ``` @@ -100,7 +102,8 @@ For more in-depth information about LoRa® and LoRaWAN®, please read [The Ardui The Gigabit Ethernet physical interface is directly connected to the high-density connector to the Portenta X8 board. The connector includes an LED for indicating activity using the color orange, there is also a LED using the color green to indicate speed. To access the 1 Gbps connection Ethernet peripheral on the Max Carrier you can use the following command: -```python + +```bash ETH_1G=`dmesg | grep "fec 30be0000.ethernet eth0: Link is Up - 1Gbps/Full"` ``` diff --git a/content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-opta-temp-ctrl/content.md b/content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-opta-temp-ctrl/content.md index 86eb5e5181..b0e29a806d 100644 --- a/content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-opta-temp-ctrl/content.md +++ b/content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-opta-temp-ctrl/content.md @@ -153,7 +153,7 @@ Inside the `Project` window, double-click on the `Main` program located under `T In the code section, you have to write the following code: -``` +```cpp temp0 := sysTempProbes[0].temperature; temp_send := temp0 * 100.00; ``` @@ -262,7 +262,7 @@ Now that we have created the global variable where we are going to store the tem In the code window, paste the next code: -``` +```cpp //Set the temperature threshold to trigger on the relay threshold := 30.00; diff --git a/content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/rtd-thermocouple-pmc/content.md b/content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/rtd-thermocouple-pmc/content.md index eb0bc21b55..2f761b44b4 100644 --- a/content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/rtd-thermocouple-pmc/content.md +++ b/content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/rtd-thermocouple-pmc/content.md @@ -187,7 +187,7 @@ If everything is correct, when you double-click on **Global_vars**, a table with Now that we have created the variables, we have to make it work by defining the variables in the **main** program code. To do this, double-click on "main" and write the next lines in the code box: -``` +```cpp TP00 := sysTempProbes[0]; temp0:= systempProbes[0].temperature; ``` diff --git a/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cli-tool/content.md b/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cli-tool/content.md index 720b2892a8..82de62777f 100644 --- a/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cli-tool/content.md +++ b/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cli-tool/content.md @@ -99,27 +99,37 @@ You can set the rate and the latency of each sensor, please check the [Nicla Sen The syntax for configuring a sensor is: -`bhy sensor config -p -sensor -rate -latency ` +```bash +bhy sensor config -p -sensor -rate -latency +``` For example, if you want to configure the **Gyroscope passthrough** which has the sensor ID #**10** connected on the port `COM01` with a rate of 1Hz and a latency of 0ms, you will enter: -`bhy sensor config -p /dev/ttyACM2 -sensor 10 -rate 1 -latency 0` +```bash +bhy sensor config -p /dev/ttyACM2 -sensor 10 -rate 1 -latency 0 +``` Now it is configured to output the reading every second (1Hz). ### Disable If you set the latency and rate to **0**, the sensor will be disabled and it will not output any data. -`bhy sensor config -p -sensor -rate 0 -latency 0` +```bash +bhy sensor config -p -sensor -rate 0 -latency 0 +``` ### Read Data From a Sensor If you want to read data from a sensor and print it once, you can use: -`bhy sensor read -p ` +```bash +bhy sensor read -p +``` To do it continuously, you can add the parameter `-live` -`bhy sensor read -live -p ` +```bash +bhy sensor read -live -p +``` ## Using a Passthrough Board with CLI When you have a firmware for the BHI module or a sketch for the MCU already compiled in a **.bin** file, you can upload them through a MKR or Portenta board directly using the terminal. You need to upload a passthrough sketch to the MKR or Portenta board, allowing the Nicla to communicate with the computer through the host board. The sketch can be found at **Examples > Arduino_BHY_HOST > Passthrough.ino**. @@ -129,12 +139,16 @@ You then need to connect the Nicla board to the desired passthrough board either ### Upload a Sketch Syntax for uploading a sketch: -`bhy dfu -t nicla -bin -p ` +```bash +bhy dfu -t nicla -bin -p +``` ### Updating the Firmware Syntax for uploading the firmware: -`bhy dfu -t bhi -bin -p ` +```bash +bhy dfu -t bhi -bin -p +``` ## Conclusion diff --git a/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/web-ble-dashboard/content.md b/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/web-ble-dashboard/content.md index 4236368fde..b10b654fec 100644 --- a/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/web-ble-dashboard/content.md +++ b/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/web-ble-dashboard/content.md @@ -54,216 +54,217 @@ If you use the Web Editor to upload the [sketch](https://create.arduino.cc/edito These libraries can be found within the Library Manager in the Arduino IDE, or it can be downloaded separately following the links attached within required hardware and software section. If you use a local IDE, you can copy & paste the following sketch: -```arduino - /* - Arduino Nicla Sense ME WEB Bluetooth® Low Energy Sense dashboard demo - Hardware required: https://store.arduino.cc/nicla-sense-me - 1) Upload this sketch to the Arduino Nano Bluetooth® Low Energy sense board - 2) Open the following web page in the Chrome browser: - https://arduino.github.io/ArduinoAI/NiclaSenseME-dashboard/ - 3) Click on the green button in the web page to connect the browser to the board over Bluetooth® Low Energy - Web dashboard by D. Pajak - Device sketch based on example by Sandeep Mistry and Massimo Banzi - Sketch and web dashboard copy-fixed to be used with the Nicla Sense ME by Pablo Marquínez - */ - - #include "Nicla_System.h" - #include "Arduino_BHY2.h" - #include - - #define BLE_SENSE_UUID(val) ("19b10000-" val "-537e-4f6c-d104768a1214") - - const int VERSION = 0x00000000; - - BLEService service(BLE_SENSE_UUID("0000")); - - BLEUnsignedIntCharacteristic versionCharacteristic(BLE_SENSE_UUID("1001"), BLERead); - BLEFloatCharacteristic temperatureCharacteristic(BLE_SENSE_UUID("2001"), BLERead); - BLEUnsignedIntCharacteristic humidityCharacteristic(BLE_SENSE_UUID("3001"), BLERead); - BLEFloatCharacteristic pressureCharacteristic(BLE_SENSE_UUID("4001"), BLERead); - - BLECharacteristic accelerometerCharacteristic(BLE_SENSE_UUID("5001"), BLERead | BLENotify, 3 * sizeof(float)); // Array of 3x 2 Bytes, XY - BLECharacteristic gyroscopeCharacteristic(BLE_SENSE_UUID("6001"), BLERead | BLENotify, 3 * sizeof(float)); // Array of 3x 2 Bytes, XYZ - BLECharacteristic quaternionCharacteristic(BLE_SENSE_UUID("7001"), BLERead | BLENotify, 4 * sizeof(float)); // Array of 4x 2 Bytes, XYZW - - BLECharacteristic rgbLedCharacteristic(BLE_SENSE_UUID("8001"), BLERead | BLEWrite, 3 * sizeof(byte)); // Array of 3 bytes, RGB - - BLEFloatCharacteristic bsecCharacteristic(BLE_SENSE_UUID("9001"), BLERead); - BLEIntCharacteristic co2Characteristic(BLE_SENSE_UUID("9002"), BLERead); - BLEUnsignedIntCharacteristic gasCharacteristic(BLE_SENSE_UUID("9003"), BLERead); - - // String to calculate the local and device name - String name; - - Sensor temperature(SENSOR_ID_TEMP); - Sensor humidity(SENSOR_ID_HUM); - Sensor pressure(SENSOR_ID_BARO); - Sensor gas(SENSOR_ID_GAS); - SensorXYZ gyroscope(SENSOR_ID_GYRO); - SensorXYZ accelerometer(SENSOR_ID_ACC); - SensorQuaternion quaternion(SENSOR_ID_RV); - SensorBSEC bsec(SENSOR_ID_BSEC); - - void setup(){ - Serial.begin(115200); - - Serial.println("Start"); - - nicla::begin(); - nicla::leds.begin(); - nicla::leds.setColor(green); - - //Sensors initialization - BHY2.begin(NICLA_STANDALONE); - temperature.begin(); - humidity.begin(); - pressure.begin(); - gyroscope.begin(); - accelerometer.begin(); - quaternion.begin(); - bsec.begin(); - gas.begin(); - - if (!BLE.begin()){ - Serial.println("Failed to initialized BLE!"); - - while (1) - ; - } - - String address = BLE.address(); - - Serial.print("address = "); - Serial.println(address); - - address.toUpperCase(); - - name = "NiclaSenseME-"; - name += address[address.length() - 5]; - name += address[address.length() - 4]; - name += address[address.length() - 2]; - name += address[address.length() - 1]; - Serial.print("name = "); - Serial.println(name); +```arduino +/* +Arduino Nicla Sense ME WEB Bluetooth® Low Energy Sense dashboard demo +Hardware required: https://store.arduino.cc/nicla-sense-me +1) Upload this sketch to the Arduino Nano Bluetooth® Low Energy sense board +2) Open the following web page in the Chrome browser: +https://arduino.github.io/ArduinoAI/NiclaSenseME-dashboard/ +3) Click on the green button in the web page to connect the browser to the board over Bluetooth® Low Energy +Web dashboard by D. Pajak +Device sketch based on example by Sandeep Mistry and Massimo Banzi +Sketch and web dashboard copy-fixed to be used with the Nicla Sense ME by Pablo Marquínez +*/ + +#include "Nicla_System.h" +#include "Arduino_BHY2.h" +#include + +#define BLE_SENSE_UUID(val) ("19b10000-" val "-537e-4f6c-d104768a1214") + +const int VERSION = 0x00000000; + +BLEService service(BLE_SENSE_UUID("0000")); + +BLEUnsignedIntCharacteristic versionCharacteristic(BLE_SENSE_UUID("1001"), BLERead); +BLEFloatCharacteristic temperatureCharacteristic(BLE_SENSE_UUID("2001"), BLERead); +BLEUnsignedIntCharacteristic humidityCharacteristic(BLE_SENSE_UUID("3001"), BLERead); +BLEFloatCharacteristic pressureCharacteristic(BLE_SENSE_UUID("4001"), BLERead); + +BLECharacteristic accelerometerCharacteristic(BLE_SENSE_UUID("5001"), BLERead | BLENotify, 3 * sizeof(float)); // Array of 3x 2 Bytes, XY +BLECharacteristic gyroscopeCharacteristic(BLE_SENSE_UUID("6001"), BLERead | BLENotify, 3 * sizeof(float)); // Array of 3x 2 Bytes, XYZ +BLECharacteristic quaternionCharacteristic(BLE_SENSE_UUID("7001"), BLERead | BLENotify, 4 * sizeof(float)); // Array of 4x 2 Bytes, XYZW + +BLECharacteristic rgbLedCharacteristic(BLE_SENSE_UUID("8001"), BLERead | BLEWrite, 3 * sizeof(byte)); // Array of 3 bytes, RGB + +BLEFloatCharacteristic bsecCharacteristic(BLE_SENSE_UUID("9001"), BLERead); +BLEIntCharacteristic co2Characteristic(BLE_SENSE_UUID("9002"), BLERead); +BLEUnsignedIntCharacteristic gasCharacteristic(BLE_SENSE_UUID("9003"), BLERead); + +// String to calculate the local and device name +String name; + +Sensor temperature(SENSOR_ID_TEMP); +Sensor humidity(SENSOR_ID_HUM); +Sensor pressure(SENSOR_ID_BARO); +Sensor gas(SENSOR_ID_GAS); +SensorXYZ gyroscope(SENSOR_ID_GYRO); +SensorXYZ accelerometer(SENSOR_ID_ACC); +SensorQuaternion quaternion(SENSOR_ID_RV); +SensorBSEC bsec(SENSOR_ID_BSEC); + +void setup(){ + Serial.begin(115200); + + Serial.println("Start"); + + nicla::begin(); + nicla::leds.begin(); + nicla::leds.setColor(green); + + //Sensors initialization + BHY2.begin(NICLA_STANDALONE); + temperature.begin(); + humidity.begin(); + pressure.begin(); + gyroscope.begin(); + accelerometer.begin(); + quaternion.begin(); + bsec.begin(); + gas.begin(); + + if (!BLE.begin()){ + Serial.println("Failed to initialized BLE!"); + + while (1) + ; + } - BLE.setLocalName(name.c_str()); - BLE.setDeviceName(name.c_str()); - BLE.setAdvertisedService(service); + String address = BLE.address(); - // Add all the previously defined Characteristics - service.addCharacteristic(temperatureCharacteristic); - service.addCharacteristic(humidityCharacteristic); - service.addCharacteristic(pressureCharacteristic); - service.addCharacteristic(versionCharacteristic); - service.addCharacteristic(accelerometerCharacteristic); - service.addCharacteristic(gyroscopeCharacteristic); - service.addCharacteristic(quaternionCharacteristic); - service.addCharacteristic(bsecCharacteristic); - service.addCharacteristic(co2Characteristic); - service.addCharacteristic(gasCharacteristic); - service.addCharacteristic(rgbLedCharacteristic); + Serial.print("address = "); + Serial.println(address); - // Disconnect event handler - BLE.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler); + address.toUpperCase(); - // Sensors event handlers - temperatureCharacteristic.setEventHandler(BLERead, onTemperatureCharacteristicRead); - humidityCharacteristic.setEventHandler(BLERead, onHumidityCharacteristicRead); - pressureCharacteristic.setEventHandler(BLERead, onPressureCharacteristicRead); - bsecCharacteristic.setEventHandler(BLERead, onBsecCharacteristicRead); - co2Characteristic.setEventHandler(BLERead, onCo2CharacteristicRead); - gasCharacteristic.setEventHandler(BLERead, onGasCharacteristicRead); + name = "NiclaSenseME-"; + name += address[address.length() - 5]; + name += address[address.length() - 4]; + name += address[address.length() - 2]; + name += address[address.length() - 1]; - rgbLedCharacteristic.setEventHandler(BLEWritten, onRgbLedCharacteristicWrite); + Serial.print("name = "); + Serial.println(name); - versionCharacteristic.setValue(VERSION); + BLE.setLocalName(name.c_str()); + BLE.setDeviceName(name.c_str()); + BLE.setAdvertisedService(service); - BLE.addService(service); - BLE.advertise(); - } + // Add all the previously defined Characteristics + service.addCharacteristic(temperatureCharacteristic); + service.addCharacteristic(humidityCharacteristic); + service.addCharacteristic(pressureCharacteristic); + service.addCharacteristic(versionCharacteristic); + service.addCharacteristic(accelerometerCharacteristic); + service.addCharacteristic(gyroscopeCharacteristic); + service.addCharacteristic(quaternionCharacteristic); + service.addCharacteristic(bsecCharacteristic); + service.addCharacteristic(co2Characteristic); + service.addCharacteristic(gasCharacteristic); + service.addCharacteristic(rgbLedCharacteristic); - void loop(){ - while (BLE.connected()){ - BHY2.update(); + // Disconnect event handler + BLE.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler); - if (gyroscopeCharacteristic.subscribed()){ - float x, y, z; + // Sensors event handlers + temperatureCharacteristic.setEventHandler(BLERead, onTemperatureCharacteristicRead); + humidityCharacteristic.setEventHandler(BLERead, onHumidityCharacteristicRead); + pressureCharacteristic.setEventHandler(BLERead, onPressureCharacteristicRead); + bsecCharacteristic.setEventHandler(BLERead, onBsecCharacteristicRead); + co2Characteristic.setEventHandler(BLERead, onCo2CharacteristicRead); + gasCharacteristic.setEventHandler(BLERead, onGasCharacteristicRead); - x = gyroscope.x(); - y = gyroscope.y(); - z = gyroscope.z(); + rgbLedCharacteristic.setEventHandler(BLEWritten, onRgbLedCharacteristicWrite); - float gyroscopeValues[3] = {x, y, z}; + versionCharacteristic.setValue(VERSION); - gyroscopeCharacteristic.writeValue(gyroscopeValues, sizeof(gyroscopeValues)); - } + BLE.addService(service); + BLE.advertise(); +} - if (accelerometerCharacteristic.subscribed()){ - float x, y, z; - x = accelerometer.x(); - y = accelerometer.y(); - z = accelerometer.z(); +void loop(){ + while (BLE.connected()){ + BHY2.update(); - float accelerometerValues[] = {x, y, z}; - accelerometerCharacteristic.writeValue(accelerometerValues, sizeof(accelerometerValues)); - } + if (gyroscopeCharacteristic.subscribed()){ + float x, y, z; - if(quaternionCharacteristic.subscribed()){ - float x, y, z, w; - x = quaternion.x(); - y = quaternion.y(); - z = quaternion.z(); - w = quaternion.w(); + x = gyroscope.x(); + y = gyroscope.y(); + z = gyroscope.z(); - float quaternionValues[] = {x,y,z,w}; - quaternionCharacteristic.writeValue(quaternionValues, sizeof(quaternionValues)); - } + float gyroscopeValues[3] = {x, y, z}; + gyroscopeCharacteristic.writeValue(gyroscopeValues, sizeof(gyroscopeValues)); } - } - void blePeripheralDisconnectHandler(BLEDevice central){ - nicla::leds.setColor(red); - } + if (accelerometerCharacteristic.subscribed()){ + float x, y, z; + x = accelerometer.x(); + y = accelerometer.y(); + z = accelerometer.z(); - void onTemperatureCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ - float temperatureValue = temperature.value(); - temperatureCharacteristic.writeValue(temperatureValue); - } - - void onHumidityCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ - uint8_t humidityValue = humidity.value() + 0.5f; //since we are truncating the float type to a uint8_t, we want to round it - humidityCharacteristic.writeValue(humidityValue); - } - - void onPressureCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ - float pressureValue = pressure.value(); - pressureCharacteristic.writeValue(pressureValue); - } - - void onBsecCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ - float airQuality = float(bsec.iaq()); - bsecCharacteristic.writeValue(airQuality); - } + float accelerometerValues[] = {x, y, z}; + accelerometerCharacteristic.writeValue(accelerometerValues, sizeof(accelerometerValues)); + } - void onCo2CharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ - uint32_t co2 = bsec.co2_eq(); - co2Characteristic.writeValue(co2); - } + if(quaternionCharacteristic.subscribed()){ + float x, y, z, w; + x = quaternion.x(); + y = quaternion.y(); + z = quaternion.z(); + w = quaternion.w(); - void onGasCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ - unsigned int g = gas.value(); - gasCharacteristic.writeValue(g); - } - - void onRgbLedCharacteristicWrite(BLEDevice central, BLECharacteristic characteristic){ - byte r = rgbLedCharacteristic[0]; - byte g = rgbLedCharacteristic[1]; - byte b = rgbLedCharacteristic[2]; + float quaternionValues[] = {x,y,z,w}; + quaternionCharacteristic.writeValue(quaternionValues, sizeof(quaternionValues)); + } - nicla::leds.setColor(r, g, b); } +} + +void blePeripheralDisconnectHandler(BLEDevice central){ + nicla::leds.setColor(red); +} + +void onTemperatureCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ + float temperatureValue = temperature.value(); + temperatureCharacteristic.writeValue(temperatureValue); +} + +void onHumidityCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ + uint8_t humidityValue = humidity.value() + 0.5f; //since we are truncating the float type to a uint8_t, we want to round it + humidityCharacteristic.writeValue(humidityValue); +} + +void onPressureCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ + float pressureValue = pressure.value(); + pressureCharacteristic.writeValue(pressureValue); +} + +void onBsecCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ + float airQuality = float(bsec.iaq()); + bsecCharacteristic.writeValue(airQuality); +} + +void onCo2CharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ + uint32_t co2 = bsec.co2_eq(); + co2Characteristic.writeValue(co2); +} + +void onGasCharacteristicRead(BLEDevice central, BLECharacteristic characteristic){ + unsigned int g = gas.value(); + gasCharacteristic.writeValue(g); +} + +void onRgbLedCharacteristicWrite(BLEDevice central, BLECharacteristic characteristic){ + byte r = rgbLedCharacteristic[0]; + byte g = rgbLedCharacteristic[1]; + byte b = rgbLedCharacteristic[2]; + + nicla::leds.setColor(r, g, b); +} ``` Once you have these tools, you can select the Nicla Sense ME as target board and its corresponding port. Now you are ready to upload the sketch. diff --git a/content/hardware/06.nicla/boards/nicla-voice/tutorials/getting-started-ml/content.md b/content/hardware/06.nicla/boards/nicla-voice/tutorials/getting-started-ml/content.md index 771fa1de5e..07418991da 100644 --- a/content/hardware/06.nicla/boards/nicla-voice/tutorials/getting-started-ml/content.md +++ b/content/hardware/06.nicla/boards/nicla-voice/tutorials/getting-started-ml/content.md @@ -55,21 +55,21 @@ The Nicla Voice has a built-in speech recognition example: **the Alexa demo**. Y 2. Extract [this .zip file](assets/nicla_voice_uploader_and_firmwares.zip), which contains the compiled uploaders for various operating systems, as well as the updated NDP120 processor firmware and speech recognition model. 3. Open a new terminal where the .zip file was extracted and execute the following command: - ``` + ```bash ./syntiant-uploader send -m "Y" -w "Y" -p $portName $filename ``` Replace `portName` and `filename` with the relevant information. Three different files must be uploaded to the board by executing the following three commands: - ``` + ```bash ./syntiant-uploader send -m "Y" -w "Y" -p COM6 mcu_fw_120_v91.synpkg ``` - ``` + ```bash ./syntiant-uploader send -m "Y" -w "Y" -p COM6 dsp_firmware_v91.synpkg ``` - ``` + ```bash ./syntiant-uploader send -m "Y" -w "Y" -p COM6 model_name.synpkg ``` diff --git a/content/hardware/06.nicla/boards/nicla-voice/tutorials/motion-detection-ml/content.md b/content/hardware/06.nicla/boards/nicla-voice/tutorials/motion-detection-ml/content.md index 6d1e3a0648..81b808259d 100644 --- a/content/hardware/06.nicla/boards/nicla-voice/tutorials/motion-detection-ml/content.md +++ b/content/hardware/06.nicla/boards/nicla-voice/tutorials/motion-detection-ml/content.md @@ -178,8 +178,8 @@ After unzipping the downloaded file, run the appropriate flashing script for you With your Nicla Voice board flashed, open a new terminal window and run the following command: -``` -$ edge-impulse-run-impulse +```bash +edge-impulse-run-impulse ``` This command will sample data from your Nicla's Voice onboard IMU, make inferences, and then classify the movement made on your board. You should see the following output in the terminal window when your Nicla Voice board is moved in horizontal movements, from left to right. diff --git a/content/hardware/06.nicla/boards/nicla-voice/tutorials/user-manual/content.md b/content/hardware/06.nicla/boards/nicla-voice/tutorials/user-manual/content.md index 1ef00e2e24..1b039046f2 100644 --- a/content/hardware/06.nicla/boards/nicla-voice/tutorials/user-manual/content.md +++ b/content/hardware/06.nicla/boards/nicla-voice/tutorials/user-manual/content.md @@ -135,21 +135,21 @@ It is recommended to update the NDP120 processor firmware and the built-in speec 3. Extract [this .zip file](assets/nicla_voice_uploader_and_firmwares.zip), which contains the compiled uploaders for various operating systems, and the updated NDP120 processor firmware and speech recognition model, in a known location on your computer. 4. Open a new terminal in the location where the .zip file was extracted and execute the following command: - ``` + ```bash syntiant-uploader send -m "Y" -w "Y" -p $portName $filename ``` Replace `portName` and `filename` with the relevant information. Three different files must be uploaded to the board by executing the following three commands, for example in Windows the commands are the following: - ``` + ```bash ./syntiant-uploader send -m "Y" -w "Y" -p COM6 mcu_fw_120_v91.synpkg ``` - ``` + ```bash ./syntiant-uploader send -m "Y" -w "Y" -p COM6 dsp_firmware_v91.synpkg ``` - ``` + ```bash ./syntiant-uploader send -m "Y" -w "Y" -p COM6 model_name.synpkg ``` diff --git a/content/hardware/07.opta/opta-family/opta/tutorials/opta-azure-iot-tutorial-en/content.md b/content/hardware/07.opta/opta-family/opta/tutorials/opta-azure-iot-tutorial-en/content.md index 75450b246a..7ea1bb852f 100644 --- a/content/hardware/07.opta/opta-family/opta/tutorials/opta-azure-iot-tutorial-en/content.md +++ b/content/hardware/07.opta/opta-family/opta/tutorials/opta-azure-iot-tutorial-en/content.md @@ -172,7 +172,7 @@ In particular, the information to be customized for the connection is represente You will need some of the information present on the device configuration page on Azure. As mentioned earlier, you can copy the necessary information and modify the code accordingly: -``` arduino +```arduino // Wifi #define IOT_CONFIG_WIFI_SSID "MyWifi" // Change it to your Wi-Fi network name #define IOT_CONFIG_WIFI_PASSWORD "12345678" // Change it to your Wi-Fi network password @@ -202,7 +202,7 @@ In the code, it is set to 300,000 milliseconds or 5 minutes: ![Opta™ Azure IoT Tutorial Sketch - Telemetry frequency](assets/opta-azure-iot-tutorial-202105.png) -``` arduino +```arduino // Publish 1 message every 5 minutes #define IOT_CONFIG_TELEMETRY_FREQUENCY_MS 300000 ``` @@ -213,7 +213,7 @@ In the **Azure_IoT_Hub_Opta.ino** file, you find a portion of code represented b ![Opta™ Azure IoT Tutorial Sketch - Telemetry payload](assets/opta-azure-iot-tutorial-202627.png) -``` arduino +```arduino /* * generateTelemetry: * Simulated telemetry. @@ -233,7 +233,7 @@ You can modify this function by changing the value of **telemetryPayload** and s You can modify this function to send a different message, for example, a classic "Hello, World": -``` arduino +```arduino static char* generateTelemetry() { telemetryPayload = String("Hello, World!"); diff --git a/content/software/plc-ide/tutorials/plc-ide-cloud-support/content.md b/content/software/plc-ide/tutorials/plc-ide-cloud-support/content.md index 5de3a9463f..60d0845370 100644 --- a/content/software/plc-ide/tutorials/plc-ide-cloud-support/content.md +++ b/content/software/plc-ide/tutorials/plc-ide-cloud-support/content.md @@ -405,7 +405,7 @@ The PLC program will do the following processes: The following code delivers the previous tasks: -``` +```cpp cnt := cnt + 1; out_counter := cnt; diff --git a/content/software/plc-ide/tutorials/plc-ide-pin-mapping/content.md b/content/software/plc-ide/tutorials/plc-ide-pin-mapping/content.md index 31d2f37036..9076b88738 100644 --- a/content/software/plc-ide/tutorials/plc-ide-pin-mapping/content.md +++ b/content/software/plc-ide/tutorials/plc-ide-pin-mapping/content.md @@ -79,7 +79,7 @@ We will assign to the **Digital Output pin 2** the name **`digitalOut01`** To interact with the digital output pin you can use this code: -``` +```cpp // Set the Digital Output 01 to HIGH digitalOut01 := 1; @@ -102,7 +102,7 @@ Now on the popup menu, you can set the name of the variable, then select the typ As it is an array you will be able to access its pin in a **For loop** like the following: -``` +```cpp // Set all the Digital Outputs to HIGH FOR pinNumber := 0 TO 7 DO diff --git a/content/software/plc-ide/tutorials/plc-programming-introduction/content.md b/content/software/plc-ide/tutorials/plc-programming-introduction/content.md index 6fbcb0a144..2dfa2f3399 100644 --- a/content/software/plc-ide/tutorials/plc-programming-introduction/content.md +++ b/content/software/plc-ide/tutorials/plc-programming-introduction/content.md @@ -159,7 +159,8 @@ There are 5 languages available: ### Structured Text This language is similar to C, the code to assign a value to a variable is the following: -``` + +```cpp count := count + addition; ``` @@ -170,7 +171,8 @@ count := count + addition; This programming language is similar to Assembly programming. The code for a counter script is: -``` + +```cpp LD count ADD addition ST count