Getting Started with the Arduino RP2040 Connect and the Arduino IDE
2022-01-10 | By Maker.io Staff
The Arduino RP2040 Connect is an IoT development board that comes in the well-known Arduino Nano form factor. Recent articles investigated the main features of the RP2040 Connect and how to program it using OpenMV, a popular MicroPython IDE. This article outlines programming the RP2040 Connect using C++ and the classic Arduino IDE.
The Arduino RP2040 Connect is a fantastic IoT development board that features a uBlox NINA module.
Before You Get Started
Start by downloading the most recent version of the Arduino IDE. If you’ve previously uploaded the OpenMV firmware and MicroPython interpreter to your RP2040 Connect board, make sure that you put the development board into bootloader mode before uploading an Arduino sketch. Otherwise, the Arduino IDE won’t detect the board. Note that this step is only necessary if you’ve previously flashed the OpenMV firmware. You only need to do this once and only if you’ve previously uploaded custom firmware to the board. By default, the Arduino IDE detects the Arduino RP2040 Connect as soon as you connect it to your PC without you having to take any further action.
Setting up the Arduino IDE
The Arduino RP2040 Connect board runs on the Mbed OS core for Nano form factor Arduinos. Therefore, you have to install the board support files before uploading a sketch to your Arduino RP2040 Connect. To get started, navigate to the Arduino IDE’s boards manager using the app’s top menu bar:
Open the boards manager using the Arduino IDE’s top menu bar.
In the boards manager pop-up window, search for “Arduino Mbed OS Nano Boards” and then install the following standalone package:
Install the highlighted package in the boards manager window.
Do not install the deprecated package. Once done, select RP2040 Connect from the list of supported devices in the Arduino IDE:
Select RP2040 Connect from the list of supported devices in the Arduino IDE.
Upload an Arduino Sketch to the RP2040 Connect
Instead of using the simple blink example that typically runs on every Arduino board out of the box, I ran a test to check a few more advanced features of the RP2040 with the following short Arduino sketch:
#include <Arduino_LSM6DSOX.h> #include <WiFiNINA.h> float x, y, z; void setup() { IMU.begin(); // Set up the RGB LED pins pinMode(LEDR, OUTPUT); pinMode(LEDG, OUTPUT); pinMode(LEDB, OUTPUT); } void loop() { if (IMU.gyroscopeAvailable()) IMU.readGyroscope(x, y, z); analogWrite(LEDR, abs(x) - 127); analogWrite(LEDG, abs(y) - 127); analogWrite(LEDB, abs(z) - 127); }
This short test script uses the built-in IMU and RGB LED of the Arduino RP2040 Connect. The setup method initializes the IMU and the onboard LED. Then, the loop function reads the gyroscope data in every iteration and stores the results in the three float variables defined at the top of the sketch. Then, the Arduino sets the RGB values of the LED relative to its orientation in 3D space.
I subtracted 127 to reduce the brightness of the LED, and I used the absolute value returned by the IMU. Note, you have to install the LSM6DSOX library using the Arduino IDE’s built-in library manager to enable the board to communicate with the IMU. Also, include the WiFiNINA library, as the RGB LED is connected to the WiFi module.
You can find a complete API of supported libraries, the RP2040 pinout, and more practical tips and tricks on this official page.
Summary
The Arduino RP2040 Connect is a versatile IoT development board based on the RP2040 microcontroller. Besides MicroPython, you can also use C++ with the Arduino IDE to program the Arduino RP2040 Connect development board. To do so, use the IDE to install the board support files for the Mbed OS Arduino Nano boards. Once done, you can upload sketches to your Arduino RP2040 like you would do with any other Arduino. Note that you have to put the RP2040 Connect into bootloader mode when you first upload a sketch to it if you’ve previously installed the OpenMV MicroPython interpreter on the development board.
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum