Trouble Connecting SAMD51 using Arduino RPC Library

I’m using a Wio Terminal with the Arduino IDE and I’m getting an error when I try to compile the openmv_popular_features_as_the_control_device_example.

The Wio Terminal uses a SAMD51 device which does not use Software Serial but it does have a second Hardware Serial port that is used as a UART (Serial1). I tried uncommenting the line for hardware_serial1 but I get the following error: ‘rpc_hardware_serial1_uart_master’ in namespace ‘openmv’ does not name a type

Here is the block of code with the line I uncommented at the end:

// Uncomment the below line to setup your Arduino for controlling over a hardware UART.
//
// * baudrate - Serial Baudrate.
//
// NOTE: Master and slave baud rates must match. Connect master tx to slave rx and master rx to
// slave tx. Finally, both devices must share a common ground.
//
// WARNING: The program and debug port for your Arduino may be “Serial”. If so, you cannot use
// “Serial” to connect to an OpenMV Cam without blocking your Arduino’s ability to
// be programmed and use print/println.
//
// openmv::rpc_hardware_serial_uart_master → Serial
// openmv::rpc_hardware_serial1_uart_master → Serial1
// openmv::rpc_hardware_serial2_uart_master → Serial2
// openmv::rpc_hardware_serial3_uart_master → Serial3
//
openmv::rpc_hardware_serial1_uart_master interface(115200);

Should I be specifying this differently?

Thanks,
Ralph

I have some ifdefs in my code that enable the serial ports. If that does doesn’t define the right thing then the ifdefs won’t work.

Please let me know what board support packages and board versions I need for the Arduino IDE to compile this.

I am using the Seeed SAMD Boards package version 1.7.9
The specific board is the Seeeduino Wio Terminal.

There are 3 hardware serial ports configured
Serial for the monitor/upload port
Serial1 for the available UART ← this is what I am trying to use
Serial2 for the WiFi/BT interface

Thanks,
Ralph

Hi,

Just to let you know that I figured it out. On the SAMD parts (21 and 51) that I am using, SERIAL_PORT_HARDWARE is defined as Serial1.

Thanks,

Ralph

Ah, sorry, I forgot about this.

Then The default Serial should work for you.

Hi Nyamekye-

You might also want to add to the instructions which pins on the camera to use (or did I just totally miss them?). I looked at the pinout and didn’t realize there were two UARTs and I2C buses to choose from and so I was getting the “1 second and freeze” problem.

BUT, after a little more investigation, I did get it working with both hardware UART and I2C on a Pololu A-Star (Leonardo). it’s all pretty slick!

Good catch, that’s not in the documentation.

where did you make the code update? I am having a similar issue using ESP32.

Code

// Uncomment the below line to setup your Arduino for controlling over a hardware UART.
//
// * baudrate - Serial Baudrate.
//
// NOTE: Master and slave baud rates must match. Connect master tx to slave rx and master rx to
//       slave tx. Finally, both devices must share a common ground.
//
// WARNING: The program and debug port for your Arduino may be "Serial". If so, you cannot use
//          "Serial" to connect to an OpenMV Cam without blocking your Arduino's ability to
//          be programmed and use print/println.
//
// openmv::rpc_hardware_serial_uart_master -> Serial
// openmv::rpc_hardware_serial1_uart_master -> Serial1
// openmv::rpc_hardware_serial2_uart_master -> Serial2
// openmv::rpc_hardware_serial3_uart_master -> Serial3
//
openmv::rpc_hardware_serial2_uart_master interface(115200);

Error Message

Arduino: 1.8.15 (Windows Store 1.8.49.0) (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"


image_transfer_jpg_as_the_controller_device_example:60:9: error: 'rpc_hardware_serial2_uart_master' in namespace 'openmv' does not name a type

 openmv::rpc_hardware_serial2_uart_master interface(115200);

         ^

Because of the SERIAL_PORT_HARDWARE definition for the SAMD parts I was just able to use the default Serial, i.e. I changed the code to “openmv::rpc_hardware_serial_uart_master interface(115200);”.

Not sure if this fix will work with your ESP32 board. I found the definition for the Wio Terminal in the variant.h file.

Thanks, serial_uart_master does not work on my esp32. still have the same error message.

this is the ‘pins_arduino’ file in the variants folder for my doitESP32devkitV1.
Is my esp32 capable of running this code with UART?

#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>

#define EXTERNAL_NUM_INTERRUPTS 16
#define NUM_DIGITAL_PINS        40
#define NUM_ANALOG_INPUTS       16

#define analogInputToDigitalPin(p)  (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p)    (((p)<40)?(p):-1)
#define digitalPinHasPWM(p)         (p < 34)

static const uint8_t LED_BUILTIN = 2;
#define BUILTIN_LED  LED_BUILTIN // backward compatibility
#define LED_BUILTIN LED_BUILTIN

static const uint8_t TX = 1;
static const uint8_t RX = 3;

static const uint8_t SDA = 21;
static const uint8_t SCL = 22;

static const uint8_t SS    = 5;
static const uint8_t MOSI  = 23;
static const uint8_t MISO  = 19;
static const uint8_t SCK   = 18;

static const uint8_t A0 = 36;
static const uint8_t A3 = 39;
static const uint8_t A4 = 32;
static const uint8_t A5 = 33;
static const uint8_t A6 = 34;
static const uint8_t A7 = 35;
static const uint8_t A10 = 4;
static const uint8_t A11 = 0;
static const uint8_t A12 = 2;
static const uint8_t A13 = 15;
static const uint8_t A14 = 13;
static const uint8_t A15 = 12;
static const uint8_t A16 = 14;
static const uint8_t A17 = 27;
static const uint8_t A18 = 25;
static const uint8_t A19 = 26;

static const uint8_t T0 = 4;
static const uint8_t T1 = 0;
static const uint8_t T2 = 2;
static const uint8_t T3 = 15;
static const uint8_t T4 = 13;
static const uint8_t T5 = 12;
static const uint8_t T6 = 14;
static const uint8_t T7 = 27;
static const uint8_t T8 = 33;
static const uint8_t T9 = 32;

static const uint8_t DAC1 = 25;
static const uint8_t DAC2 = 26;

#endif /* Pins_Arduino_h */