The broker system was set up using MQTT. MQTT is short for “Message Queuing Telemetry Transport” and describes a publish-subscribe-messaging-protocol. It works on top of the TCP/IP protocol and is designed for low capacity networks as it works with small footprints and even with high latency circumstances. With MQTT, a server (so called “broker”) is needed which stores topics with messages. A client can subscribe to a topic so that the broker publishes new data to the client as soon as it receives it.

To set up the specific broker system, additional hardware is needed. In this case, a Raspberry Pi is set up as broker and two Raspberry Pis as well as a smartphone are set up as clients. Additionally, a router is needed so that the devices are connected within the same network, specifically via WLAN. In this example, a TP Link router with the following specifications was used:

  • Model TL-WR841N
  • 3G / 4G Modem
  • 300 Mbit/s Wi-Fi
  • AccessPoint

In an additional configuration, the shown broker provided by a Raspberry Pi, is replaced by the Amazon IoT Core service. The clients as well as the app directly communicate with this service then.

Utilization in practical exercises

In order to use the broker system together with the Train IoT app (described in the section “IoT Broker System Mobile App”) an administration interface is available on the broker system. The web interface can be opened on http://trainiot.local:8080/. The login interface is presented to the administrator as depicted in the following figure:

In order to support privacy the students to not have to provide any private user accounts to use the app. The teacher can generate an arbitrary number of accounts for a new class and give these accounts to the students to authorize against the broker system. The generated accounts can be maintained in the web interface as well, as can be seen in the next figure:

Furthermore the teacher can see a list of all devices and IoT components registered within the IoT playground environment:

Getting started

First of all, the mentioned infrastructure must be established. Therefore, three Raspberry Pis should be set up as described in the last chapter. Two of them should be equiped with the Sense HATs so that they act as publisher of new data. A third Raspberry Pi becomes the broker. In the setup above, the configuration of the network is the following:

  • Raspberry Pi 1 (publisher):, hostname: HBO1-pi1
  • Raspberry Pi 2 (publisher):, hostname: HBO1-pi2
  • Raspberry Pi 3 (broker):, hostname: HBO1-pimaster
  • TP Link (router):, SSID: TranIoT-HBO1, password: erasmus2018

To achieve this, the two Raspberry Pi clients must install the paho-mqtt package:

pip install paho-mqtt

The broker, on the other side, needs the mosquitto package to act as a broker, which can be installed this way:

sudo apt install mosquitto

Moreover, a smartphone was used to interact with the data published from the Raspberry Pi clients and hosted by the broker. To do so, the smartphone needs to be connected to the same local network and must install the “MQTT Dash” app for Android or the WApp for iOS. Afterwards, the app can be used to subscribe to topics to receive data or also send data to specific topics to control other devices. Devices connected using the WApp can also be managed using the related web interface.

In the last step, Amazon IoT Core was used. To configure this, the Raspberry Pi clients need to install the AWS CLI as well as BOTO. This is possible with the following commands:

pip install awscli --upgrade
pip install boto
pip install boto3

After the configuration of the related AWS service, the Raspberry Pi broker is no longer needed and the smartphone apps as well as the Raspberry Pi clients can directly communicate with the Amazon IoT Core service.

Where to buy?       

The mentioned TP Link router or comparable devices are available at most electrical stores. The MQTT app is available from the Google Play store.