How it Works
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 Element Terminology
- Kinoma Code: Kinoma’s IDE for configuring/provisioning, developing and deploying code to Kinoma hardware
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):
- Download and install Kinoma Code IDE.
- Get Element set up on WiFi network.
- 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
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):
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:
- Button-controlled LED: Pressing a pushbutton (momentary switch) toggles an LED on and off. Uses digital input and digital output.
- Photoresistor and Fading LED: A “nightlight” that grows brighter as ambient light decreases (and vice versa). Uses analog input and PWD output.
- I2C magnetometer (compass) and websockets: A websockets-driven real-time display of compass headings. Uses serial (I2C) and software integration (websockets).
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.
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.
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”)
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.
Time: 35 minutes; 15 of them trying different resistors
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
The resulting web page (
index.html) displays the compass’ heading, updating as frequently as twice per second if there is a change:
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
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.
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…
- 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