Communicating between Rpi <-> Pico via USB

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.)

There is 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.

Sadly NO. :-1: 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 :

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
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

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. :frowning:

Thanks for trying to help ! :heart:

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

"firmata pico"

keywords and found this commit:

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

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:

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

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"


    Read more about it here:
    GitHub - firmata/ConfigurableFirmata: A plugin-based version of Firmata

  5. File -> Open -> 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)

#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 :

Import:

[{"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.

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.

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!

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, it's no wonder, because this simple 220 line .js file include only 1 try .. catch code at the Close function.

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 ! :slight_smile:
    /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

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)

... 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, got the answer from there.

5. Kaluma JS

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 but nobody answered yet.

6. node-red-mcu

@ralphwetzel recommended me here to use node-red-mcu-plugin.

Similar to Kaluma, 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.

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