Connecting RPi and Pico/RP2040

What are the options for connecting an RPi and an RP2040 board, with my code running on both? I have some Plasma 2040s and one idea I have is to change the lights based on music being played by the Pi. At a simple level, to set a sequence based on which track is being played (loud, fast music = bright lights), but even better would be if it could also alter throughout the piece, even if it’s not fast enough to flash on the beat. Speaking of which, I did consider some of the microphone breakouts for a standalone beat detection, but I don’t think any of them are compatible with MicroPython and I didn’t check CircuitPython so far.

I’m fine with programming (though not in C), but I’m not experienced in soldering so I’d prefer a solution that doesn’t involve soldering directly onto either board if possible. Connecting the two with a USB cable would be ideal, but I don’t know if the RP2040 ever communicates with via USB when it’s running code. And if I did that I guess all the power for the lights would need to come over the RPi’s USB port, so that’s not going to work. Could I rig something up via the QW/ST port? Or is there something to make connecting to the GPIO ports safer for someone who’s bad at soldering?

It should be theoretically possible to get the pico to run as a I2C slave, so you could connect via the QW/ST port, but I’ve not been able to find a good example to do it. But you could try here GitHub - vmilea/pico_i2c_slave: I2C slave library for the Raspberry Pi Pico

Also looking at the plasma photo, the pin holes don’t seem to line up well (see below), so a straight row of pins might be tricky

However, you should be able to configure the I2C_SCL and I2C_SDA as GPIO pins. From the schematic it looks like they are GPIO 0&1, then you could use something like this JST-SH cable - Qwiic / STEMMA QT compatible - Pimoroni and some female/female jumpers to connect to the main PI, however you’d only have 2 bits to play with, so that’s only 4 modes.

You can setup a Pico as a USB Hid device in Circuit Python. But communication will I believe be the wrong way. Pico talking to Pi but not listening to the Pi. Might be worth looking into anyway.

That slight offset of the solder pads is so the header doesn’t fall out while you solder it. ;)
It’s not enough that the pin alignment is affected.

1 Like

You could wire a GPIO pin on the Pi to the SWC pin on the Pico. A Low would be button pressed. You should be able to use the A0 A1 A2 SWC and SWD in the same manner.

You just have to make sure physically pressing Button C or D isn’t going to damage the Pi’s GPIO.
Don’t ever set the GPIO to 3.3V out. Use a Low / Ground for a button pressed signal, and floating / not grounded for button released.

Two more options: use a cheap HC-05 and configure Bluetooth (classic) between RPi and Pico. Or use a cheap ESP-01S to add wifi to Pico. I have used both options and both work very well. If you Google for HC-05, you will find many tutorials for other MCUs, but Pico is not different to others in this respect.

oh yes, and a third option: connect the rx/tx pins of the Rpi to the tx/rx pins of the pico and use serial communication. Setting up the RPi for this is a bit tricky, but again, Google is your friend.

Thanks for all the suggestions. I was doing some practice soldering and found my soldering iron tip is badly oxidised, so I’m going to see if I can restore that before I order anything; whether that’s a cable, radio module, or a new soldering iron (not sure where I’d find replacement tips for a Maplin own-brand iron…)

I’m tempted to start with something simple even if limited for now, like the JST-SH cable; then move onto something more advanced another time once I’ve had a bit more practice

I must admit that the title of your post is a bit misleading. You are referring to the plasma2040, which does not have UART-pins. So my solutions do not work.

You can stick with the qwicc, and create a little program with the plasma2040 as a slave as already suggested. There is example code around for this (in C and Python), just google for “i2c-slave pico”.
The RPi will be the I2C-master, and here you have tons of examples.

For the RPi side, you could use Sparkfun’s qwicc shim (available here in the shop). No soldering required ;-)

Ah sorry, I was trying to be generic with the title. Thanks again for the extra suggestion. I still want to practice my soldering anyway, so I’ll see if I need to buy a new soldering iron before I buy any extra parts. I placed about 3 orders during the 10th anniversary sale so I want to bundle any more orders together to save on the delivery charge :-D

