Adafruit TinyUSB conflicting declaration


I want to write a custom USB device interface with all types of endpoint (interrupt, isochronous, and bulk) on an Arduino Nano 33 IoT. For this, I’m trying to set up the Adafruit TinyUSB library, with the Adafruit SAMD core. I got it working on the Arduino IDE (with some modifications to the core), but when I try to get it working in PlatformIO, I keep getting this error when compiling:

In file included from .pio/libdeps/nano_33_iot/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:45:0,
                 from src/main.cpp:30:
.pio/libdeps/nano_33_iot/Adafruit TinyUSB Library/src/arduino/Adafruit_USBD_Device.h:143:19: error: conflicting declaration 'USBDeviceClass TinyUSBDevice'
 #define USBDevice TinyUSBDevice
/home/warre/.platformio/packages/framework-arduino-samd/cores/arduino/USB/USBAPI.h:95:23: note: in expansion of macro 'USBDevice'
 extern USBDeviceClass USBDevice;
.pio/libdeps/nano_33_iot/Adafruit TinyUSB Library/src/arduino/Adafruit_USBD_Device.h:138:29: note: previous declaration as 'Adafruit_USBD_Device TinyUSBDevice'
 extern Adafruit_USBD_Device TinyUSBDevice;

I’m not sure what I’m doing wrong, as I don’t have much experience in PlatformIO.

My platformio.ini:

; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

board = nano_33_iot
framework = arduino
platform = atmelsam
platform_packages = framework-arduino-samd-adafruit @ ^1.7.13
lib_deps = 
	adafruit/Adafruit TinyUSB Library@^3.0.0
	adafruit/Adafruit NeoPixel@^1.12.0
build_flags = -DUSE_TINYUSB

The main.cpp file (A slightly modified version of the Adafruit WebUSB rgb example):

 Adafruit invests time and resources providing this open source code,
 please support Adafruit and open-source hardware by purchasing
 products from Adafruit!

 MIT license, check LICENSE for more information
 Copyright (c) 2019 Ha Thach for Adafruit Industries
 All text above, and the splash screen below must be included in
 any redistribution

/* This sketch demonstrates WebUSB as web serial with browser with WebUSB
 * support (e.g Chrome). After enumerated successfully, Browser will pop-up
 * notification with URL to landing page, click on it to test
 *  - Click "Connect" and select device, When connected the neopixel LED will
 * change color to Green.
 *  - When received color from browser in format '#RRGGBB', device will change
 * the color of neopixel accordingly
 * Note:
 * - The WebUSB landing page notification is currently disabled in Chrome
 * on Windows due to Chromium issue 656702 ( You have
 * to go to landing page (below) to test
 * - On Windows 7 and prior: You need to use Zadig tool to manually bind the
 * WebUSB interface with the WinUSB driver for Chrome to access. From windows 8
 * and 10, this is done automatically by firmware.

#include <Adafruit_TinyUSB.h>
#include <Adafruit_NeoPixel.h>

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
// use on-board neopixel PIN_NEOPIXEL if existed
#define PIN_NEOPIXEL 2

// How many NeoPixels are attached to the Arduino?
// use on-board defined NEOPIXEL_NUM if existed
#define NEOPIXEL_NUM 8

// When we setup the NeoPixel library, we tell it how many pixels, and which pin
// to use to send signals. Note that for older NeoPixel strips you might need to
// change the third parameter--see the strandtest example for more information
// on possible values.
Adafruit_NeoPixel pixels =

// USB WebUSB object
Adafruit_USBD_WebUSB usb_web;

// Landing Page: scheme (0: http, 1: https), url
// Page source can be found at
WEBUSB_URL_DEF(landingPage, 1 /*https*/,

void line_state_callback(bool connected);

// the setup function runs once when you press reset or power the board
void setup() {
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
  // Manual begin() is required on core without built-in support for TinyUSB
  // such as mbed rp2040
  // usb_web.setStringDescriptor("TinyUSB WebUSB");


  // This initializes the NeoPixel with RED


  // wait until device mounted
  while (!TinyUSBDevice.mounted())

  Serial.println("TinyUSB WebUSB RGB example");

// convert a hex character to number
uint8_t char2num(char c) {
  if (c >= 'a')
    return c - 'a' + 10;
  if (c >= 'A')
    return c - 'A' + 10;
  return c - '0';

void loop() {
  // Landing Page 7 characters as hex color '#RRGGBB'
  if (usb_web.available() < 7)

  uint8_t input[7];
  usb_web.readBytes(input, 7);

  // Print to serial for debugging
  Serial.write(input, 7);

  uint8_t red = 16 * char2num(input[1]) + char2num(input[2]);
  uint8_t green = 16 * char2num(input[3]) + char2num(input[4]);
  uint8_t blue = 16 * char2num(input[5]) + char2num(input[6]);

  uint32_t color = (red << 16) | (green << 8) | blue;

void line_state_callback(bool connected) {
  // connected = green, disconnected = red
  pixels.fill(connected ? 0x00ff00 : 0xff0000);;