The Kinoma Element is a small, JavaScript-powered IoT platform with 16 programmable pins. It’s inexpensive—an Element will set you back about twenty bucks or maybe a little more. It lacks the bells and whistles of its more beefy (and costly) brethren—you won’t find on-board USB, Ethernet, SDCard or other peripheral goodies—but it has the bits needed for IoT products in an efficient little package.

Chipmaker Marvell produces the Element, which features its Marvell MW302 System-on-a-Chip (SoC) (which in turn uses a 200MHz ARM Cortex M4). The board, enclosure, JavaScript runtime and framework software are open source.

Kinoma Element Kinoma Element

How it Works

The Element is an orchestration of flexibility within constraints. To run JavaScript natively with only 512KB RAM, the Element uses XIP (execute-in-place) technology to run JavaScript. It runs FreeRTOS, a streamlined and minimal, open-source operating system.

The Element’s operating voltage is 3.3V and you deploy to it using WiFi b/g/n or USB.

What’s Different About it

The Element comes packaged in an enclosure, which makes it look less like a board and more like a finished device (the enclosure design is open-source, too). Instead of having dedicated power pins, you can program any of the Element’s 16 pins (eight on each side of the board) as 3.3V or ground.

Kinoma uses its own (Apache-licensed) JavaScript engine, XS6, which, with minor exceptions, claims ES6 compatibility.

Kinoma Element Terminology

  • XIP: eXecute In Place: Technology that allows the Element to execute JavaScript without chewing up all of its (highly-constrained) memory.
  • BLL: “Blinking Light Library”—Reusable JavaScript that defines how a component (e.g. a particular serial sensor, a button) should behave within Kinoma JavaScript applications.
  • kinomajs: Optimized JavaScript runtime for Kinoma hardware
  • Kinoma Code: Kinoma’s IDE for configuring/provisioning, developing and deploying code to Kinoma hardware

Getting started

The Element comes solo, with no accessories. You’ll need to provide your own USB-micro cable. The Element is a new offering from Kinoma, which has a couple of impacts. Much of the documentation on Kinoma’s site is given over to the Create product and isn’t directly relevant to the Element (the Create has a display and runs full-blown Linux). Code examples for the Element are thin on the ground, and existing documentation can be hard to find.

After tooling around for a while, I came across their user forums and this sticky post about getting started, which was helpful. Most of the top-level content about the Element currently funnels toward a purchase page, meaning that finding useful pages like this and this can take some hunting. That’s not to say that there isn’t any documentation—it’s just hard to put one’s finger on all of it.

Unboxing and setup

Note: The Kinoma Code IDE has Mac-only support at this point. It’s ostensibly possible to work without it, deploying and managing programs on the Element using a command-line utility over telnet or a USB serial app. But it could be pretty finicky.

Getting my Element set up wasn’t completely smooth sailing—it required overnight intervention via their user forums (you can see my post here) and feeling my way through a couple of minor glitches after that. In the end, my process was (this is based on the steps in the quick-start guide):

  1. Download and install Kinoma Code IDE.
  2. Get Element set up on WiFi network.
  3. Apply firmware update. This failed for me (mentioned above). I was ultimately successful in getting the update to apply over USB tether (see above).

In all, the setup experience would have been speedy and easy if I hadn’t run into glitches and gaps in documentation.

Time: 1.5 days; active time: 2 hours

Developing for the Kinoma Element

Code projects for the Element are developed in the Kinoma Code IDE in JavaScript.

Application projects contain a project.json file which defines an entry point—that is, the script that will get executed on the device. It defaults to main.js. (The source for the first button-led example below shows basic structure of an application).

You can use Common-JS style modules and require statements to pull in other JS files in your projects and any of the Kinoma framework’s modules. The most relevant module is Pins, which provides basic IO support for the kinds of things you’d expect: digital and analog input and output; pulse-width modulation (PWM); serial (I2C).

Developing for the Kinoma Element involves creating or extending “BLLs” (Blinking-Light Libraries):

The code for each hardware module (sensor, LED, button, motor, etc) is contained in a JavaScript module called a BLL. BLLs communicate directly with hardware pins. The application communicates with the BLL using the Pins module. – http://kinoma.com/develop/documentation/element-bll/

An example of a custom BLL can be seen in the source from the I2C-websockets example below.

Code deploys to the Element over WiFi are refreshingly speedy, making quick iterations and testing less of a pain. The IDE has a GUI debugger, as well.

