Prologue

Two years ago I started working on Aquila, a Domotics and Internet of things platform aimed at easing prototyping, development and testing of ideas with connected devices.

At that time, the whole "Internet of things" idea was relatively new, new IoT platforms where appearing trying to become the default platform for that type of devices.

However, each one of those platforms was incompatible with the others, some being better for some things than others, being more or less useful depending on the application.

Aquila 1.0 was created integrating open technologies and standards like 802.15.4, aiming at being a viable alternative for developers. Aquila successfully reached its original objectives, however, integrating it with other technologies is not easy and could be not flexible enough for some applications.

The Internet of things matures

During that time, another technology was becoming popular in the IoT world: a protocol named MQTT, this is not a new technology, it was created by IBM in 1999, but it turned out to be ideal for IoT applications due to its simplicity and lightness.

MQTT is based on the Publish - Subscribe concepts; Clients are connected to a server called "Broker", and can publish in certain "Topics" or subscribe to them.

Example of the workings of MQTT, Source: http://www.hivemq.com/

For example, lets say that we have two clients, one is a temperature sensor that publishes on the topic "sensor1/temperature", and the other is a screen that subscribes to the same topic. When the sensor publishes that we are at 24ºC, the screen gets that value immediately and can, for example, display it.

MQTT doesn't define the lower network layers, like the frequency, modulation, packets, etc. Instead, it runs over TCP networks, this is good because it's easily implementable on any TCP/IP network and can be integrated on mobile applications and web services. Nevertheless, this makes it harder to implement in simpler sensor networks.

Now, there is a specification called MQTT-SN - MQTT for sensor networks -, this specification is very interesting because it allows us to integrate embedded devices with any MQTT network, without losing the advantages of that sensor network, like low power usage, and surpassing it's limitations, like the limited computation power of a microcontroller.

MQTT-SN Architecture, Source: MQTT-SN spec v1.2

MQTT-SN seemed to me as the solution for interoperability between sensor networks. Aquila 2.0 had to integrate it.

There are few implementations of this specification, and I couldn't find any complete open source one. That's why I decided to implement it for Aquila 2.0.


Aquila 2.0

Characteristics of Aquila 2.0:

- Ideal for low power networks
- MQTT all the way via MQTT-SN
- Sleeping nodes support according to MQTT-SN spec
- Security by default (using radio encryption features when available)
- Easy and flexible implementation
- Interoperability between different wireless networks via MQTT


Aquila 2.0 consists of:

- MQTT-SN Gateway
- Bridge (Firmware)
- Wireless nodes (Firmware and MQTT-SN libraries)

Aquila 2.0 Architecture

The nodes implement the MQTT-SN support in firmware and are connected wirelessly to the Bridge. The Bridge transmits every message to a PC (or micro-pc like Raspberry Pi) via serial communication or USB. The PC runs the Gateway, it is in charge of: 1. Managing the devices (pairing, addressing, buffering of messages for sleeping nodes, MQTT topics, and more) and 2. Translating messages from and to your favorite MQTT Broker (like Mosca or Mosquitto).

This implementation aims to be as hardware independent as posible, this makes possible porting it to different boards, microcontrollers and radio transceptors in a relatively easy way.

Right now we have two hardware implementations:

Altair Pro

Aquila 2.0 also allows for the interoperability between different wireless technologies via MQTT, for example, if we had a light sensor in an Altair and a relay actuator with an rfm69, having an Altair bridge and a rfm69 bridge connected to two instances of the Gateway makes possible that when the Altair publishes "sensor/low_light", the actuator with the rfm69 turns on a light.

Aquila 2.0 is in Beta, almost all of it's features are implemented and it's completely functional, but it could suffer major changes to its API before reaching the stable version.

Where to find the code

As any good open source project, you can find it on Github:

https://github.com/Rodmg/aquila-mqtt-sn-gateway

(You can find the links for the Gateway and client implementations on the README, along with the documentation.)

I expect to be uploading examples and tutorials on the use of this new platform in the near future. In the meantime, I recommend you to check this projects out: node-red and node-red-dashboard, they are the perfect companions to this platform.