Controlling an Arduino with NodeJS

Ikechi Michael
2 min readFeb 14, 2019

Recently, I was introduced to a tool that helps me control my Arduino MEGA board with JavaScript.

Sup, Johnny?

Here’s how it works

  • Make sure you have your Arduino IDE setup for your environment.
  • In your Arduino IDE,
  • Go to Sketch → Include Library → Manage Libraries
  • Filter by “Firmata”
  • Choose the Latest Version (as at the time of writing, it’s 2.5.8)
  • Go to File → Examples → Firmata → StandardFirmataPlus
  • Make sure your Board is connected
  • Upload to the Board

This will load the Firmata program to your board. The Firmata program makes your board listen to instructions via the USB, and performs them.

Your NodeJS program sends the instructions via the USB, and listens for feedback.

Here’s the Kicker

If it works by sending instructions via USB and listening for feedback on the same port, then any programming language can be used to do the same.

And then I found them … a lot of implementations.

What’s the big deal?

If you have a have multiple Arduino boards working in a system, you don’t have to flash them with code updates every time you need to make it.

You could coordinate them via a Raspberry PI running your JavaScript, Java, C# or Python code, and make them work for you.

Also, here’s a programming language with Yoruba constructs. Imagine if we could control these Boards with it.

JS code to rotate a Servo to 30 degrees.

--

--

Ikechi Michael

I’ve learned I don’t know anything. I've also learned that people will pay for what I know. Maybe that's why they never pay.