Firmata via USB on Uno R4 Wifi

Has anyone got the Firmata Library (Configurable or Standard) to run via USB on the Arduino Uno R4 WiFi board?
The sample codes are now compiling without errors, but I am not getting a “Firmata Ready” signal under vvvv on the host.
I would be grateful for any tips on what else I could try.
Thanks in advance!

Hi @ae172. Unfortunately I don't have any experience with vvvv, so I won't be able to provide assistance, but I did take a quick look into the subject just to figure out what it was. For the benefit of the other forum helpers, I'll share a link to the documentation of the Firmata support for the vvvv live visual programming environment:

Unless you are following a tutorial or reference that explicitly specifies the use of the ConfigurableFirmata library, I would recommend using the standard Firmata library for now, as that is what is specified in the vvvv documentation. The ConfigurableFirmata library's documentation warns:

https://github.com/firmata/ConfigurableFirmata#firmata-client-libraries

Not all client libraries officially support ConfigurableFirmata, but the protocol implementation is the same as for StandardFirmata, so most libraries should work.

There is one thing you should be aware of when using the standard Firmata Arduino library, which is that there is a bug in its code for determining which pins on the UNO R4 WiFi board have PWM (analogWrite) capability, as discussed here:

https://github.com/firmata/ConfigurableFirmata/pull/168#pullrequestreview-2304400666

However, that should only be a problem in certain specific use cases, but not if you aren't trying to use that specific functionality in your project.

I don't know what language you're using for your client application, but if you're comfortable with Python, you might want to consider Telemetrix. There are APIs for both a conventional threaded model and Python asyncio.

It supports USB/Serial and WIFI and BLE data transports out of the box.

It also comes with a complete set of examples.

Looks like nobody has done it successfully yet. Adding Arduino r4 wifi to Firmata board.h file

Great job of tracking down that related topic @ahsrabrifat. That discussion is now outdated as support for the UNO R4 WiFi has since been added to the library:

https://github.com/firmata/arduino/pull/509

https://github.com/firmata/arduino/pull/517

It should be noted that a new release of the library has not been made since that time, so it is necessary to download the latest development version of the Firmata library and install it manually, or using Arduino IDE's "Add .ZIP Library..." feature instead of the outdated release version you get from Boards Manager. Since @ae172 said "sample codes are now compiling without errors", I assumed they had already installed the development version, but it is worth verifying.

Apparently the libraries (Standard)Firmata and ConfigurableFirmata have also been updated in the IDE.
Originally there was no “Arduino Uno R4 Minima and WiFi” section in the Boards.h file of the libraries.
Now the boards are recognized when compiling, but via USB with vvvv as host, the code does not work, at least for me.

I have now found a working solution.
Version 2.5.7 of the (Standard)Firmata with a Boards.h file supplemented by the R4 boards works for me with Uno R4 Minima and WiFi board connected via USB with vvvv (beta or gamma) as host.

Thanks to all contributors!

To be clear, the 3.3.0 release version of the ConfigurableFirmata library that is available for installation via the Arduino IDE Library Manager does have UNO R4 WiFi support, but the 2.5.9 release version of the Firmata library that is the latest one available from Library Manager does not:

Great news! Thanks for taking the time to post an update.

Just out of curiosity, did you also try it with the ConfigurableFirmata library? If so, did you find that it doesn't work with ConfigurableFirmata even though it does with the Firmata library?

I think this information might be of interest to other Arduino community members who are using vvvv with the UNO R4 WiFi.

Okay, then I was wrong.
I thought version 2.5.9 of the Firmata Library had support for Uno R4 WiFi.
On the Github page of the project, the Boards.h was updated 8 months ago to include the Uno R4 boards. With this version of Boards.h the sample code for the Uno R4 WiFi board compiles without errors but does not work via USB with vvvv.

The ConfigurableFirmata (3.3.0) works for me on the Minima board, but not on the Uno R4 WiFi board (no “Firmata Ready” signal in vvvv).

Would you mind providing more detail about how you accomplished this "supplementation", for those of us who may not have prior experience manipulating the Boards.h file?

I know the question was asked of @ae172, and since they have the direct experience in the subject matter their information is very welcome.

