firmata / arduino

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

Nano 33 IoT Missing in Boards.h #469

Closed mhamilt closed 3 years ago

mhamilt commented 3 years ago

The Nano 33 Iot is missing in Boards.txt. Given all the other SAMD21 boards are included, I'd assume there isn't anything fundamentally needing tweaked here.

As far as I can gather it just needs an addition of the following in Boards.h

// Arduino Nano 33 IoT
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
#define TOTAL_ANALOG_PINS       8
#define TOTAL_PINS              21 // 13 Digital + 8 Analog
#define IS_PIN_DIGITAL(p)       (((p) >= 2 && (p) <= 13))
#define IS_PIN_ANALOG(p)        ((p) >= 14 && (p) < 22)
#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) == SDA || (p) == SCL)
#define IS_PIN_SPI(p)           ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
#define IS_PIN_SERIAL(p)        ((p) == PIN_SERIAL1_RX || (p) == PIN_SERIAL1_TX) //defined in variant.h  RX = 13, TX = 14
#define PIN_TO_DIGITAL(p)       (p)
#define PIN_TO_ANALOG(p)        ((p) - 15)
#define PIN_TO_PWM(p)           PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p)         (p) // deprecated since v2.4
soundanalogous commented 3 years ago

Have you tested this with a Nano 33?

soundanalogous commented 3 years ago

Out of curiosity, what are you trying to accomplish using Firmata when the Nano 33 IoT board is already compatible with several Cloud services like Arduino IoT Cloud, Firebase, Azure, etc? As more boards are powerful enough to interact with Cloud Services, yet priced the same or less than boards like an Arduino Uno, I'd think the primary use case remaining for Firmata is simply using it over a UART for quick iterative prototyping.

mhamilt commented 3 years ago

@soundanalogous

Have you tested this with a Nano 33?

Yes, and everything seems to work, however I have not tested it extensively.

I'd think the primary use case remaining for Firmata is simply using it over a UART for quick iterative prototyping.

Correct, I am also using it for teaching purposes where students' first interaction with the Nano 33 will primarily be Serial comms based.

Since the MKR boards are already included in Boards.h

https://github.com/firmata/arduino/blob/d4cde66bdc0f7813a03bc296ec80a899c32d412a/Boards.h#L264-L265

and since there does not seem to be any adverse effects on the Firmata itself, I could not see the harm in including the Nano 33 IoT.

soundanalogous commented 3 years ago

I've added this board per https://github.com/firmata/arduino/pull/474, but do not have the physical board to verify with. I've only ensured it will compile StandardFirmata. Please let me know if you encounter any issues.

bilal697 commented 2 years ago

error "Please edit Boards.h with a hardware abstraction for this board"

Hello Anyone assist me to solve this error for Arduino Nano 33 BLE Sense.

agentff6600 commented 2 years ago

Hi,

as reported above it's pretty well with the StandardFrimata library on an Arduino Nano IoT 33. Later on I tried to compile the StandardFirmataBLE and I got this:

/private/var/folders/gf/tr166wdx0cbcrcgq6kl_6h7w0000gn/T/.arduinoIDE-unsaved2021928-963-1agdbak.j8af/StandardFirmataBLE/StandardFirmataBLE.ino: In function 'void setup()': /private/var/folders/gf/tr166wdx0cbcrcgq6kl_6h7w0000gn/T/.arduinoIDE-unsaved2021928-963-1agdbak.j8af/StandardFirmataBLE/StandardFirmataBLE.ino:772:3: error: 'stream' was not declared in this scope stream.setLocalName(FIRMATA_BLE_LOCAL_NAME); ^~~~~~ /private/var/folders/gf/tr166wdx0cbcrcgq6kl_6h7w0000gn/T/.arduinoIDE-unsaved2021928-963-1agdbak.j8af/StandardFirmataBLE/StandardFirmataBLE.ino:772:3: note: suggested alternative: 'strcat' stream.setLocalName(FIRMATA_BLE_LOCAL_NAME); ^~~~~~ strcat /private/var/folders/gf/tr166wdx0cbcrcgq6kl_6h7w0000gn/T/.arduinoIDE-unsaved2021928-963-1agdbak.j8af/StandardFirmataBLE/StandardFirmataBLE.ino: In function 'void loop()': /private/var/folders/gf/tr166wdx0cbcrcgq6kl_6h7w0000gn/T/.arduinoIDE-unsaved2021928-963-1agdbak.j8af/StandardFirmataBLE/StandardFirmataBLE.ino:806:8: error: 'stream' was not declared in this scope if (!stream.poll()) return; ^~~~~~ /private/var/folders/gf/tr166wdx0cbcrcgq6kl_6h7w0000gn/T/.arduinoIDE-unsaved2021928-963-1agdbak.j8af/StandardFirmataBLE/StandardFirmataBLE.ino:806:8: note: suggested alternative: 'strcat' if (!stream.poll()) return; ^~~~~~ strcat Multiple libraries were found for "Firmata.h" Used: /Users/windlin/Documents/Arduino/libraries/Firmata Not used: /Applications/Arduino.app/Contents/Java/libraries/Firmata Multiple libraries were found for "Servo.h" Used: /Users/windlin/Documents/Arduino/libraries/Servo Not used: /Applications/Arduino.app/Contents/Java/libraries/Servo Compilation error: Error: 13 INTERNAL: exit status 1

the issues with the libraries are resolved but I have absolutely no clue what to do about the "stream" scope.

Is there something you are working on that I missed?

I am also trying to understand what alternatives I have. Is it only possible to run it on the 3 boards listed in the BLEconfig file (Arduino 101, Redbear and Adafruit). Is there a way to use a UNO with a BLE shield?

pgrawehr commented 2 years ago

If you need to use another board than the ones mentioned in the BLEconfig file, you need to update the code for that particular board. You need to have a board-specific implementation of BLEstream. Typically, it's possible to derive the required code from an example for your particular board.

cstawarz commented 2 years ago

@agentff6600: I just submitted a PR (#485) that adds support for ArduinoBLE-compatible boards. My test device was the Nano 33 IoT. Be sure to install ArduinoBLE via the Library Manager before compiling.