Tessel: A First Look at JavaScript on Hardware

When a small red circuit board called the Tessel appeared on a crowd-funding site over a year ago, its promise to bring simplicity to hardware hacking caught my eye. It’s now on the market and, with a project percolating in my mind, I ordered one to play with. This post documents my initial impressions after two days of exploring it.

It seems like I’ve been hacking on hardware forever. I built cardboard box robots with crayons as a kid. Those cardboard boxes later got replaced by things like microprocessors and sonar sensors. Looking back over the last decade, it’s amazing how far hobbyist electronics have come: the hardware available today is far more accessible and much cheaper than in the past. And with Moore’s law, each generation of new hardware brings us more powerful chips to do our bidding.

At one time, we only had chips like the Motorola microprocessors and Atmel AVR chips. These devices came as raw chips, not full development boards, and it was up to the hobbyist developer to design a circuit board, wire up input/output pins, and build a circuit to flash code to the chip. Additionally, the lingua franca of these chips is C and sometimes assembly language, which have a steeper learning curve than other programming languages. The barrier to entry was high, and the devices required serious skills in electronics and low-level programming.

In the early 90’s came the BASIC Stamp, which used a dialect of the BASIC programming language to allow a whole generation of hobbyists to build robots and other projects.

In 2005, a team of educators in Italy released the Arduino, a cheap, easy-to-use microcontroller for the electronics education and DIY markets. The Arduino has friendly software and makes simple demos like blinking an LED understandable. With the Arduino and the growing maker scene, the market saw a huge change towards cheap, easy-to-use hardware. We’re still riding that wave today.

In 2012, a group looking to continue the UK’s educational computer tradition released the Raspberry Pi. The Pi was unique for its low price and the fact that it ran the Linux operating system, which meant users could program it in just about any language. The ARM processor used in the Pi was powerful but made cheap by the flood of cellphones and tablets powered by ARM CPUs.

Today, we now have a wide range of cheap, accessible hardware to use on projects. There’s powerful ARM chips that run Arduino tooling, dev boards that run Microsoft’s .NET platform, and more.

Enter the Tessel.

Over a year ago, a company called Technical Machine launched a crowd-funding effort for the Tessel. The Tessel’s main selling point was that it ran JavaScript on the device. As we’ll see later, using JavaScript opens up the hardware world to those with some experience coding for the web. Furthermore, the Tessel would ship with hardware modules to add neat sensing and output capabilities. Altogether, the platform looked very promising.

First Impressions

The Tessel is a compact, red, Altoids-tin sized circuit board. The silkscreened art on the circuit board is a nice touch, and I feel that it reflects how much design went into the device. Four pin headers are visible around its perimeter—these are the standardized connectors for the hardware modules. If you’re interested in playing with sensors, RFID, or relays, you don’t need to worry about breadboarding, wires, and discrete components. Instead, the standardized header allows you to just power down the board and slot in one of the modules. The Tessel team has released node.js libraries for each hardware module, eliminating the need to resort to low-level programming just to see data from sensors or to make motors spin.

For connecting other electronics, there’s also a GPIO (general-purpose input/output) header, which gives the Tessel similar expansion capabilities to an Arduino or a Raspberry Pi.

Setup

After unpacking my Tessel module, I followed the instructions at https://tessel.io/start to install the tooling and get my laptop set up.

The Tessel uses the npm package management tool for node.js to manage dependencies and install its tooling. The tessel command that you use to interact with the Tessel is itself a node.js application that runs on your development machine.

When you connect the Tessel board via USB, the tessel command finds it automatically. There’s no serial ports to configure or complicated device drivers to install. Though seemingly a minor feature, I found this to be a huge improvement over other boards that I’ve used in the past.

The last setup step was to update the Tessel’s firmware per the guide. The update was painless and a minute later I had a rebooted Tessel with the latest firmware.

Running Demos

One way that I like to approach learning a new tool or environment is to get a demo app running and tease the code apart to understand it. I started with the ‘blinky’ demo. I changed some values, refactored the style a bit, and kept iterating.

The biggest surprise to me was that the main selling point of the Tessel was true: you just write JavaScript. That is to say, the entire program was in JavaScript. It wasn’t a thin veneer over some low-level library. It didn’t force me to poke memory locations or do pointer math. They’ve gone to great lengths to ensure that there’s no “glue code” required or inconsistent experience in the interactions. Technical Machine’s written all the low-level code for you and wrapped it up in a nice library on npm. You use these libraries the same way you’d grab moment.js to use in your JavaScript application.

Specifically, each expansion board for the Tessel has its own npm module, and the library name is printed on the circuit board itself. Let’s say you want to set up the ambient sensor board to get light and sound data. You run npm install ambient-attx4 . Then, in your JavaScript file, you require the module and use it much as you’d expect other JS libraries:

ambient . on ( ' ready ' , function () { ... });

As you can see, the Tessel hardware libraries use a familiar on event binding pattern. You write callback functions to be called when these events are fired. This style should feel familiar to anyone who has had to write a click handler in JQuery or a web app on node.js.

I think this will be a huge boon to web developers and designers who want to make the leap to hardware, perhaps to build interactive art or visualize data they have online. The Tessel helps give them a familiar platform so that they can focus on their problem rather than low-level hardware concerns.

