The Internet of Things: Cordova Plugin for Electric Imp’s BlinkUp
Macadamian Technologies | August 18, 2015 | 4 Min Read
The Internet of Things (IoT) is a new and exciting trend where everyday objects are being connected to the internet.
The Internet of Things (IoT) is a new and exciting trend where everyday objects are being connected to the internet. From consumer applications to enterprise machine-to-machine communications to healthcare IT, almost every market is showing increasing support for connected devices. And, leading the way in providing connected device solutions across these various markets is Electric Imp.
The Electric Imp Solution
Electric Imp provides an easy-to-use environment to develop custom firmware for their Wi-Fi enabled, SD card-sized micro-controllers that can be integrated with existing circuits and devices. The Electric Imp solution is used in a large range of projects from small do-it-yourself activities to prototypes to mass-produced connected products. Electric Imp also offers a platform to develop and test your code and a lightweight cloud solution called “Agents” that allow the device to communicate with the larger Internet.
One problem remains. The Electric Imp device must be connected to the Internet and be provided with Wi-Fi credentials. Electric Imp determined that this should not be done through the device itself, but through a mobile device. This process is called BlinkUp, and communicates Wi-Fi credentials by flashing light patterns from an iOS or Android phone to a sensor on the Electric Imp device.
Mobile Companion Applications for the Internet of Things
In addition to an Internet-enabled device (such as the Imp), an IoT solution generally requires a companion application that allows interaction with the connected device from the Internet. This companion application is typically a mobile app due to the accessibility of mobile devices and their ability to access IoT-enabled devices regardless of location.
While we recommend writing mobile IoT applications in native technologies (e.g. Cocoa on iOS and Java on Android), consider using mobile Web technologies such as Cordova for a minimum viable product. This solution provides some benefits. Code can be easily shared between platforms and Web-savvy developers can be used to create applications. One of the drawbacks of this approach is that native code might need to be invoked from the applications (e.g. accessing phone’s camera or a process that requires high performance). The BlinkUp process requires precise timing and falls into this category. So, how do you solve this problem?
The Cordova Plugin for BlinkUp
We decided to investigate how well the BlinkUp process works within a Cordova-based sample application and experimented with the Cordova Plugin to allow mobile web applications to perform BlinkUp with Electric Imp devices. Apart from defining our APIs, one of the challenges that arose when developing the Cordova Plugin was that the BlinkUp SDK implementations differed between iOS and Android. We needed to ensure the behavior was consistent between both operating systems.
Another challenge when picking a Web-based application was having a design that was consistent on both platforms. For this sample application, we intentionally went with a design language similar to iOS that did not look out of place on Android. For a richer application, however, this might have a jarring effect on users who expect their mobile application to have a particular look and feel.
Open Sourcing the Plugin
As a result, a BlinkUp plugin was successfully built and we are able to use it in a sample Cordova application. The plugin and sample application have been made publicly available on GitHub and released under an Apache 2.0 license. Also, keep an eye out for it on npm! Open sourcing this was quite intentional and we wanted to give back to the Electric Imp and Cordova community to help anyone de-risk their Cordova and Imp-based IoT projects. Fork it, play with it, and send your contributions to help improve it!
Get Email Updates
Get updates and be the first to know when we publish new blog posts, whitepapers, guides, webinars and more!
Health Information System Integration
In this webinar, we discuss interoperability in healthcare and answer attendee questions on Health Information System integration. Download the webinar Now.Read More
Guide to Creating Engaging Digital Health Software
This guide shares our knowledge and insights from years of designing and developing software for the healthcare space. Focusing on your user, choosing the right technology, and the regulatory environment you face will play a critical role in the success of your application.Read More
Accelerate Time To Market Using Rapid Prototyping
In this webinar, you will learn how to leverage rapid prototyping to accelerate your products time to market in one week, agile sprints.Read More