Representative Tasks and Applications

The following three representative tasks demonstrate typical hardware capabilities for IoT platforms:

  1. Button-controlled LED: Pressing a pushbutton (momentary switch) toggles an LED on and off. Uses digital input and digital output.
  2. Photoresistor and Fading LED: A “nightlight” that grows brighter as ambient light decreases (and vice versa). Uses analog input and PWD output.
  3. I2C magnetometer (compass) and websockets: A websockets-driven real-time display of compass headings. Uses serial (I2C) and software integration (websockets).

Button-Controlled LED

In the Kinoma Code IDE, one can create a new project from several pre-packaged examples. Turns out there is a perfect fit with the “button-led” example project (source here). I did not have to change any code, and it was fairly easy to parse what was going on.

Starting from a Pre-Packaged Example on the Kinoma Element

However, none of the Kinoma Element coding examples (neither as packaged in the IDE nor in the source github repo) contain wiring diagrams, so I was left to my own devices on how to wire the button for the particulars of the Element’s pins. I couldn’t locate hardware specs on any internal pull-up resistors on pins configured as digital inputs, so I had to guess a bit. After some trial and error, I got the example to work using a 10kΩ pull-down resistor.

Wiring Diagram for Button-LED on Kinoma Element

Time: 1.25 hours, mostly spent trying to determine best button wiring and how to use the Kinoma Code IDE

Analog Sensor and PWM (“Nightlight”)

Kinoma JS has built-in support for Analog pins that can be used to, unsurprisingly, read analog input. That part was pretty straightforward. There is also PWM) support that is easy enough to use.

Note: Kinoma JS values tend to be floating point numbers between 0 and 1. This includes analog input read values as well as PWM duty cycle values. This may seems a little different if you’re used to 8- (0 - 255) or 10-bit (0 - 1024) values for some of these things.

It took me some time to figure out the best resistor to use as a voltage divider for the photoresistor (I don’t know what the impedance is on the Element’s input pins). In the end, I got the best range (about 0.3 to 0.99) with a 4.7kΩ resistor.

Wiring Diagram for Photoresistor-PWM on Kinoma Element

Time: 35 minutes; 15 of them trying different resistors

Source

I2C Sensor with Websockets

To take readings from the HMC5883L triple-axis magnetometer (fancy words for: “a compass”), I had to write my own BLL. There is an I2C pin type that I built atop of, and I deeply sourced Rick Waldron’s great work on the the same sensor for Johnny-Five’s Compass class. (Here’s the source of my custom BLL).

KinomaJS has its own WebSockets module. It also has an HTTPServer module, but I was running low on time. Figuring out how to deploy an HTML document to the device as well as read and stream it out with the HTTPServer was certainly doable, but I elected to build a client-side HTML page (with WebSockets client) and have the Element just spin up a WebSockets server (not a full HTTP server).

Wiring Diagram for HMC5883L on Kinoma Element

The resulting web page (index.html) displays the compass’ heading, updating as frequently as twice per second if there is a change:

Compass Heading web display

Nothing too fancy, but it works!

Time: 2.75 hours, writing custom I2C handling for the HMC5883L; working through WebSockets and related documentation on Kinoma’s site; creating a web app

Source

The Verdict

The Element is a capable device for its constraints, and its support of nearly all of ES6 is forward-looking. The core available modules provide a relevant set of functionalities. You can’t lean on the Node.js ecosystem the way you can with some other platform options, but if you keep the logic light on the device itself, it ticks the key boxes for hardware support.

You’ll need some basic chops both in JS and basic electronics to get going here. There’s a fair amount of documentation on Kinoma’s site, but is has some shortcomings. It can be challenging to find the right documentation, and many gems are buried in user forum posts. The lack of non-Mac support for the IDE is certainly a hurdle for users of other platforms. If you’ve done any work in JavaScript on basic microcontrollers, the Element shouldn’t pose major challenges to you.

Once one is up to speed—the Element is configured correctly, firmware updated, core metaphors and structures understood—it can be quick to start churning out little apps. The photoresistor-to-PWM example was especially quick because there was no need to build specific support for an I2C device.

The Element is Good for…

  • JavaScript coders
  • Quick, basic hardware prototyping with the usual suspects (GPIO, serial, etc.)
  • Low power applications in small spaces
  • Penny-pinching (compared to other SBCs)
  • Mac users