Firefly 2.0 Now Available

Firefly 2.0 now available

Firefly connects Grasshopper to the physical world. It reads sensors and controls motors, lights, and other hardware on Arduino and similar microcontroller boards, live, right on the canvas. Firefly 2.0 is a complete rewrite, and you can install it today from the Rhino Package Manager.

Everything you relied on in the original Firefly is still here, and there is a lot that is new. It runs on Rhino 8 and Rhino 9, on both Windows and macOS. And it is built around a new universal firmware, so almost any board works without editing any Arduino code.


Firefly turns live sensor values into geometry. No code, just wires on the canvas.


What’s new at a glance

  • Runs everywhere: Rhino 8 and Rhino 9, on Windows and macOS. Firefly is fully cross-platform for the first time.
  • Works in both Grasshoppers: you get components for Grasshopper 1 (Rhino 8 and 9) and for Grasshopper 2 (Rhino 9), all from one install.
  • One firmware for every board: upload a single sketch to the board once, then set up each pin from Grasshopper as you build, with no code to edit and nothing to upload again.
  • Smarter more flexible components: every component adapts to the board you connect, so you see only the pins it can use and you decide what each one does.
  • A bigger toolkit for microcontrollers: new components for analog voltage output, sound, stepper motors, and signal smoothing.

Installing

Open Rhino’s Package Manager (run the _PackageManager command), search for Firefly, and install it. That single package includes builds for both Grasshopper 1 and Grasshopper 2.


One (new) firmware for every board

One of the biggest changes in this rewrite is under the hood, in the firmware that runs on the board.

The original Firefly used a single firmware, but it was rigid. It set aside a fixed group of pins for fixed jobs: a few analog inputs, a few digital inputs, a few outputs. In Grasshopper you reached those pins through board-specific components like Uno Read and Uno Write, each with a long list of inputs or outputs, and the board streamed all of those pins over the serial connection on every update, whether you were using them or not.

:information_source: Note: The original Firefly Firmata firmware is still available, now called Firefly Firmata Legacy, but for new projects I recommend the new firmware described next.

Firefly Firmata 2 works differently. Grasshopper now talks to the board using commands. It first asks the board what it can do (e.g. how many analog inputs it has, which pins support PWM, whether it has a DAC), then tells each pin what job to do as you build your definition. Nothing is fixed ahead of time, and the board only sends the values you actually use. Because the firmware adapts to whatever board it finds, one sketch now covers everything from an Uno to a Pico or an ESP32.

You upload the firmware to each board once. The first time you start Firefly, it copies the firmware sketch into your Arduino sketchbook for you (the Documents/Arduino folder), ready to open. To upload the firmware onto your board:

  1. Connect the board to your computer with a USB cable.
  2. Open the Firefly Firmata 2 sketch in the free Arduino IDE.
  3. In the Tools menu, choose your board and its serial port.
  4. Click the Upload button.

After that, Firefly connects to the board on its own whenever you use it within Grasshopper. You can now close the Arduino IDE and simply work with your microcontroller within the Grasshopper interface(s).

Boards that have tested with the Firefly Firmata 2.0: Arduino Uno (R3), Uno R4 WiFi and Minima, Mega 2560, Leonardo, Yún, Due, Raspberry Pi Pico, Pico W, Pico 2, and ESP32. Other compatible boards fall back to a generic profile.

Curious how it all works under the hood? The full Firefly Firmata 2 protocol is written up in PROTOCOL.md.


One universal sketch. Upload it once, and Firefly sets up the rest.

:information_source: Note: Do you have boards already running the original Firefly firmware? They still work. The Uno Read and Uno Write components (in the Legacy group) speak the old legacy Firefly Firmata protocol, so your earlier projects keep running.


Connect once, then wire anything

