2

I am using a Portenta Arduino Breakout Board that is connected to the Portenta H7 for a project I am working on. The project requires me to use three Adafruit Ultimate GPS sensors and connect each to its own UART ports on the Portenta breakout board. I am only using UART0, UART1, and UART2 (which are respectively Serial, Serial1, and Serial2).

To be able to get data, I've been using this example code from the Arduino IDE:

// Test code for Ultimate GPS Using Hardware Serial
// (e.g. GPS for Leonardo, Flora or FeatherWing)
//
// This code shows how to test a passthru between USB and hardware serial
//
// Tested and works great with the Adafruit GPS FeatherWing
// ------> https://www.adafruit.com/products/3133
// or Flora GPS
// ------> https://www.adafruit.com/products/1059
// but also works with the shield, breakout
// ------> https://www.adafruit.com/products/1272
// ------> https://www.adafruit.com/products/746
//
// Pick one up today at the Adafruit electronics shop
// and help support open source hardware & software! -ada

// what's the name of the hardware serial port?
#define GPSSerial Serial1

void setup() {
  // make this baud rate fast enough to we aren't waiting on it
  Serial.begin(115200);

  // wait for hardware serial to appear
  while (!Serial) delay(10);

  // 9600 baud is the default rate for the Ultimate GPS
  GPSSerial.begin(9600);
}


void loop() {
  if (Serial.available()) {
    char c = Serial.read();
    GPSSerial.write(c);
  }
  if (GPSSerial.available()) {
    char c = GPSSerial.read();
    Serial.write(c);
  }
}

This code works for Serial1, and I get data when I connect a GPS to the UART1 port of breakout board. When I call for Serial, or Serial2, changing #define GPSSerial Serial1 to #define GPSSerial Serial or #define GPSSerial Serial2 the code will upload with no errors, but I am not receiving any data from the GPS when it is connected to the respective UART port (UART0 and UART2).

I checked to see if the data is automatically only coming from UART1 port but it will not show anything when I am calling for Serial or Serial2, which should be expected.

Does anyone know how to deal with this issue? Could UART0 and UART2 ports not be transferring data to the Portenta H7 board which could be why I am not seeing any data?

Please let me know if I should clarify anything.

1 Answer 1

2

I just spent a day tracking down this same issue. The cause is that Arduino made an absolute mess of the naming conventions for these UART ports. Please see the table below. I created this table from the Portenta Schematic and the Breakout board Schematic.

Breakout Schematic P. Schematic @ J1,J2 P. Schematic @ Micro Micro Pin (tx,rx) pins_arduino.h
UART0 Serial2 UART4 (PA0,PI9) not defined
UART1 Serial1 LPUart (PA9,PA10) Maybe Serial 1?
UART2 Serial3 UART6 (PG14,PG9) not defined
UART3 Serial4 UART8 (PJ8,PJ9) Serial 3

Unfortunately as you can see, the built in serial definitions in pins_arduino.h are not going to work for the breakout board. (unless you use Serial 1 or Serial 3)

If you want to use these other serial ports, you need to define your own serial ports which actually isn't that hard. You just have to manually specify the pins and you're off.

#include "Serial.h"
UART UART0Breakout = UART(PA_0, PI_9);
UART UART2Breakout = UART(PG_14, PG_9);
void setup()
{
    UART0Breakout.begin(115200);
    UART2Breakout.begin(115200);
}

Hope this helps you! It certainly drove me mad for a while. Unfortunately the schematic I used for the breakout board was not nearly as nicely annotated as the one I linked here (I found it while writing this answer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.