I am trying to add a board abstract to Firmata board.h file to allow Firmata capabilities with Arduino UNO r4 wifi. But I can't seem to get the macro name correct, every time I try a new name it does not recognize the board.
the elif defined statement needs the correct macro name for the chip on the Arduino UNO r4 wifi.
#elif defined(RENESAS_RA4M1_firmata)
#define TOTAL_ANALOG_PINS 6
#define TOTAL_PINS 20 // 14 digital + 6 analog
#define VERSION_BLINK_PIN 13 // or any available pin for LED
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) <= 13) // Adjusted for digital pins
#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) <= 19) // Adjusted for analog pins
#define IS_PIN_PWM(p) (((p) == 3) || ((p) >= 5 && (p) <= 9) || ((p) >= 10 && (p) <= 13)) // Adjusted for PWM pins
#define IS_PIN_SERVO(p) (((p) == 3) || ((p) >= 5 && (p) <= 9) || ((p) >= 10 && (p) <= 13)) // Adjusted for servo pins
#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19) // Adjusted for I2C pins
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK) // Adjusted for SPI pins
#define PIN_TO_DIGITAL(p) (p) // Adjusted for digital pins
#define PIN_TO_ANALOG(p) ((p)-14) // Adjusted for analog pins
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) // Adjusted for PWM pins
#define PIN_TO_SERVO(p) PIN_TO_DIGITAL(p) // Adjusted for servo pins
Hi @matthewcern. For this specific application where the macros defined in the conditional block are related to the board's pin mapping, I think it will be most appropriate to use the board identification macro: ARDUINO_UNOWIFIR4
In case you are interested in knowing the origin of this macro, it is defined via a -D flag in the compilation command patterns:
Hi. I'm having what I think must be a similar problem.
Here's my error message:
In file included from C:\Users\johnn\OneDrive\Desktop\sketch_may4b\BlinkSerial\BlinkSerial.ino:1:0:
C:\Users\johnn\AppData\Local\Arduino15\libraries\Firmata/Boards.h:1123:2: error: #error "Please edit Boards.h with a hardware abstraction for this board" #error "Please edit Boards.h with a hardware abstraction for this board"
^~~~~
exit status 1
Compilation error: exit status 1
and I've tried to add various versions of what's here to the boards.h and nothing is working.
Thank you for this suggestion. I have gone ahead and tried adding this to the boards.h file and it returned that Compilation error: 'TOTAL_PORTS' was not declared in this scope I tried adding the TOTAL_PORTS to the boards.h file using 3 and then 1 but still returned the error.
I referred your comments in the following Arduino git issue for reference for now. If you have more intel on how to solve this that would be super welcomed
Thank you for your help, and hope that we can resolve this soon.
Support for the Uno R4 has been added to ConfigurableFirmata.
So I think the best solution is for you to use the "ConfigurableFirmata" library instead of the "Firmata" library. You can install the ConfigurableFirmata library via the Arduino IDE Library Manager (the library has support for UNO R4 WiFi starting from version 3.2.0). After installing the library, you'll find an example sketch that demonstrates the library's usage at File > Examples > ConfigurableFirmata > ConfigurableFirmata in Arduino IDE.
Just tried that out and I get the following error:
In file included from /private/var/folders/p4/9t0h4nrd12v46g5523pshb_h0000gn/T/.arduinoIDE-unsaved202488-62149-wdmcrc.xhxa/ConfigurableFirmata/ConfigurableFirmata.ino:93:0:
/Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/DhtFirmata.h:26:10: fatal error: DHT.h: No such file or directory
#include <DHT.h>
^~~~~~~
compilation terminated.
exit status 1
Compilation error: exit status 1
Just as you use libraries in your sketch code, libraries may use other libraries. When you are using one of the libraries that does this, it is necessary to install the other libraries on which the library depends in addition to the library you are using directly in your sketch.
The "ConfigurableFirmata" library has a dependency on the "DHT sensor library" library. You don't have the "DHT sensor library" library installed, so the compilation fails with this "No such file or directory" error.
You can solve it by installing the missing library.
I'll provide instructions you can follow to do that:
Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus to open the "Library Manager" view in the left side panel.
Type DHT sensor library in the "Filter your search..." field.
Scroll down through the list of libraries until you see the "DHT sensor library by Adafruit" entry.
You will see an "INSTALL" button at the bottom of the entry. Click the button.
An "Install library dependencies" dialog will open.
Click the "INSTALL ALL" button in the "Install library dependencies" dialog.
The dialog will close.
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 ...
Now try compiling or uploading your sketch again. Hopefully this time you won't have any errors and everything will work as expected.
In file included from /Users/jules/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.2.0/cores/arduino/Arduino.h:124:0,
from /Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/utility/Boards.h:23,
from /Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/ConfigurableFirmata.h:18,
from /Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/AnalogOutputFirmata.cpp:19:
/Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/AnalogOutputFirmata.cpp: In member function 'virtual boolean AnalogOutputFirmata::handlePinMode(byte, int)':
/Users/jules/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.2.0/variants/UNOWIFIR4/pins_arduino.h:93:30: error: 'IS_PIN_PWM' was not declared in this scope
#define digitalPinHasPWM(p) (IS_PIN_PWM(getPinCfgs(p, PIN_CFG_REQ_PWM)[0]))
^
/Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/utility/Boards.h:817:33: note: in expansion of macro 'digitalPinHasPWM'
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
^~~~~~~~~~~~~~~~
/Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/AnalogOutputFirmata.cpp:41:33: note: in expansion of macro 'IS_PIN_PWM'
if (mode == PIN_MODE_PWM && IS_PIN_PWM(pin)) {
^~~~~~~~~~
/Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/AnalogOutputFirmata.cpp: In member function 'virtual void AnalogOutputFirmata::handleCapability(byte)':
/Users/jules/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.2.0/variants/UNOWIFIR4/pins_arduino.h:93:30: error: 'IS_PIN_PWM' was not declared in this scope
#define digitalPinHasPWM(p) (IS_PIN_PWM(getPinCfgs(p, PIN_CFG_REQ_PWM)[0]))
^
/Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/utility/Boards.h:817:33: note: in expansion of macro 'digitalPinHasPWM'
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
^~~~~~~~~~~~~~~~
/Users/jules/Documents/Arduino/libraries/ConfigurableFirmata/src/AnalogOutputFirmata.cpp:50:7: note: in expansion of macro 'IS_PIN_PWM'
if (IS_PIN_PWM(pin)) {
^~~~~~~~~~
exit status 1
Compilation error: exit status 1
In the following Github Arduino Issue it seems that there was indication of compilation issues. Not sure if that is also relevant to this.
Now try compiling the sketch again. Hopefully this time it will work.
Explanation
In case you are interested in the boring details of why this was necessary, I'll provide an explanation below. If you aren't interested in such things then you can skip reading the rest of the post.
The problem is that there is a macro named IS_PIN_PWM in the UNO R4 WiFi board's Arduino core library:
but the ConfigurableFirmata library also uses a macro of the same name:
The person who added support for the UNO R4 WiFi board attempted to work around that macro name collision by undefining the core's macro before defining the library's macro:
However, that doesn't work because the digitalPinHasPWM macro uses the IS_PIN_PWM macro:
I worked around this by duplicating all the code from the core for the digitalPinHasPWM macro definition, including the code for the core's IS_PIN_PWM macro.
Thank you! And sorry for the slow response that totally worked for me also. Really appreciate the quick response and the thorough response and working resolution.
Do you know if this solution will get implemented into an updated release so that it becomes more of a permanent solution?
I chose this solution because it was the most simple for you to apply to the library. However, it is not an ideal solution because it duplicates code from the core. So I'm not sure it would be the best way for the library developers to implement a fix in their library.
I think that a better solution would be to change the name of the ConfigurableFirmata library's IS_PIN_PWM macro to something more unique (e.g., CONFIGURABLE_FIRMATA_IS_PIN_PWM) so that it won't collide with the macro of the same name in the UNO R4 WiFi board's core. However, this solution does require updating all references to the macro throughout the library so it is more complex to apply to the library.
My suggestion is for you to submit a bug report to the issue tracker of the ConfigurableFirmata library repository:
That will bring the bug to the attention of the library developers. You can add a link to this forum topic in the bug report so that the interested parties can see the discussion we had here. I already checked for an existing report in their issue tracker and didn't find one.
Thank You, same error, did this, more errors, then I removed others libraries and reopen the ConfigurableFirmata standard example file, now it's OK…
update : I try to find my arduino r4 wifi on my network… but I didn't uncomment one line : #define ENABLE_WIFI in ConfigurableFirmata.ino
Now it's
In file included from /Users/benoit/Documents/Arduino/libraries/ConfigurableFirmata/src/utility/WiFiClientStream.h:29:0,
from /Users/benoit/Documents/Arduino/ConfigurableFirmata_copy_20241003141329/ConfigurableFirmata_copy_20241003141329.ino:65:
/Users/benoit/Documents/Arduino/libraries/ConfigurableFirmata/src/utility/WiFiStream.h: In member function 'int WiFiStream::begin(char*, uint8_t, const char*)':
/Users/benoit/Documents/Arduino/libraries/ConfigurableFirmata/src/utility/WiFiStream.h:175:36: error: no matching function for call to 'CWifi::begin(char*&, uint8_t&, const char*&)'
WiFi.begin( ssid, key_idx, key );
^
In file included from /Users/benoit/Documents/Arduino/ConfigurableFirmata_copy_20241003141329/ConfigurableFirmata_copy_20241003141329.ino:64:0:
/Users/benoit/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.2.1/libraries/WiFiS3/src/WiFi.h:65:9: note: candidate: int CWifi::begin(const char*)
int begin(const char* ssid);
^~~~~
/Users/benoit/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.2.1/libraries/WiFiS3/src/WiFi.h:65:9: note: candidate expects 1 argument, 3 provided
/Users/benoit/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.2.1/libraries/WiFiS3/src/WiFi.h:76:9: note: candidate: int CWifi::begin(const char*, const char*)
int begin(const char* ssid, const char *passphrase);
^~~~~
/Users/benoit/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.2.1/libraries/WiFiS3/src/WiFi.h:76:9: note: candidate expects 2 arguments, 3 provided
/Users/benoit/Documents/Arduino/ConfigurableFirmata_copy_20241003141329/ConfigurableFirmata_copy_20241003141329.ino: In function 'void initTransport()':
/Users/benoit/Documents/Arduino/ConfigurableFirmata_copy_20241003141329/ConfigurableFirmata_copy_20241003141329.ino:157:7: error: 'class CWifi' has no member named 'mode'
WiFi.mode(WIFI_STA);
^~~~
/Users/benoit/Documents/Arduino/ConfigurableFirmata_copy_20241003141329/ConfigurableFirmata_copy_20241003141329.ino:157:12: error: 'WIFI_STA' was not declared in this scope
WiFi.mode(WIFI_STA);
^~~~~~~~
/Users/benoit/Documents/Arduino/ConfigurableFirmata_copy_20241003141329/ConfigurableFirmata_copy_20241003141329.ino:157:12: note: suggested alternative: 'PIN_SDA'
WiFi.mode(WIFI_STA);
^~~~~~~~
PIN_SDA
exit status 1
Compilation error: 'class CWifi' has no member named 'mode'