Every project starts with the Connect Board component. Point it at a serial port, and every other Firefly component can talk to that board. Because the components know what the board offers, choosing a pin is easy: Analog Read lists the analog pins, Analog Write lists the pins that support PWM, and so on. If a pin is already used somewhere else in your definition, Firefly marks it, so you will not assign the same pin twice by accident.


Components show only the pins your board supports, and flag any that are already in use.


The components

Legacy (for boards on the original firmware) Query Serial Ports, Uno Read, Uno Write

Serial Connect Board, Analog Read, Analog Write, Digital Read, Digital Write, DAC Write, Tone Write, Servo Write, Stepper Write, Stepper Jog, Serial Read, Serial Write

Signal (clean up and shape values) Exponential Moving Average, Simple Moving Average, Moving Median, Deadband, Slew Rate Limit, One-Euro Filter, Schmitt Trigger, Debounce, Ramp


The Firefly 2 toolkit in Grasshopper 2 (left) and Grasshopper 1 (right).


A few things worth a closer look

  • DAC Write gives you a true analog voltage, not PWM, on boards that have a DAC (the Due and the Uno R4). It is good for clean voltage references and smoothly changing signals.
  • Tone Write plays simple tones on any digital pin, for beeps, alarms, and feedback. You can hold a steady pitch, switch it on and off, or send a short beep that the board times on its own. Connect a small piezo speaker and it makes sound.
  • Stepper Write and Stepper Jog run stepper motors smoothly, with real acceleration and without freezing Grasshopper. They support step and direction driver boards (such as the A4988 and DRV8825) and 4-wire motors (such as the 28BYJ-48).
  • The Signal components turn noisy sensor readings into steady, usable values. You get moving averages, a median filter, deadband, slew limiting, the One-Euro filter, a Schmitt trigger, and debounce.
  • Ramp is a value that moves on its own over time. Send it into a Graph Mapper to shape it into any curve, then use it to fade an LED, sweep a servo, or drive any animation. There is no separate timer to wire up.


A noisy signal from a sensor cleaned up by the Signal filters.


Now working on macOS

Serial connections on the Mac used to be a headache. Firefly 2.0 works on macOS with no extra setup (on Rhino 8.33 and later, and on Rhino 9). Same components, same workflow.


Tell me what you think

Firefly 2.0 is a big rewrite, so I would love your feedback. Tell us about boards that act up, components that surprise you, or features you wish were there. Reply here, or open an issue on discourse and add the Firefly tag.

Hi..first of all thanks for this version…jst a doubt does this support PCA9685/I²C..coz i needed to connect multiple servos.

Firefly doesn’t support the PCA9685, or I²C in general, at the moment. Right now, Firefly drives servos directly off the board’s own pins through the firmware, so you’re limited to how many servo-capable pins the board has… and on an Uno, using servos even ties up the timer that pins 9 and 10 need for PWM.

The PCA9685 is a nice way around all of that since it handles PWM itself and lets you run 16 servos per board over I²C (and you can chain several boards together for more). The issue is that Firefly would need to learn to talk I²C and address that chip specifically, which it can’t do yet.

It is a nice request and I’ll put it on the list of possible future additions. The new Firmata 2 firmware was built to be extended, so perhaps adding an I2C device type is something that I can look into for a future update. Or, if you’re feeling so inclined, the Firmata is opensource and you could make a pull request if you want to take a stab at adding something yourself. Out of curiosity, how many servos are you trying to drive?

Hi Andy
planning for 4X4 servo matrix for a conceptual setup with my students on our clg wall-to make a conceptual wave type. the thing was. if I go beyond 4X4 the I am hitting Arduino’s limit and the delay is too much. So, I’ve switched to pi5. but for students it was little too much … so I instruct my students to use r7 to use firefly all dese years. coz firefly and fermata workflow did make them work on design more…and I2C is just a cool thing.

Have you considered chaining up pwm driver or using shift registers?

I’m curious to hear if people have any thoughts on the new Firefly Firmata 2. It’s quite different from the first version and is much more flexible. I’m curious to hear what people thing of this protocol.