Functions familiar to JavaScript developers, such as console.log , have nice counterparts on Tessel. In this case, console.log outputs in your dev machine’s terminal while your code is running on the Tessel through tessel run . This makes debugging and logging from the device easy.

Wifi

Another nicety that the Tessel provides is an onboard wifi radio. The board doesn’t have to stay tethered to your development machine. With the wifi connected to your network, you can use standard node.js libraries for networking. The Tessel can serve websites, talk to remote servers and APIs, and generally do anything you might otherwise do with a computer on the internet with node.js.

Unfortunately, the tessel wifi command failed to connect the Tessel to my home wifi and our office wifi after repeated attempts. I’m keeping an eye on the Tessel forums for potential solutions and firmware updates, but my difficulties with wifi are a reminder that the Tessel is brand new hardware. The Tessel team has built tons of features for a device that didn’t exist a year ago, after all—help them out by reporting issues and work with them to improve the device and libraries. They seem open to feedback and helpful in diagnosing issues.

With the wifi capability, a Tessel could sit anywhere in range of your wifi and run off a standard cell phone wall charger connected to any number of sensors. Yet at the same time it could push data up to the cloud or serve web apps to phones and laptops on the wifi. Compared to an Arduino with a Wifi Shield or Ethernet Shield, the Tessel is far more capable. It has the processing power and the feature-packed libraries for it. Node.js is, after all, a great environment for building networked apps.

Hardware modules

I ordered three hardware modules with my Tessel: the ambient sensor board, the climate sensor board, and the relay board.

The ambient board measures light and sound levels with its sensors. There were some issues with the ambient board’s firmware that were solved by reading this forum thread. After that, the ambient board worked flawlessly.

After trying out the demo code for each board, I wanted to create a program that allowed me to visualize sound levels. My eventual goal is to hang a Tessel in a window at Bendyworks along with some sort of LED display and have it react to the sound during live concerts outside our office. (See: our ConcertCam post for more about the hardware we’ve built for concerts.)

To get started, I only needed to visualize the sound levels in my terminal. I thought that a histogram of asterisks, one reading per line, was the simplest demo to start with. After about 20 minutes of hacking together a simple script, I had my solution:

https://github.com/mathias/tessel-demos/blob/master/sound_histogram.js

What impressed me with developing for the Tessel is how quick I could take an idea to working demo with hardware. In that short period of time, I was able to throw in fun little hacks like a not-quite-rigorous feature scaling algorithm. The Tessel opens up opportunities for prototyping networked hardware projects quickly and in a way that should be accessible to my colleagues who mostly work on web apps.

What I didn’t run into were difficulties getting the data off the hardware or in diagnosing hardware problems. The tooling and hardware didn’t get in my way. The Tessel let me work at a level of abstraction just above the land of hardware and low-level programming where I can write solutions and see the results almost immediately.

Cost

In reviewing the Tessel, it is worth mentioning the cost. Tessel is a new board built by a new company. They don’t have the scale of some of the companies that build the cheapest microcontrollers.

Tons of development and design went into polishing the tooling and making the hardware modules beautiful. And it shows.

But the scale and effort also mean that the Tessel costs more than the competition. The base board with one hardware module is $99, which may make it out of range and inaccessible to some.

For comparison, the Arduino Uno costs around $25 and the Raspberry Pi costs $40. But remember: these boards aren’t nearly as featureful as the Tessel. To the Arduino, you’d have to add a WiFly Shield ($70) for wifi and a few sensors to start to match the Tessel’s capabilities. At that point, the cost of the Arduino solution is similar and the Arduino is not powerful enough to do common web app tasks like parse JSON. Having to integrate sensors and other components yourself on a breadboard comes with another cost: time spent. With the Raspberry Pi, you’d also have to add on a wifi adapter and some sort of USB hub and then configure it. Again, we’re running into costs not associated with the sticker price above.

So, if you ask me whether the Tessel is worth the price, I will tell you that it is pricey, but definitely worth it. And I expect that as Technical Machine ramps up production, their costs will also go down.

Final thoughts

There’s a lot of projects that I could see the Tessel being useful for. I think any web shop that knows JavaScript should consider one to get their projects off of screens and onto the physical space. There’s tons of fun ideas I could build with the few hardware modules I’ve purchased: a forecast.io API client that changes color when the weather changes, a build status indicator for Jenkins CI, or a Nest-like temperature and humidity monitor. Once we add the internet to basic electronics projects, we find all sorts of cool things we can do.

The Tessel has impressed me. I’m excited about what it will allow me to build. When new projects come in the door that might have some element of hardware prototyping, the Tessel will probably be the first thing I reach for. Overall, I see the growing and helpful community, good tooling, and simplicity as powerful reasons to consider it.

If you’re a JavaScript developer that wants to play with hardware, the Tessel is a great choice. If you’re looking to learn about hardware but don’t want to get bogged down in circuitry, it might also be a good start. But, if you’re looking to learn basic electronics or to learn low-level programming, there’s other options out there. Adafruit’s guides and kits are currently my favorite. The Arduino site itself is a great resource for getting started in microcontrollers and electronics. And don’t discount things like Lego Mindstorms.

(Disclaimer: I paid for the Tessel myself, and all views are my own and entirely unsolicited.)