Developing apps for wearables and the IoT using JavaScript

How JS developers can apply their skills to make their own applications for wearbales and IoT such as the Pebble Watch, Ninja Blocks or other devices

There’s more to JavaScript than just the Web; it’s making its way into wearables and Internet of Things devices, according to Web developer and SitePoint author Patrick Catanzariti.

Catanzariti spoke with Techworld Australia about his work using JavaScript to develop for Pebble Watch and Ninja Blocks, as well as the pros and cons of working with the language for wearables and Internet of Things devices.

Catanzariti, who this week spoke the YOW! Connected conference in Melbourne, said that there are more wearable devices and IoT applications that use JavaScript.

Microcontroller Tessel, for example, which came out mid-2014, runs completely off JavaScript. The Pebble Watch also has its PebbleKit Javascript Framework, which was released in January 2014 as part of the Pebble SDK 2.0.

“It’s a good sign that things are starting to move in that direction. It’s going to be a trend where we are moving towards either being able to do everything in JavaScript on the device or [use it to] just accompany things,” he said.

Some of Catanzariti’s recent JavaScript-based applications include a ‘find me a Starbucks’ app for the Pebble Watch and an app that detects and responds to tweeted words for the Ninja Block.

The ‘find me a Starbucks’ app uses the JavaScript framework for the Pebble location API and connects to Foursquare to help the user find a Starbucks coffeehouse close to their location.

“One of the things that was really great about using JavaScript for it was that it has the ability now to have a single Web page when somebody wants to change their settings on their Pebble application on their phone,” Catanzariti said.

“Rather than having to install, say, an Android application on their phone to deal with settings for a Pebble app, they can just go to a one-page website, which Pebble redirects them to automatically. So you can change it from Starbucks to find me McDonalds instead, and it will send off the keyword ‘McDonalds’ to Foursquare and start finding nearest one.”

The app that detects and responds to tweeted words uses the JavaScript API library for Ninja Blocks and connects with Twitter.

“I had it set up to turn on three different light sirens, depending on what people would tweet at me. So the red siren would go off any time someone tweeted the word ‘red’ at me, and the blue one would go off anyone tweeted the word ‘blue’ at me.”

Pros and cons of JavaScript for wearable/IoT devices

Because there are numerous APIs and frameworks that support JavaScript, it makes it easy to move from applications for the Web to applications for devices and to integrate them with social media without much tinkering involved, Catanzariti said.

“Somebody might have made a JavaScript plug-in for their website or be thinking about it in terms of a Web application. Because it’s all in JavaScript, a lot of the time with that stuff you can just [move] it across and it will work just the same on a Pebble app or any number of other things.

“If you wanted to integrate Twitter into something or any of those sorts of services, there’s already a lot that exists in JavaScript to be able to do that sort of thing. Rather than somebody having to create this whole custom-built application for the Internet of Things or a particular device, with JavaScript there’s all this stuff that’s already made.”

JavaScript also can be a really easy language to learn, which encourages people to experiment in wearable/IoT app development space, said Catanzariti.

“Really basic stuff about variables and arrays and all of that, using JavaScript it is really simple to get there and you don’t need to know all of these really in-depth concepts like memory management or the inner workings of a computer. With JavaScript they can do the bare minimum.”

However, it can be challenging when using JavaScript to develop for wearable devices when there is poor documentation and not a lot of examples of how to code things, Catanzariti said.

“It’s not as easy as JavaScript developers who are used to using jQuery, who just go to the jQuery documentation and look up how to make something fade in and out, for example. Because it’s still relatively new, it can be challenging. It’s very much a self-directed trial and error thing.”

Because JavaScript is a high level language, there can be some limitations when developing wearables and IoT applications.

“Take the Pebble Watch, for example. You can’t do everything with JavaScript because you’ve got to still do some native programming. And I’ve found the same thing with Arduino – there’s a lot that you can do with JavaScript, but there’s still some things that you have got to fall back to the native device C programming to be able to do some really in-depth stuff,” Catanzariti said.

Join the newsletter!


Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags appsapplicationsjavascriptInternet of Thingswearable devices

More about SitePointStarbucks

Show Comments