#2 Collecting MQTT sensor data on a local Windows PC

Localized and secure collection of MQTT data

Recipe: Securely connect your MQTT IoT data to a local windows PC

Ingredients: Mosquitto (open source MQTT broker), iSimplyConnect Network Connector, MQTT enabled IoT edge gateway

 

Get Cooking:

In this recipe we will provision a local windows machine, to act as a Message Queue Telemetry Transport (MQTT) broker. Enabling us to aggregate MQTT messages from all of the cellular enabled gateways.

The recipe uses an open source MQTT broker – Eclipse Mosquitto™ (https://mosquitto.org/), which can be downloaded and installed on the local machine.

Eclipse Mosquitto™ is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 3.1 and 3.1.1. MQTT provides a lightweight method of carrying out messaging using a publish/subscribe model.

Configuring the IoT Gateway

1. Power-off the GPRS enabled cellular gateway device, insert the SIM into the device and power up again.

2. Edit the APN settings on the device, submit and/or save the APN details. Restart the device if needed.

Note: The iSimplyConnect APN details are available from the FAQ and or Getting Started guides.

3. Verify that the gateway device is connected to the carrier network e.g. the device has received an IP address.

Verify Connectivity to IoT gateway

1. Check that the IoT gateway is visible in the Asavie IoT Connect portal.

2. It’s also worth noting the IP address assigned to the IoT gateway.

Note: The SIM status should be live and the date last seen should be from when you powered back on the device.

Configuring the local windows PC

Installing the secure tunnel client – iSimplyConnect Network Connector

1. Log into the IoT Connect portal. Select the Network Settings tab and then select the “+” icon at top of the Network Connectors column.

Note: If there is an existing Network Connector, disable it first. This is in order to be able to add a new connector type.

2. Follow the instructions as prompted, assign the Network Connector a unique IP address outside the SIM card range.

3. Select OS version based on your local PC OS, copy the activation code and download the Network Connector to the local PC.

4. On the local PC, run the downloaded executable, follow the install instructions.

5. Paste the activation code that was shared with you per step 3, select next to continue.

6. On successful install, you will then see the new Network Connector, appear in the IoT Connect portal.

Installing the MQTT Broker

1. Download the open source MQTT broker software from https://mosquitto.org/download/, follow the install instructions.

2. Once the MQTT broker and all package dependencies are installed, modify the mosquitto.conf file and add an extra listener.

Note: The new listener will be assigned the same IP address as that of the installed Network Connector.

3. Restart the MQTT broker via the Services window i.e. search services in the windows explorer tool bar.

Verifying the MQTT broker as operational

1. Open a DOS command line window and navigate to your Mosquitto install folder. In the DOS window, add a listener client using the mosquitto_sub commands. Equally, its possible to publish to the topic using mosquitto_pub.

Note: You will need to define a topic for the data collection, which should also match the IoT device MQTT topic e.g.
C:\mosquitto> mosquitto_sub -d -t isimply/temp

2. Another tool worth considering for debug is MQTTLens, a Google Chrome application, which connects to a MQTT broker and is able to subscribe and publish to MQTT topics.

3. With the sensors now connected to the gateway and set to publish to the topic, your data should now appear on the broker, if you are using the MQTTLens tool and subscribed to the same topic you should see your sensor data appear in the MQTTLens window.

Congratulations! You have securely connected your IoT project to you local windows PC!