The Machine-2-Machine protocol, MQTT, has really forced me to rethink how to organize the whole communication process of this project. MQTT stands for Message Queue Telemetry Transport and is touted as the protocol for the developing world of IoT (Internet of Things). Developed by Andy Stanford-Clark and Arlen Nipper, MQTT has been around since 1999. I heard about it while scouring the Raspberry Pi forum for information on communicating between two Pi's over TCP/IP.
Here's what the official website says about MQTT:
MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. For example, it has been used in sensors communicating to a broker via satellite link, over occasional dial-up connections with healthcare providers, and in a range of home automation and small device scenarios. It is also ideal for mobile applications because of its small size, low power usage, minimised data packets, and efficient distribution of information to one or many receivers.
The central point of MQTT is the broker. The broker is like a base station for communication between sensors and subscribers. From my cursory research I've concluded that the broker really ought to be located on a computer that is robust and well, not running around inside a pizza box. MQTT expects connections to be bad on the endpoints and not as a result of the broker being down. The broker will hang onto the sensor data until connections are reestablished. What this means for PizzaPi is that I need a third dedicated Raspberry Pi server that can be kept safe and sound with a reliable internet connection. There are a number of brokers available but Mosquitto is the only open source version that I've found and it is the one I am running.
Here's my updated hardware infrastructure:
The diagram shows how the various devices/users/subscribers interact with the broker and web server that will run on the kit RPi 2. The customer and pizza store will really only directly interact with the web server while the kit RPi B+ and my original RPi B will interact with the broker. Before, I had intended to have the web server run on RPi 2 which is currently hooked up to the PiFace Control & Display 2. The two RPi's would then communicate directly over TCP and then any end users like the pizza store and customer would get information from RPi 2. Clearly, this leads to reliability problems and only running the PiFace CAD is a waste of the upgraded memory and speed on RPi 2, hence the Pi shuffle.
I'll post again soon, the little GPS light is blinking, reminding that I need to get down to business!
