firmata / arduino

Firmata firmware for Arduino
GNU Lesser General Public License v2.1
1.54k stars 514 forks source link

Error compiling Firmata for board Arduino Nano Every #493

Closed ThorPrez closed 2 years ago

ThorPrez commented 2 years ago

Hi @all

Now it´s 2022 and there´s still a problem with Firmata. I got my Nano Every today and have changed the boards.h. I´m trying it with: elif defined(AVR_NANO_EVERY) || elif defined(ARDUINO_NANO_EVERY) and getting this fault: In file included from C:\Program Files (x86)\Arduino\libraries\Firmata/Firmata.h:17:0, from C:\Users\ARBEIT~1\AppData\Local\Temp\arduino_modified_sketch_434776\StandardFirmata.ino:28: C:\Program Files (x86)\Arduino\libraries\Firmata/Boards.h:870: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"

Is there actually a working solution ?

Thanks, Thorsten

pgrawehr commented 2 years ago

Hi @ThorPrez

Please do the following: In the Arduino IDE, go to File->Preferences and enable verbose mode for compiling. Then run a build and copy the whole build output to a file. Attach this file here. The build output will contain the exact name of the preprocessor definition that is to be used.

ThorPrez commented 2 years ago

Thanks for your feedback. Where exactly can I see the right name for the board ? Here are some examples of the output;

Arduino: 1.8.19 (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"

Using board 'nona4809' from platform in folder: C:\Users\Arbeitszimmer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7 Using core 'arduino' from platform in folder: C:\Users\Arbeitszimmer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7

Detecting libraries used... .... mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR ....

And here´s my edit:

// Arduino Nano Every elif defined(AVR_NANO_EVERY) || elif defined(ARDUINO_NANO_EVERY)

define TOTAL_ANALOG_PINS 8

define TOTAL_PINS 24 // 14 digital + 8 analog + 2 i2c

define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 21) // TBD if pins 0 and 1 are usable

define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)

define IS_PIN_PWM(p) digitalPinHasPWM(p)

define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS) // deprecated since v2.4

define IS_PIN_I2C(p) ((p) == PIN_WIRE_SDA || (p) == PIN_WIRE_SCL) // SDA = 22, SCL = 23

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) // deprecated since v2.4

pgrawehr commented 2 years ago

It's the parameters prefixed with "-D" (excluding the D itself). So try

#elif defined(AVR_NANO_EVERY) || defined(ARDUINO_NANO_EVERY) || defined(ARDUINO_AVR_NANO_EVERY)
pgrawehr commented 2 years ago

Make sure you don't miss the # before elif

ThorPrez commented 2 years ago

With # before Elif I'm having more faults

pgrawehr commented 2 years ago

Then you probably have a syntax error. Try the line exactly as I specified above.

ThorPrez commented 2 years ago

elif defined(AVR_NANO_EVERY) || defined(ARDUINO_NANO_EVERY) || defined(ARDUINO_AVR_NANO_EVERY)

It works, thanks. Now I can try to communicate with Pi and Arduino. But it seems, that Node-Red cannot communicate with the Nano Every. Serial node is working, Arduino node not.

pgrawehr commented 2 years ago

I have updated the source and after fixing the typo this works, so closing the issue.