Getting Started With the Arduino Portenta Breakout

This tutorial will give you an overview of the core features of the Portenta Breakout, setup the development environment and introduce the APIs required to program the board.

Overview

The Arduino Portenta Breakout is a versatile tool designed for developing, testing and debugging on Portenta family boards. In this tutorial you will set up the development environment for the Portenta Breakout and learn some of its simple functionalities using the Breakout Carrier Library.

Goals

  • About the Portenta Breakout's layout and functions
  • How to setup the development environment
  • How to use the Arduino_PortentaBreakout library
  • Control an external LED using one of the carriers PWM pins
  • Read an external potentiometer using an analog pin on the carrier

Required Hardware and Software

Instructions

1. Get to Know the Carrier

The Portenta Breakout is designed to reduce development time. It gives access to the Portenta's High Density connectors as well as features Ethernet, USB-A, a JTAG connector and more. However, for this tutorial, we will focus on using the Arduino_PortentaBreakout library to get access to the High Density connectors and create some simple example use cases.

Parts of the Portenta Breakout board

2. The Basic Setup

As part of this tutorial, we will create two sample use cases for the Arduino_PortentaBreakout library: starting by using the Portenta Breakout's PWM pins to connect an LED and fade its brightness high ad low. Secondly, we will connect an external potentiometer to showcase how to use the Portenta Breakout to read an analog input. In order to use the pins on the Portenta Breakout to connect external components, pin headers have to be soldered on to the used pins. We recommend using double row pin headers.

After having prepared the Portenta Breakout by soldering on pin headers, we can start using it. The board comes with two DIP switches called BOOT and BT_SEL. These switches are used to keep the Portenta in either boot-mode (BT_SEL switch) or to enable the embedded bootloader (BOOT switch) to upload firmware via the USB port on the Portenta Breakout. In this case, we have to make sure that both DIP switches are set in the OFF position. Having done that, we can connect the Portenta H7 to the Portenta Breakout using the two high density connectors in the orientation showcased by the dashed line on the Portenta Breakout.

Dip switch on the Breakout

3. The Circuit

In order to build this example circuit, we need our Portenta Breakout with the Portenta H7 on top and headers soldered on (at least within the ANALOG/PWM and GPIO section on the bottom right corner of the carrier). Then we need a simple LED, an adequate resistor for it (we are using a 220Ω resistor) as well as a potentiometer. To connect all these components we use jumper wires and a breadboard by following this schematics:

Connecting the LEDs and the Portenta

For the LED we can use any of the Portenta Breakout's 10 PWM Pins, in this case PWM 9. For the potentiometer, on the other hand, we can use one of the analog pins (A0 to A7) in order to read the potentiometer current value, in this example we use A7. The potentiometer also needs a 3.3V power source, which we take from the GPIO section on the Portenta Breakout, considering it being located most conveniently and close by. Eventually, potentiometer and LED have to be connected to GND to finalize the circuit.

After having connected everything, the Portenta H7 can be plugged into the computer using a USB-C® cable and we can start with the code.

4. The Arduino_PortentaBreakout Library

In the Arduino IDE we create a new Sketch and make sure we have selected the Arduino Portenta H7 on the M7 core. If you haven't used the Portenta H7 before, here you can find a detailed tutorial on how to get started with it.

In order to use the pins on the Portenta Breakout we need to install the Arduino_PortentaBreakout Library, which allows us to address all the pins located on the Carrier. Therefore, we need to download the library using the library manager, by going to Sketch > Include Libraries > Manage Libraries and search for Arduino_PortentaBreakout.

Once we have installed the Portenta Breakout library, we can import it to our Sketch.

1#include <Arduino_PortentaBreakout.h>

The library defines a number of constants that can be used to call desired pins, so are PWM pins for example called

PWM0
,
PWM1
, etc and analog pins are named
ANALOG_A0
,
ANALOG_A1
, etc. A complete list with all keywords can be found below in the "Next Steps" section.

We can now create a variable of the type

breakoutPin
and thereby specify the name of the pin we would like to use. This can either be a specific pin or we can use an array to save a selection of pins that we can then use throughout our sketch.

1breakoutPin pwmPins[] = {PWM0, PWM1, PWM2, PWM3, PWM4 , PWM5, PWM6 , PWM7, PWM8, PWM9};
2breakoutPin analogPins[] = {ANALOG_A0, ANALOG_A1, ANALOG_A2, ANALOG_A3, ANALOG_A4, ANALOG_A5, ANALOG_A6, ANALOG_A7};

5. PWM & LED

Once we have the pins in place, we can start controlling the LED we connected to

PWM9
by creating a byte variable containing our pin number and setting the
pinMode
within the
setup()
function.

1byte pwmPinNumber = 9;
2
3void setup() {
4 pinMode(pwmPins[pwmPinNumber], OUTPUT);
5}

The setup for using the LED is thereby complete, next is creating the

loop()
function, which as a first test contains two for loops to fade the LED's brightness up and down.