Glad you have some ambition towards DIY projects, and also glad that you’re thinking of getting back to soldering - that is worth doing because it opens up a raft of possibilities for this and future projects. Go for it!
I don’t know the Plasma2040 - in particular, have they brought out the analog pins for you to access? If so, another direction to consider would be sending audio from the Pi’s 3.5mm jack (or an added pin, if you are using a Pi Zero - needs soldering!) to analog pins on the 2040 and doing the processing at the 2040 end.
Whatever data connection you use, shouldn’t you be powering the LEDs from an external source? I’d have thought you’d want that rather than from the Plasma2040, and definitely rather than hanging everything off the Pi

I don’t think the Plasma2040 exposes analog pins, but I’m not completely certain because I’m not used to looking at the schematics. The only reference to analog in the docs I saw was for the current draw sensor. But out of interest, can you use the Pi’s jack socket for data transfer when the Pi is also being used to play music using a USB soundcard?

As for powering the LEDs, I was just looking into what the current limit is on the Plasma 2040 but haven’t found anything; the docs on the current draw sensor are just talking about keeping the current within what your power supply can provide. I ran some quick tests with it tethered to another computer, but of course in real use at least the Plasma would be on its own power supply. I’ve got two types of LED: Flexible RGB LED Strip (aka NeoPixel, WS2812, SK6812) - Pimoroni and 5m Flexible RGB LED Wire - 50 RGB LEDs (aka NeoPixel, WS2812, SK6812) - Pimoroni. The LED strip has separate power cables, but the LED wire doesn’t. I’ll have to experiment a bit, but if I can run them off spare USB power supplies (I’ve got a spare Pi 4 power supply for one) then that keeps the wiring simple. I think the Plasma 2040 is designed to be simple to use for a simple use case, so it would make sense if it can handle a decent amount of power

Pins A0, A1 and A2 are analog

From your quote "the docs on the current draw sensor are just talking about keeping the current within what your power supply can provide it suggests they are expecting you to use a beefy power supply for the LEDs (and the board itself takes a negligible amount from that). OK.
But that’s a long way from powering the whole thing from a Raspberry Pi’s (fused) (low power) outputs. Rather, since you know the Pi itself consumes only a small, known amount (which model Pi is it?), suggest you also power the Pi from the LED power supply / Plasma2040 board (‘backwards’, if you like)

The Pi should be capable of that, but your software possibly not. Usual player software has an option for where you want its output sent? It would probably be easier to have a different sound source sent to the jack than to the soundcard (but that’s not what you are after!). If you need a USB soundcardto get higher quality output, you can tap into that to duplicate the same signal to the Plasma2040 (more soldering? Or use one of those 3.5 to 2x3.5 headphone Y splitters if it’s all on 3.5mm jacks, or similar if using phono).

Very rarely should you ever be soldering directly to boards, other than one-off attaching the GPIO pins themseves if you didn’t buy the board “with headers”.
Generally, use the female end of Dupont connecting wires pushed onto the header pins if you’ve just got one or 2 wires, or a female header if youve got lots (and then they don’t fall off or get mixed up)
If you haven’t already got something similar, see Maker Essentials - Mini Breadboards & Jumper Jerky - Pimoroni though possibly better to buy more wires and larger breadboards
For female headers and larger packs of wires, see Search - Pimoroni

Another option: don’t connect the RPi at all. Just add a simple microphone breakout to one of the three analog pins of the Plasma2040. Then read the mic-level and do anything you want with your LEDs to visualize the music. Again, you will find similar projects when you search for them. But you will of course need to adapt these examples to the specific hardware.

Something like: Adafruit Electret Microphone Amplifier - MAX9814

1 Like

I never said I was planning to run the whole thing tethered to a Pi… Only that I tested that all the LEDs in the set were working while tethered, by turning them on and off one at a time. Any real project will of course require a separate power supply. I don’t want to power the Pi from the Plasma 2040 either, they’ll be plugged in separately - I just want to get data from one to the other - but it’s a Pi 4.

Correction to my earlier post by the way, the LED wire does have separate power feed cables. It’s just that the LED strip has them at both ends, but the LED wire only has them at the controller end, which isn’t the end I picked up while taking a quick look.