Tag Archives: embedded devices

MQTT: M2M messaging for low-powered IoT devices

mqttMessage Queuing Telemetry Transport (MQTT) is a publish/subscribe messaging protocol for constrained, low-powered embedded Internet of Things devices. Think of it as the M2M (machine-to-machine) messaging protocol for low-bandwidth, high-latency, and unreliable network environments. This gives IoT developers a solid communication option when specifically working with embedded devices, which are expected to perform in “the wild,” while still needing to remain small, light, and have a high performance battery life.

Design and History Behind MQTT

MQTT was first developed in 1999, but has seen a massive explosion in growth and adoption with the surge of the Internet of Things. We now need a way to communicate, signal, and connect between low powered smart devices, and that’s where MQTT comes in. Built as a low-overhead protocol with strong considerations towards bandwidth and CPU limitations, MQTT has found its place in the embedded environment.

SmartDevice

In terms of design, MQTT is a publish/subscribe M2M protocol for embedded devices. It enables clients to connect as a publisher, subscriber, or both, and connect to a broker that handles message passing. There is plenty of documentation and open source client implementations if you wish to dive further into the protocol itself.

The Core of MQTT is the Topic

The ‘topic’ is at the core of using MQTT as an M2M communication avenue for embedded devices. It’s a simple idea, and it’s not unique to MQTT. However, the MQTT protocol harnesses the ‘topic’ fairly well. The ‘topic’ does several things, it’s most important being to ensure that a message is delivered to the correct subscribers. MQTT treats the ‘topic’ as a file path. Overall, think of the ‘topic’ as a simple communication filter, which makes the path application very powerful.

topic = "user/path/topic"

You could be interested in a particular higher level of the path or the leaf element. Without explicitly saying so, MQTT filters messages based on where you subscribe in the tree path. A simple idea, that can be used very effectively.

Technical Specifications of MQTT

Looking a little deeper into the technical aspects of MQTT, the M2M protocol runs on the top of a TCP/IP networking stack. When a client connects for publish/subscribe, MQTT begins the handshaking process. The MQTT header is two bytes, and the first byte is constant. In the first byte, you specify the type of message being sent, as well as the QoS level, retain, and DUP flags. The second byte is the remaining length field. There is more information you can glean from the MQTT specification if you are interested.

Building MQTT on a Data Stream Network

With PubNub now supporting MQTT over our realtime, global data stream network, we wanted to give an overview of the protocol and why you might or might not use it from our perspective. We just went through some of the inner workings, features, and the value the protocol. We’ll now take a look at why you might want to use MQTT with PubNub, or PubNub native exclusively.

EmbeddedWatchPubNubTo utilize PubNub, our gateway is mqtt.pubnub.com and we’ll handle all the broker services and provide you access to our network. First, you publish to a topic (at PubNub we call them channels). Anyone who is subscribed to that topic will receive the message that was published.

If you want to read more and see a more in-depth tutorial, check out our blog post on using MQTT with the PubNub Data Stream Network here.

You may be wondering what the advantage is of using PubNub Native over MQTT?

from Pubnub import Pubnub
 
def callback(message, channel):
    print(message, channel)
 
pubnub = Pubnub('demo', 'demo')
pubnub.subscribe('my_channel', callback=callback)
- See more at: http://www.pubnub.com/blog/what-is-mqtt-use-cases/#sthash.Fm9tmkN5.dpuf

MQTT targets low-powered embedded device environments where resources are scarce. PubNub solves the problems of large-scale connectivity for realtime apps and IoT devices. If you’ve already deployed MQTT-based infrastructure, it makes sense to take advantage of this new PubNub gateway to facilitate scaling and maintenance of your embedded device connectivity layer.

If MQTT is not part of your current infrastructure, you might consider leveraging the PubNub Realtime Data Stream Network directly along with PubNub’s numerous IoT SDKs for all of your Internet of Things connectivity. To start, we provide over 50 client SDKs to use, extensive PubNub documentation and our blog where we showcase useful tutorials with open source code, demos, and other write ups on all things realtime technology.