1void loop() {
2 for (int i = 0 ; i < 255; i++) {
3 Breakout.analogWrite(pwmPins[pwmPinNumber], i);
4 delay(5);
5 }
6 for (int i = 255; i > 0; i--) {
7 Breakout.analogWrite(pwmPins[pwmPinNumber], i);
8 delay(5);
9 }
10}

While uploading the sketch to the board, we should see the LED fading up and down in brightness. If that works as expected, we can proceed connecting the potentiometer to our code.

Analog Inputs Through the Portenta Breakout

Similar to the PWM code we need to define our pinNumber first, we will also create a variable to save the last value potentiometer value that has been read. Before the

setup()
function we therefore specify the following:

1byte analogPinNumber = 7;
2uint32_t lastPotentiometerValue = -1;

Within the

setup()
function we can then initialize the serial connection so we can write the incoming value to the serial monitor.

1Serial.begin(9600);
2while (!Serial);
3Serial.println("Initialized Breakout Carrier example sketch");

Once we completed the setup, we can then update the loop

loop()
function to read the incoming potentiometer value and write it to the Serial Monitor. We can also update the PWM setting for the LED instead of fading up and down on repeat, to follow the potentiometers value.

1void loop() {
2 uint32_t reading = Breakout.analogRead(analogPins[analogPinNumber]);
3
4 if (reading != lastPotentiometerValue) {
5 Serial.print("Potentiometer Value: ");
6 Serial.println(reading);
7 lastPotentiometerValue = reading;
8 }
9
10 uint32_t ledValue = map(reading, 0, 1023, 0, 255);
11 Breakout.analogWrite(pwmPins[pwmPinNumber], ledValue);
12}

Once the sketch is re-uploaded and we start the Serial Monitor, the Portenta starts reading the current potentiometer value and translates it into different brightness levels of our LED.

Conclusion

This sketch shows a simple usage of the Portenta Breakout in combination with the Arduino_PortentaBreakout Library to access and control some of the Portenta's High Density connectors. The library can thereby also be used for other protocols and pins such as I2C, UART and more. Within the "Next Steps" section below,there is a table of reference regarding how to address specific pins or what API to use.

Complete Sketch

1#include <Arduino_PortentaBreakout.h>
2
3breakoutPin pwmPins[] = {PWM0, PWM1, PWM2, PWM3, PWM4 , PWM5, PWM6 , PWM7, PWM8, PWM9};
4breakoutPin analogPins[] = {ANALOG_A0, ANALOG_A1, ANALOG_A2, ANALOG_A3, ANALOG_A4, ANALOG_A5, ANALOG_A6, ANALOG_A7};
5
6byte pwmPinNumber = 9;
7byte analogPinNumber = 7;
8uint32_t lastPotentiometerValue = -1;
9
10void setup() {
11 pinMode(pwmPins[pwmPinNumber], OUTPUT);
12 Serial.begin(9600);
13 while (!Serial);
14 Serial.println("Initialized Breakout Carrier example sketch");
15}
16
17void loop() {
18 uint32_t reading = Breakout.analogRead(analogPins[analogPinNumber]);
19
20 if (reading != lastPotentiometerValue) {
21 Serial.print("Potentiometer Value: ");
22 Serial.println(reading);
23 lastPotentiometerValue = reading;
24 }
25
26 uint32_t ledValue = map(reading, 0, 1023, 0, 255);
27 Breakout.analogWrite(pwmPins[pwmPinNumber], ledValue);
28}

Peripherals Table

This section includes a table of reference regarding the Arduino_PortentaBreakout Library's current peripheral names and APIs.

