Building an Open Source PaaS for Internet of Things
The Internet of Things (IoT) is not about simply connecting a device to the Internet. It is about making a device intelligent and changing the way we use it every day. Putting a powerful hardware into a toaster, a vacuum cleaner, an air conditioner or another well known home appliance will not make it smart out of the box. But connecting it to the cloud where the user can define rules, monitor and control it remotely in real time is another story.
The rise of IoT requires an open source platform as a service (PaaS) based on open standards to monitor and control in a safe and secure manner the smart gadgets around us. The aim of my open source project is to create a platform that includes a user friendly web interface and a mobile application to control multiple IoT devices in the cloud.
I use open source hardware devices and sensors powered by ESP8266, a low-cost microcontroller with wi-fi from Olimex, for early prototypes and proof of concept demonstrations. When the gadget is turned on for the first time it creates its own open WiFi network. The user has to connect this network and to type in the password of his home WiFi network. The device will reboot and automatically connect to the home WiFi network using the provided credentials. Once it has access to the Internet it will establish a connection with the cloud using the machine-to-machine (M2M) connectivity protocol MQTT.
The building of a platform for Internet of Things in the cloud has a lot of challenges. Although nowadays there are several similar projects, none so far provides the required flexibility for a world class easy to use projects.
The first major challenge is how to build a hardware device at affordable price that is easy to setup at home or the office? The open source hardware development devices with ESP8266 from Olimex are a perfect option for low cost rapid prototyping. Its price of about $3-$4 per unit makes it a perfect solution for do it yourself (DIY) home automation. The feature of ESP8266 to work as a WiFi access point and a client simultaneously simplified the initial configuration process for end consumers.
Moving it to the Cloud
The second major challenge is how to monitor and control multiple Internet of Things in real time from a single place? An architecture based on MQTT overcome the difficulties caused by NAT (Network Address Translation) during communication between devices in a home WiFi network and a server with a global IP address. All Internet of Things connect as clients to MQTT broker on the cloud which dispatches the exchanged messages between the different machines. HTTP server implemented with Node.js (or another web back-end technology) also connects as a client to the MQTT broker and exposes HTTP API to web and mobile applications.
Hosting and Scalability
The third major challenge is how to implement and maintain an IoT platform as a service. Unfortunately hosting MQTT broker in not as simple as hosting a WordPress blog. Despite the rapid development and rising popularity of Node.js, finding a reliable and affordable hosting for Node.js application is still not as easy as for a solution developed on PHP or Python. Last but not least the scalability is vital for the success of any PaaS.
I explored different communication protocols, hardware devices and cloud hosting solutions. For the moment this is just a hobby project so I had to find stable hosting for a limited budget. The technical specifications of the hosting plans on the mass market do not provide the required capabilities for running an MQTT broker and Node.js application.
After drifting around and struggling with several other cloud hosting solution a friend of mine recommended Kyup. I was able to launch a Linux container, to install the open source MQTT broker Mosquitto and deploy Node.js HTTP API in less than 5 minutes. The user interface of Kyup is simple and very intuitive. The best part is that the user has root access to the container so you have the freedom to do what suits your project best.
Kyup makes the life of IoT developers easier by quickly solving a lot of the challenges. With Kyup any developer can launch a Linux container, develop, deploy and provide a platform for management of IoT as a service for end consumers. The platform offers easy setup and maintenance of distributed systems that can scale depending on the load and the needs of the project.
Before Kyup I tried OpenShift - the cloud of RedHat, one of the largest and most innovative companies with business based entirely on open source solutions. Although OpenShift provides great services there were several limitations that I encountered for my specific needs. The setup of MQTT broker on OpenShift required a lot of steps and I had to use port forwarding to access the MQTT broker from clients if I wanted to use it without SNI proxy.
Another solution that I tried was CloudMQTT. This is a hosted broker for Internet of Things with a free plan for a tryout. The setup and the service of CloudMQTT is very good but the plans suitable for real life solutions are quite expensive and there is no option to host anything else except the MQTT broker on their cloud.
Picking up a proper architecture and a rock solid hosting is essential for the success of any project. The combination of open source software and hardware technologies with cloud hosting on Linux containers is changing the game. These tools allow any developer to unleash his or her creativity and to compete with the big players on the market for innovative IoT solutions.
About the Author
Leon Anavi is a software engineer and open source enthusiast with more than 8 years of experience in the field of core telephony solutions, mobile and web applications. He is the author of the Tizen Cookbook, printed by Packt Publishing as well as the founder of the open source projects Tizen-sunxi and Tizen-rockchip for porting the Tizen software platform to devices with Allwinner and Rockchip SoC. He is a regular speaker at various developer events related to open source around in San Francisco, Shanghai, Brussels, Bratislava, Sofia and his hometown Plovdiv and his latest passion is IoT (Internet of Things).