MQTT does have many open source client implementations and documentation, and is a great publish/subscribe messaging protocol for low-powered devices. The protocol has a small footprint and has some great MQTT use cases.

import paho.mqtt.client as mqtt
 
def on_message(client, userdata, message):
print(msg.topic, str(msg.payload))
 
def on_connect(client, userdata, flags, rc):
client.subscribe('my_topic')
 
client = mqtt.Client()
client.on_message = on_message
client.on_connect = on_connect
client.connect('mqtt.pubnub.com', 1883)
client.loop_forever()

Arduino + MQTT = Two Peas in a Pod

There are several Arduino-MQTT implementations and resources available today, and the two go hand in hand for developers working on embedded device projects. As a user, if you are looking for a very small publish/subscribe protocol, MQTT may be for you. If you need more features, or need to scale to hundreds or thousands of connected devices, that’s where PubNub comes in. The transition from MQTT to PubNub in both code and ideology is a quick, exciting process.

Happy Hacking!

Wearables shipments to reach 22 million in 2014

According to CCS Insight, 22 million wearable devices will be shipped in 2014 — more than double last year’s 9.7 million total. The latest report projects that over 250 million smart wearables will be in use by 2018, nearly 14 times more than in 2013.

“The wearables market is in its Stone Age right now. There needs to be huge improvements to broaden their appeal,” explains Marina Koytcheva, Director of Forecasting at CCS Insight.

The forecast predicts that wrist-worn devices will account for 87% of wearables to be shipped in 2018 — comprising 68 million smartwatches and 50 million smart bands with no screen or with a minimal, one-line display. Fitness and well-being trackers remain the fastest-growing category, given that they have a clearly defined purpose, user benefits and are relatively affordable. CSS Insight believes fitness trackers will account for over half of the 35 million wearables in use at the end of this year.

“Wearables are poised to be the perfect gift for the person who has everything this Christmas. We believe this will fuel strong growth in the final quarter of 2014 for smart bands, particularly fitness trackers, which will account for more than half of the 35 million wearables in use at end of 2014,” Koytcheva adds.

According to the report, CCS Insight also foresees strong future growth in smartwatches. The company expects many smart band manufacturers to extend their product ranges by adding devices with screens. As smartwatches broaden their appeal, capabilities are refined, new functions are added and prices fall, CCS Insight expects smartwatches to displace fitness bands and become the most used form of wearables.

A smart wearable category that will become much more prominent in the second half of 2014, CSS reveals, is stand-alone cellular wearables. “We expect a number of high-profile devices with their own SIM cards will be announced in the coming months. However, these devices will face significant challenges as people are reluctant to take out another contract with their mobile operator.”

North America currently leads the way in terms of adoption of wearables with 5.2 million wearables sold in  2013, and over 40% of all wearable devices currently in use are there. Reason being that a majority of companies are based in North America, while the region possesses a proven eager to adopt new technology. Western Europe is catching up and from 2016 is expected to buy more wearables than North America, the analysts predicted. Adoption will be slower in emerging markets and primarily driven by tech-savvy, affluent users.

“The market is still in a chaotic stage of development, and there’s still a huge amount of uncertainty. Every category faces different risks: the way people use wearables is still changing, one type of device could kill sales in another category, people are unsure whether some wearables are socially acceptable, and intellectual property rights are a minefield for the dozens of start-ups entering the wearables market,” Koytcheva points out.

To learn more, you can access the entire report here or view the detailed infographic from the research firm below.

CCS_WW_wearables_forecast_August2014_s

 

Controlling a Toy Helicopter–With Your Thoughts

You might see neighborhood kids, or even grown-ups, playing with remote-controlled helicopters. Well, the remote control that operates that toy may soon take a back seat. A San Francisco company called Puzzlebox has created a toy helicopter that can be controlled by your brainwaves. The Orbit features an electroencephalography (EEG) headset that reads electrical activity along the scalp. And, it is powered by an embedded board — in this case an Arduino Uno board featuring an Atmel AVR ATmega328 microcontroller.

Can you imagine the possibilities for thought-controlled devices? What would you like to be able to control with your brainwaves?