However, I think it will be appropriate for me to explain that there is no need to modify the library. You only need to install the latest development version of the library (which has the changes made in the last year to add UNO R4 WiFi support) instead of the release version 2.5.9 from Library Manager (which is from 2022, before the time UNO R4 WiFi support was added). This will be much easier, faster, and less error prone than making the necessary modifications manually. I'll provide instructions you can follow to do that:

  1. Click the following link to open the library's GitHub repository homepage in your web browser:
    https://github.com/firmata/arduino
  2. Click the "Code ▾" button you see on that page.
  3. Select Download ZIP from the menu.
    A download of the ZIP file of the library will start.
  4. Wait for the download to finish.
  5. Select Sketch > Include library > Add .ZIP Library from the Arduino IDE menus.
    The "Select the zip file containing the library you'd like to add" dialog will open.
  6. Select the downloaded arduino-main.zip file from the dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. If you already have an installation of the library, a "Do you want to overwrite the existing library?" dialog will now open. Click the "YES" button in the dialog.
  9. Wait for the installation process to finish, as indicated by a notification at the bottom right corner of the Arduino IDE window:

    ⓘ Successfully installed library from ...

1 Like

I tried your (@ptillisch) solution, but unfortunately it didn't work for me.
I still had to exchange the "Arduino Uno R4 Minima and Wifi" section in Boards.h to get the StandardFirmata example to work with vvvv FirmataDevice Node in vvvv gamma and beta.

Here is the "Arduino Uno R4 Minima and Wifi" section for Boards.h which worked for me:

// Arduino UNO R4 Minima and Wifi
// The pinout is the same as for the classical UNO R3
#elif defined(ARDUINO_UNOR4_MINIMA) || defined(ARDUINO_UNOR4_WIFI)
#if defined(NUM_ANALOG_INPUTS) && NUM_ANALOG_INPUTS == 6
#define TOTAL_ANALOG_PINS       6
#define TOTAL_PINS              20 // 14 digital + 6 analog
#else
#define TOTAL_ANALOG_PINS       8
#define TOTAL_PINS              22 // 14 digital + 8 analog
#endif
// These have conflicting(?) definitions in the core for this CPU
#undef IS_PIN_PWM
#undef IS_PIN_ANALOG
#define VERSION_BLINK_PIN       13
#define IS_PIN_DIGITAL(p)       ((p) >= 2 && (p) <= 19)
#define IS_PIN_ANALOG(p)        ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)
// 25.03.: #define IS_PIN_PWM(p)           digitalPinHasPWM(p)
#define ARDUINO_IS_PIN_PWM(x)   (((x & PIN_USE_MASK) ==  PIN_PWM_GPT) || ((x & PIN_USE_MASK) ==  PIN_PWM_AGT))
#define ARDUINO_digitalPinHasPWM(p) (ARDUINO_IS_PIN_PWM(getPinCfgs(p, PIN_CFG_REQ_PWM)[0]))
#define IS_PIN_PWM(p)           ARDUINO_digitalPinHasPWM(p)
// END 25.03.
#define IS_PIN_SERVO(p)         (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS)
#define IS_PIN_I2C(p)           ((p) == 18 || (p) == 19)
#define IS_PIN_SPI(p)           ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
#define PIN_TO_DIGITAL(p)       (p)
#define PIN_TO_ANALOG(p)        ((p) - 14)
#define PIN_TO_PWM(p)           PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p)         ((p) - 2)

OK, I see that you have introduced the fix for the bug I mentioned in post #2 (incorrect determination of which pins have PWM capability):

--- a/Boards.h
+++ b/Boards.h
@@ -464,8 +464,17 @@ writePort(port, value, bitmask):  Write an 8 bit port.
 #define TOTAL_ANALOG_PINS       8
 #define TOTAL_PINS              22 // 14 digital + 8 analog
 #endif
+// These have conflicting(?) definitions in the core for this CPU
+#undef IS_PIN_PWM
+#undef IS_PIN_ANALOG
 #define VERSION_BLINK_PIN       13
 #define IS_PIN_DIGITAL(p)       ((p) >= 2 && (p) <= 19)
+#define IS_PIN_ANALOG(p)        ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)
+// 25.03.: #define IS_PIN_PWM(p)           digitalPinHasPWM(p)
+#define ARDUINO_IS_PIN_PWM(x)   (((x & PIN_USE_MASK) ==  PIN_PWM_GPT) || ((x & PIN_USE_MASK) ==  PIN_PWM_AGT))
+#define ARDUINO_digitalPinHasPWM(p) (ARDUINO_IS_PIN_PWM(getPinCfgs(p, PIN_CFG_REQ_PWM)[0]))
+#define IS_PIN_PWM(p)           ARDUINO_digitalPinHasPWM(p)
+// END 25.03.
 #define IS_PIN_SERVO(p)         (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS)
 #define IS_PIN_I2C(p)           ((p) == 18 || (p) == 19)
 #define IS_PIN_SPI(p)           ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)

This also fixes an equivalent bug related to determining which pins have analog (ADC) capability, which I was not aware of.