6.10. Adding electronics

This section gives tips for how to expand the 3pi+ 2040 with additional electronics.

Free I/O pins

The pins GP24, GP27, GP28, and GP29 are free I/O pins that are not used for anything on the 3pi+ 2040. Each of these pins is accessible on the mid expansion header, and can be used as a general purpose input, digital output, or PWM output. Three of the pins (GP27, GP28, and GP29) can be used as analog inputs.

The 3pi+ 2040 has several traces that you can cut to disconnect I/O pins from their on-board functions, freeing them up for other uses. The front expansion header contains cuttable traces for the pins used by the IR sensors: GP16, GP17, GP18, GP19, GP20, GP21, GP22, GP23, and GP26. In the OLED display area, there is a cuttable SMT jumper for GP7 labeled “7 = Buzzer” and one for GP26 labeled “BAT LEV = 26”. The RP2040 functions available on these pins are documented in Section 6.9.

Adding an I²C device

There are two types of devices that can connect to an I²C bus: a controller is a device that initiates transfers of data, generates clock signals, and terminates transfers, while a target is a device that is addressed by a controller.

You can add I²C devices to the 3pi+ 2040 by connecting the SDA pin of each device to GP4 and connecting the SCL pin of each device to GP5. Both of those pins are available on the mid expansion header. These are the same pins used by the inertial sensors documented in Section 6.6, so the I²C addresses of any targets you add here must be different than the I²C addresses of the inertial sensors. The LIS3MDL uses address 30 (0b0011110) and the LSM6DSO uses address 107 (0b1101011). The GP4 and GP5 pins are each pulled up to 3.3 V with a 10 kΩ resistor.

The RP2040 acts as an I²C controller on the GP4/GP5 bus when it accesses the inertial sensors. If you are adding another I²C controller to the bus, it is probably best to avoid the complexity of a multi-controller setup and instead configure the RP2040 to be an I²C target (or not use the bus at all).

Another option is to add an I²C device by connecting its SDA pin to GP28 and connecting its SCL pin to GP29. These are free I/O pins that are not used for anything on the 3pi+ 2040. However, note that if you want to use hardware I2C on these pins, you would need to use the RP2040’s I2C0 module, which is the same one used for the inertial sensors on GP4 and GP5. To work around this conflict, you could use a software I²C implementation for one of the busses or consider adding code to change the I2C0 pin function selections dynamically.

Any I²C devices you add must be compatible with the 3.3 V levels used by the RP2040 or use a level shifter.

Adding a UART serial device

The RP2040’s UART0 module is available on the free I/O pins GP28 (TX) and GP29 (RX). Alternatively, if you remove the OLED display, you can use UART0 on GP0 (TX) and GP1 (RX). Any UART serial devices you add must be compatible with the 3.3 V levels used by the RP2040 or use a level shifter. The RP2040’s I/O pins are not 5 V tolerant.

Adding an SPI device

If you remove the OLED display, you can use the RP2040’s SPI0 module on pins GP0 (RX), GP1 (CSn), GP2 (SCK), and GP3 (TX). The RGB LEDs typically use SPI0, but it is possible to work around this conflict by changing the SPI0 pin function selections dynamically, and the libraries we provide for the 3pi+ 2040 OLED and RGB LEDs show how to do this.

Another option is to disconnect GP26 from the line sensor emitter control line (DNE) by cutting a trace on the front expansion header. Then you can use the RP2040’s SPI1 module on pins GP26 (SCK), GP27 (TX), GP28 (RX), and GP29 (CSn). The RP2040 normally uses GP26 to control the line sensor emitters and read the battery voltage, so if you need those functions then you would have to find an alternative way to perform them.

Related Products

3pi+ 2040 Robot - Standard Edition (30:1 MP Motors), Assembled
3pi+ 2040 Robot - Turtle Edition (75:1 LP Motors), Assembled
3pi+ 2040 Robot - Hyper Edition (15:1 HPCB Motors), Assembled
3pi+ 2040 Robot Kit with 30:1 MP Motors (Standard Edition Kit)
3pi+ 2040 Robot Kit with 75:1 LP Motors (Turtle Edition Kit)
3pi+ 2040 Robot Kit with 15:1 HPCB Motors (Hyper Edition Kit)
3pi+ 2040 Control Board
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors