Raspberry Pi Pico variant name

In my sketch I do conditional compilation based on the board attached. For example for the Portenta and Nano 33 BLE, I can use the following:

#if defined(ARDUINO_ARCH_NRF52840)
  //  Do Nano 33 BLE stuff
#elif defined(ARDUINO_PORTENTA_H7_M7)
  //  Do Portenta stuff
#else
  #error "Unsupported Hardware"
#endif  // target detection

I'm looking for a similar board variant name for the Pico. I had a look in the Arduino Core repository for the Pico but can't find it.

I've tried RASPBERRY_PI_PICO, but that doesn't work.

SafeString uses

#if defined(ESP_PLATFORM) || defined(ARDUINO_ARCH_ESP8266)
#include <pgmspace.h>
#elif defined(ARDUINO_ARDUINO_NANO33BLE) || defined(ARDUINO_ARCH_MBED_RP2040)|| defined(ARDUINO_ARCH_RP2040)
#include <api/deprecated-avr-comp/avr/pgmspace.h>
#else
#include <avr/pgmspace.h>
#endif

That covers Arduino and Earl's Pico packages
SafeString also uses

// This include handles the rename of Stream for MBED compiles
#if defined(ARDUINO_ARDUINO_NANO33BLE) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_MBED_RP2040) || defined(ARDUINO_ARCH_RP2040)
#include <Stream.h>
#elif defined( __MBED__ ) || defined( MBED_H )
#include <WStream.h>
#define Stream WStream
#else
#include <Stream.h>
#endif

and

// to skip this for SparkFun RedboardTurbo
#ifndef ARDUINO_SAMD_ZERO
#if defined(ARDUINO_ARDUINO_NANO33BLE) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_MEGAAVR) || defined(ARDUINO_ARCH_MBED_RP2040) || defined(ARDUINO_ARCH_RP2040)
namespace arduino {
#endif
#endif // #ifndef ARDUINO_SAMD_ZERO
1 Like

Thanks for the quick response @drmpf!

I hadn't seen SafeString before, I will have to consider it next time I do something String intensive.

I can confirm that both ARDUINO_ARCH_MBED_RP2040 and ARDUINO_ARCH_RP2040 works for the Pico. I haven't got one of the new Arduino Nano RP2040 boards so I can't test if it works on those or whether there is a way to differentiate between these boards.

Do you know in which file these constants are defined?

The Arduino one I got from looking the verbose compile output. Earl provided the other one (I could not see it in the compile line)
You can just try a compile without a board to see that they work.

1 Like