Project Description

Build a cloud-ready temperature sensor with the Arduino Uno and the IBM Watson IoT Platform

Part 2: Write the sketch and connect to the IBM Watson IoT Platform

by Kyle Brown



Overview

In Part 1 of this four-part tutorial series, I discussed the design of a project for monitoring temperatures in my wiring closet, built by using the Arduino Uno and the Virtuabotix DHT11 temperature sensor. I showed the construction of the circuit for the project and walked you through the installation of the Arduino IDE and how to test out each of the individual components of the project with different Arduino sample sketches. You’re now ready to see the design of the sketch that ties the IoT project into the cloud and the steps to enable monitoring of realtime temperature and humidity data remotely. However, first I need to discuss the protocol that you’ll use to communicate with the IBM IoT Foundation: MQTT.

What is MQTT?

MQTT (formerly Message Queueing Telemetry Transport) is a lightweight, fast communications protocol designed for the Internet of Things. It has its origins at IBM (where it was originally developed by Andy Stanford-Clark), and it has since been submitted to Organization for the Advancement of Structured Information Standards (OASIS) for standardization, where the current version of the protocol standard is version 3.1. The MQTT V3.1 Protocol Specification specification states that its purpose is to be a “lightweight broker-based publish/subscribe messaging protocol designed to be open, simple, lightweight and easy to implement.” In the time since its introduction, the “easy to implement” part has certainly proven to be true, as several different libraries implementing MQTT clients have been developed. You can find links to nearly all of them at the Eclipse Paho project page.

MQTT is perfect for use in embedded devices because it:

  • Is asynchronous, with multiple different levels of quality of service, which is important in cases where Internet connections are unreliable.
  • Sends short, tight messages that make it handy for low-bandwidth situations.
  • Doesn’t require much software to implement a client, which makes it great for devices like the Arduino with limited memory.

MQTT is the protocol that the IBM IoT Foundation QuickStart is designed to take input on.

Resources

Learn
MQTT V3.1 Protocol Specification: Read the latest version of the MQTT specification.
IBM Internet of Things Foundation: Try out the IBM IoT Foundation and sign up for the beta program.
Arduino: Visit the Arduino website.
“Bluemix and the Internet of Things” (Ryan Baxter, developerWorks, July 2014): Find out how IBM Bluemix and the IBM IoT Foundation can work together.

Get products and technologies
MQTT client for Arduino: Click the GutHub link to download the client.
Mosquitto: Download the Mosquitto broker.
Eclipse Paho Project: Download MQTT clients.

Learn more

Goto Original
Goto Part1


Author : Kyle Brown (IBM)