The project (what’s it all about):
This is a demo project for “Internet of Things” (IOT). In this demo project we will try to connect led and a sensor to IBM bluemix cloud, so that LED can be operated through any smartphone/ tablet/ pc etc. Likewise, sensor data will be furnished to device requesting it.
We will be using MQTT protocol for overall communication. In MQTT protocol, clients connect to each other via a central broker. “Mosquitto” is used as public broker in this project. The raspberry-pi, which interfaces the LED and sensor uses “MQTT-Paho” library (written in python), to connect to the broker.
On invoking the Paho script along with RPi.GPIO – to perform I/O operation, raspberry pi sits to receive any command on subscribed topic. As a certain message is received on some topic – either LED is toggled or sensor data is published.
MQTT is a publish/subscribe messaging protocol designed for lightweight M2M communications. It was originally developed by IBM and is now an open standard.
MQTT has a client/server model, where every sensor is a client and connects to a server, known as a broker, over TCP.
MQTT is message oriented. Every message is a discrete chunk of data, opaque to the broker.
Every message is published to an address, known as a topic. Clients may subscribe to multiple topics. Every client subscribed to a topic receives every message published to the topic.
For example, imagine a simple network with three clients and a central broker.
All three clients open TCP connections with the broker. Clients B and C subscribe to the
topic temperature .
At a later time, Client A publishes a value of
22.5 for topic
temperature . The broker forwards the message to all subscribed clients.
The publisher subscriber model allows MQTT clients to communicate one-to-one, one-to-many and many-to-one.