# Communicating between Rpi \<-\> Pico via USB

**URL:** <https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294>\
**Category:** General\
**Created:** [7 February 2024 16:22 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294 "2024-02-07T16:22:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [7 February 2024 16:22 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/1 "2024-02-07T16:22:31Z")

</div>

Is there somewhere a "ready to use" code for Rasptberry Pico boards I could

- add names or Serial numbers to,
- than simply upload to multiple pieces, (changing the name / number)
- plug into any USB of the RPi, or a HUB attached to it,
- and with NodeRed could read the pin states or set them ?

Similar to Arduino + Firmata.  
_(I've searched the entire forum for topics about "Pico", but found no solution.)_

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 February 2024 16:33 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/2 "2024-02-07T16:33:04Z")

</div>

There is [RPIEasy](https://github.com/enesbcs/rpieasy) (its a take on ESPEasy)

Never used it, but I have used ESPEasy - an it is, as the name suggests easy to get off the shelf devices connected and working an reporting into Node-RED via MQTT.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [8 February 2024 23:52 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/3 "2024-02-08T23:52:26Z")

</div>

> [@Steve-Mcl](#):
>
> There is [RPIEasy](https://github.com/enesbcs/rpieasy) (its a take on ESPEasy)

**Sadly NO.** 👎 This is not going to work ever on the cheapest RPi Pico, only with more expensive Wifi or LAN capable devices.  
I've also asked the author about this, here is his [answer](https://github.com/enesbcs/rpieasy/issues/286#issuecomment-1934612897) :

> RPIEasy made for computers with Linux Operating System.  
> Raspberry Pi Pico is a microcontroller.  
> The LAN (W5100S-EVB-Pico) and the Wifi (Pico-W) variant will work with mpyeasy-async:  
> [GitHub - enesbcs/mpyeasy-async: Easy MultiSensor device based on MicroPython for Raspberry Pico (RP2) and ESP32](https://github.com/enesbcs/mpyeasy-async)  
> I saw a basic experimental USB RNDIS support to RP2040 in micropython but it never reached the stable edition, so its unlikely that i can add support for that in the near future:  
> [micropython/micropython@f782c8b](https://github.com/micropython/micropython/commit/f782c8b5a6d6e9f65c2a4feeaaa95a192ab2a123)

Interesting fact is that the mentioned half-finished code of that experimental USB RNDIS is massive!  
It's a pity it wasn't ever finished. ☹

Thanks for trying to help ! ❤

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [9 February 2024 00:49 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/4 "2024-02-09T00:49:28Z")

</div>

... I just had the crazy ide for searching for:

# "firmata pico"

keywords and found this commit:

> <https://github.com/firmata/ConfigurableFirmata/issues/115>
>
> I believe this to be the board definition for a standard Raspberry Pi Pico devic…e, it would be great if this could be incorporated:
> \`\`\`
> // Raspberry Pi Pico
> // https://datasheets.raspberrypi.org/pico/Pico-R3-A4-Pinout.pdf
> #elif defined(TARGET\_RP2040) || defined(TARGET\_RASPBERRY\_PI\_PICO)
> #define TOTAL\_ANALOG\_PINS 4
> #define TOTAL\_PINS 30
> #define VERSION\_BLINK\_PIN LED\_BUILTIN
> #define IS\_PIN\_DIGITAL(p) (((p) \>= 0 && (p) \< 23) || (p) == LED\_BUILTIN)
> #define IS\_PIN\_ANALOG(p) ((p) \>= 26 && (p) \< 26 + TOTAL\_ANALOG\_PINS)
> #define IS\_PIN\_PWM(p) digitalPinHasPWM(p)
> #define IS\_PIN\_SERVO(p) (IS\_PIN\_DIGITAL(p) && (p) != LED\_BUILTIN)
> // From the data sheet I2C-0 defaults to GP 4 (SDA) & 5 (SCL) (physical pins 6 & 7)
> // However, v2.3.1 of mbed\_rp2040 defines WIRE\_HOWMANY to 1 and uses the non-default GPs 6 & 7:
> //#define WIRE\_HOWMANY	(1)
> //#define PIN\_WIRE\_SDA (6u)
> //#define PIN\_WIRE\_SCL (7u)
> #define IS\_PIN\_I2C(p) ((p) == PIN\_WIRE\_SDA || (p) == PIN\_WIRE\_SCL)
> // SPI-0 defaults to GP 16 (RX / MISO), 17 (CSn), 18 (SCK) & 19 (TX / MOSI) (physical pins 21, 22, 24, 25)
> #define IS\_PIN\_SPI(p) ((p) == PIN\_SPI\_SCK || (p) == PIN\_SPI\_MOSI || (p) == PIN\_SPI\_MISO || (p) == PIN\_SPI\_SS)
> // UART-0 defaults to GP 0 (TX) & 1 (RX)
> #define IS\_PIN\_SERIAL(p) ((p) == 0 || (p) == 1 || (p) == 4 || (p) == 5 || (p) == 8 || (p) == 9 || (p) == 12 || (p) == 13 || (p) == 16 || (p) == 17)
> #define PIN\_TO\_DIGITAL(p) (p)
> #define PIN\_TO\_ANALOG(p) ((p) - 26)
> #define PIN\_TO\_PWM(p) (p)
> #define PIN\_TO\_SERVO(p) (p)
> \`\`\`
> I've done basic tests with the above using DIGITAL\_INPUT, DIGITAL\_OUTPUT and I2C.

So basically it's already Commited and theoratically ready to go, if we set !  
Just need to define : `TARGET_RP2040` or `TARGET_RASPBERRY_PI_PICO`

I'll give it a try as soon as I can. _(I just have to install everything first)_

* * *

# 2.

Also I've found this:

## Arduino-Pico

> **[Arduino-Pico — Arduino-Pico 5.4.3 documentation](https://arduino-pico.readthedocs.io/en/latest/index.html)**

Maybe it's worse investigating further, because it's very well documented and has many plugins and possibilities.

* * *

# 3.

And there is this:

> **[GitHub - execuc/u2if: USB to interfaces implementing MicroPython...](https://github.com/execuc/u2if)**
>
> USB to interfaces implementing MicroPython "machine" module functionalities on a computer.

Which could be very fast, if there is a bridge between NR and those Python codes running on the main PC.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [11 February 2024 15:05 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/5 "2024-02-11T15:05:57Z")

</div>

I'd like to announce:

# Arduino Node "works" with Rpi Pico.

1. First, you have to install Arduino IDE

2. Than add at board manager the _"Arduino Mbed OS RP2040 Boards"_  

3. and switch to that board

4. At Tools -\> Library Manager -\> Add "CofigurableFirmata"  

5. File -\> Open -\> [ConfigurableFirmata.ino](https://github.com/firmata/ConfigurableFirmata/blob/master/examples/ConfigurableFirmata/ConfigurableFirmata.ino)  
On Windows it is located at:  
`C:\Users\Dell\Documents\Arduino\libraries\ConfigurableFirmata\examples`

6. Comment unnecessary define lines: (I did 2, which I knew to be totally unnecessary: SPI + DHT)

```js
#define ENABLE_SERIAL
#define ENABLE_I2C
//#define ENABLE_SPI
#define ENABLE_ANALOG
#define ENABLE_DIGITAL
//#define ENABLE_DHT
#define ENABLE_FREQUENCY

```

I guess SERIAL and FREQ can be dropped too? But I did not try.

1. File -\> Save AS ... choose a name, you would like to name your board.  
do not use spaces..

2. Click Sketch -\> Verify/Comile [Ctrl + R]

3. Click Sketch -\> Export Compiled Binary [Ctrl + Alt + S]

4. Search the forder you have created by saving the projet -\> inside that there will be a subfolder called : `build`

5. Upload the `yourProjectname.ino.u2f` file to your _Rpi Pico_ by :

- hold down the boot button on the board
- while plugging into your PC / RPi
- and copy the file there. (it will auto restart)

## At Node-Red :

- install Arduino node explained here:  
[Interacting with Arduino : Node-RED](https://nodered.org/docs/faq/interacting-with-arduino)
- Set the PIN number to `25` to blink the LED. Shema:  
[https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html)
- add 2 inject (true + false) + 1 Arduino Out to test  
 ![kép](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d10fa5b1908c7ed7bb2b9dd914258c0f11a4d922.png)

### Import:

```auto
[{"id":"7543615fa0e73cb9","type":"tab","label":"Ardu-Pico teszt","disabled":false,"info":"","env":[]},{"id":"9af8c232996dc018","type":"arduino out","z":"7543615fa0e73cb9","name":"Pico Led","pin":"25","state":"OUTPUT","arduino":"f98aec68661d74af","x":240,"y":40,"wires":[]},{"id":"f1b4b3b7cb06d0ba","type":"inject","z":"7543615fa0e73cb9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":90,"y":40,"wires":[["9af8c232996dc018"]]},{"id":"97912eec4212270d","type":"inject","z":"7543615fa0e73cb9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":90,"y":80,"wires":[["9af8c232996dc018"]]},{"id":"7abbf06b7862da49","type":"catch","z":"7543615fa0e73cb9","name":"","scope":null,"uncaught":false,"x":80,"y":120,"wires":[["774edbaded6ee7d7"]]},{"id":"774edbaded6ee7d7","type":"debug","z":"7543615fa0e73cb9","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":240,"y":120,"wires":[]},{"id":"f98aec68661d74af","type":"arduino-board","device":"COM3"}]

```

### Warning:

... if You import this, the port is set to `COM3` ! You must edit that, or click the search button next to it.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [11 February 2024 15:10 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/6 "2024-02-11T15:10:31Z")

</div>

# But the problem is:

the same as 3 years ago with Arduino Nano + Firmata node:

- If I unplug the USB cable,
- and re-plug it again, _(or the USB HUB's power is disconnected for a second)_

## It will not reconnect !

(Unless the whole PC / NodeRed gets restarted)

This time I've tested it on Windows 11. So it's not board or OS related problem,  
but either `Firmata C` or the `NR node JS` code is fault.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [11 February 2024 16:12 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/7 "2024-02-11T16:12:51Z")

</div>

I've never found Windows USB com ports to be reliable - I had one fail on me yeterday when I unplugged a MIDI adaptor and plugged it back in again.

Wouldn't work - had to move it to another USB slot before it was re-recognised!

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [13 February 2024 16:23 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/8 "2024-02-13T16:23:58Z")

</div>

# Firmata + Arduino Node problems:

1. The "connected" / "connecting" status is totally **unreliable**.

- Saw many times **"connected"** but could not control it _(both on windows11 & Debian Bookworm)_
- other times it says: **"connecting"** (gray dot) but I could control it fine.

1. Could not control it using device-id. I've checked and copied the path at Debian:  
`/dev/serial/by-id/usb-Arduino_RaspberryPi_Pico_076461E6283367E3-if00`  
and it showed "connected", but could not blink the LED on port 25.

2. If I unplug the board, sometimes it does **crash the whole NR** service!

Looking at the [actual code](https://github.com/node-red/node-red-nodes/blob/master/hardware/Arduino/35-arduino.js), it's no wonder, because this simple 220 line `.js` file include only 1 `try .. catch` code at the Close function.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [23 February 2024 01:46 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/9 "2024-02-23T01:46:55Z")

</div>

Update:

# 1. Configurable Firmata

The **good** news is:

- Flashing multiple Pico boards with same `.uf2` firmware build creates different serial-IDs for each one. So they can be distuingushed ! 🙂  
`/dev/serial/by-id/usb-Arduino_RaspberryPi_Pico_076461E6283367E3-if00`  
`/dev/serial/by-id/usb-Arduino_RaspberryPi_Pico_076461E62D412FE3-if00`
- So it does not matter which USB is where you plug it in, it will be recognized by that ID.

The **Bad** news:

- Re/opened some tickets, to implement watchdog into Firmata firmware to make it stable. Nothing happened since 2016.

Also I did not find any info how it would be possible to thange those names of those boards.

# 3. [u2if](https://github.com/execuc/u2if)

After thorough investigation I have found out, that this firmware was not maintained after creation.

- None of the patches were commited
- It can handle only 1 board !  
_(Can not distuingish multiple Pico, always talking to the first one)_

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [4 May 2024 08:34 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/10 "2024-05-04T08:34:59Z")

</div>

... after further searching for any solutions:

# 4. GPIO ZERO / Remote GPIO

This code those not support the **Rpi Pico** Board, only the RPi + **RPi Zero**  
Opened a [ticket](https://github.com/gpiozero/gpiozero/issues/1127), got the answer from there.

# 5. Kaluma JS

> **[Kaluma](https://kalumajs.org/)**

It is a great and promising solution for easy programming a board, but it seems there is no "host controller" part for it, only a debugger. So currently only standalone apps can be developed with it.  
I've also opened a [ticket](https://github.com/kaluma-project/kaluma/issues/639) but nobody answered yet.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [5 May 2024 09:33 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/11 "2024-05-05T09:33:11Z")

</div>

# 6. [`node-red-mcu`](https://github.com/phoddie/node-red-mcu)

@ralphwetzel recommended me [here](https://discourse.nodered.org/t/nr2pico-u2if-python-to-js-help-wanted/87706/2) to use [`node-red-mcu-plugin`](https://flows.nodered.org/node/@ralphwetzel/node-red-mcu-plugin).

Similar to [Kaluma](https://kalumajs.org/), this could work only, if somebody would provide a "ready to use" example, how to communicate through the default USB with the "main NR".  
I've searched for it for several days, but concluded:

- USB is reserved for debugging + new firmware upload.
- Communicating with the Pico board would be possible through Wifi or Ethernet only (which the USB version of Pico board does not have).
- There is no `MQTT -> to serial` or `Webserver over serial` protocol built in, Moddable scripts assume a presence of ESP32 or similar chip.
- UART is reserved for PINs only.

Also it had to be written for both sides (host + board) laying down the communication protocol from scratch.  
Once uploaded the firmware to the board, it would be impossible to dynamically change a "mcu-node" to something else. (For example an IO pin to PWM) from host side.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 August 2024 09:33 UTC](https://discourse.nodered.org/t/communicating-between-rpi-pico-via-usb/85294/12 "2024-08-03T09:33:50Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