PERIPHERALSILKBREAKOUTuC PINAPINOTES
ETHERNET
D+ETHERNET_DPNot available as GPIO
D-ETHERNET_DNNot available as GPIO
GND
GND
L2ETHERNET_L2Not available as GPIO
L1ETHERNET_L1Not available as GPIO
C-ETHERNET_CNNot available as GPIO
C+ETHERNET_CPNot available as GPIO
B-ETHERNET_BNNot available as GPIO
B+ETHERNET_BPNot available as GPIO
A-ETHERNET_ANNot available as GPIO
A+ETHERNET_APNot available as GPIO
UART0Breakout.UART0HW flow control not supported
3V3
TXUART0_TXPA_0
RXUART0_RXPI_9
RTSUART0_RTSPI_10
CTSUART0_CTSPI_13
GND
UART1Breakout.UART1HW flow control not supported
3V3
TXUART1_TXPA_9
RXUART1_RXPA_10
RTSUART1_RTSPI_14
CTSUART1_CTSPI_15
GND
DISPLAY
D3PDISPLAY_D3PNot available as GPIO
D3NDISPLAY_D3NNot available as GPIO
D2PDISPLAY_D2PNot available as GPIO
D2NDISPLAY_D2NNot available as GPIO
D1PDISPLAY_D1PNot available as GPIO
D1NDISPLAY_D1NNot available as GPIO
D0PDISPLAY_D0PNot available as GPIO
D0NDISPLAY_D0NNot available as GPIO
CLKPDISPLAY_CLK_PNot available as GPIO
CLKNDISPLAY_CLK_NNot available as GPIO
GND
GND
CAN0Not connected
5V
TXCAN0_TX
RXCAN0_RX
GND
CAN1
5V
TXCAN1_TXPH_13
RXCAN1_RXPB_8
GND
I2C
3V3Breakout.I2C_1
GND
I2C1SDAI2C_SDA_1PB_7
I2C1SCLI2C_SCL_1PB_6
3V3Breakout.I2C_0
GND
I2C0SDAI2C_SDA_0PH_8
I2C0SCLI2C_SCL_0PH_7
3V3Breakout.I2C_2
GND
I2C2SDAI2C_SDA_2PH_12
I2C2SCLI2C_SCL_2PH_11
GPIOBreakout.digitalWrite
3V3
0GPIO_0PC_13
1GPIO_1PC_15
2GPIO_2PD_4
3GPIO_3PD_5
4GPIO_4PE_3
5GPIO_5PG_3
6GPIO_6PG_10
GND
GND
ANALOGBreakout.analoRead
GND
REFNANALOG_REFN
REFPANALOG_REFP
A0ANALOG_A0PA_0_C
A1ANALOG_A1PA_1_C
A2ANALOG_A2PC_2_C
A3ANALOG_A3PC_3_C
A4ANALOG_A4PC_2As GPIO internally connected to A2
A5ANALOG_A5PC_3As GPIO internally connected to A3
A6ANALOG_A6PA_4
A7ANALOG_A7PA_6
PWMBreakout.analogWriteMinimum frequency 770Hz
GND
PWM0PWM0PA_8
PWM1PWM1PC_6
PWM2PWM2PC_7
PWM3PWM3PG_7
PWM4PWM4PJ_11Shares timer with PWM8
PWM5PWM5PK_1
PWM6PWM6PH_15
PWM7PWM7PJ_7
PWM8PWM8PJ_10Shares timer with PWM4
PWM9PWM9PH_6
SPI0Not connected
3V3
CSSPI0_CS
CKSPI0_CK
CIPOSPI0_CIPO
COPISPI0_COPI
GND
SPI1Breakout.SPI_1
3V3
CSSPI1_CSPI_0
CKSPI1_CKPI_1
CIPOSPI1_CIPOPC_2
COPISPI1_COPIPC_3
GND
UART2Breakout.UART2
3V3
TXUART2_TXPG_14
RXUART2_RXPG_9
RTSUART2_RTSNot connected
CTSUART2_CTSNot connected
GND
UART3Breakout.UART3
3V3
TXUART3_TXPJ_8
RXUART3_RXPJ_9
RTSUART3_RTSNot connected
CTSUART3_CTSNot connected
GND
PCIENot connected
TXNPCIE_TXN
TXPPCIE_TXP
RXNPCIE_RXN
RXPPCIE_RXP
CKNPCIE_CKN
CKPPCIE_CKP
GND
RST
SAI
GND
D0SAI_D0PI_6
D1SAI_D1Not connected
FSSAI_FSPI_7
SCKSAI_SCKPI_5
3V3
I2S
GND
SDOI2S_SDOPI_3
SDII2S_SDIPI_2
WSI2S_WSPB_9
CKI2S_CKPD_3
3V3
CAMERA
D0PCAMERA_D0PPH_10
D0NCAMERA_D0NPH_9
D1PCAMERA_D1PPH_12
D1NCAMERA_D1NPH_11
D2PCAMERA_D2PPI_4
D2NCAMERA_D2NPH_14
D3PCAMERA_D3PPI_7
D3NCAMERA_D3NPI_6
CKPCAMERA_CKPPI_5
CKNCAMERA_CKNPA_6
HSCAMERA_HSPA_4
GND
PDMBreakout.PDM
GND
D0PDM_D0
D1PDM_D1Not connected
CKPDM_CK
SPDIFNot connected
GND
GND
RXSPDIF_RX
TXSPDIF_TX
USB0
GND
IDUSB0_IDNot connected
D-USB0_DNPA_12
D+USB0_DPPA_11
VBUS
USB1
GND
IDUSB1_IDPJ_6
D-USB1_DN
D+USB1_DP
VBUS
SD CARDAvailable as CORE peripheral
RSTNot connected
GND
WPSD_WPNot connected
NC
CDSD_CDNot connected
D0SD_D0PB_14
D3SD_D3PB_4
CMDSD_CMDPD_7
D2SD_D2PB_3
CLKSD_CLKPD_6
D1SD_D1PB_15
VSDSD_VSD
RTCBreakout.RTClock

Next Steps

More examples on how to use the Portenta Breakout can be found in the examples menu in the IDE after installing the library. They can be found under File > Examples > Arduino_PortentaBreakout.

Suggest changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. If you see anything wrong, you can edit this page here.

License

The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.