---
description: Message Queuing Telemetry Transport
---

# MQTT Setup

The MQTT protocol enables a publish/subscribe messaging model in an extremely lightweight way. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.

### **Steps to follow Paho-MQTT on x86 using python :**

Step1: Make sure python & Internet -Enabled in your PC.&#x20;

Step2: Create Folder(paho-mqtt) and copy the source : iot\_pub.py ,iot\_sub.py and other dependency files.

&#x20;Step3: Terminal-1: python iot\_pub.py     Terminal-2:python iot\_sub.py     //First - Model&#x20;

Step4: Install “MYMQTT “ App in your Android Mobile and configure like.\
&#x20;   (a) Open App and goto settings and fill the broker name with : [https://m2m.eclipse.org](https://m2m.eclipse.org) and remaining       \
&#x20;         blanks are optional and Save it. \
&#x20;   (b) Open App and select subscribe fill with topic : phytec/iot/temp/mv (Ref:iot\_pub.py )

Step5: Run :python iot\_pub.py and verify the Data on your MQTT- App @ Dashboard.

### Compilation Guide for paho-MQTT on x86 using C **:**

1.Extract the folder mqtt by following command: tar -xvf mqtt.tar.gz

2.Now enter the below make command, make&#x20;

3\. Wait for the compilation to be finished, compiled output binary files will be available in below path: \
cd build/output/samples/&#x20;

4\. cd mqtt/paho.mqtt.c\_x86/src/samples is the path for your mqtt publish.c and subscribe.c if u have any changes copy your mqtt publish.c and subscribe.c file in above path&#x20;

5\. compile again, \
`make`&#x20;

6.gopal@phytec:\~/Work/mqtt/paho.mqtt.c\_x86/build/output/samples$ ./MQTTAsync\_subscribe (Terminal-1)&#x20;

7\. gopal@phytec:\~/Work/mqtt/paho.mqtt.c\_x86/build/output/samples$ ./MQTTAsync\_publish \
(Terminal-2)

**MQTTAsync\_publish.c**

![](https://2940024201-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbvnQRGvCTc2Zmsi6BG%2F-LdwSgrIBxDIHqejCU24%2F-LdwTE329neQZLyazXMI%2Fmqttsc.jpg?alt=media\&token=6041f11d-7ca9-48bf-8b7e-9a493196302f)

**MQTTAsync\_subscribe.c**

### Compilation Guide for paho-MQTT on ruggedBoard:

**Steps for configure MQTT:**

1\. Extract the folder mqtt by following command: tar -xvf mqtt.tar.gz&#x20;

2.Run the env.sh script for arm-cortexa8 compiler.&#x20;

3.Go to following location: cd mqtt/openssl/openssl-1.0.0j\_arm/include/openssl/&#x20;

4.Enter command 'pwd' and copy the path given by this command.&#x20;

5.Now come back to the main folder and enter below path: cd mqtt/paho.mqtt.c\_arm/ open the ReadmE file and paste the copied path of pwd above, save.&#x20;

6.Now enter the below make command, by putting the copied path in step 4: make&#x20;

7.Wait for the compilation to be finished, compiled output binary files will be available in below path: cd build/output/samples/&#x20;

8.cd mqtt/paho.mqtt.c\_arm/src/samples is the path for your mqtt publish.c and subscribe.c if u have any changes copy your mqtt publish.c and subscribe.c file in above path .

9.compile again, make&#x20;

10.Copy the Binary (MQTTAsync\_publish) into home folder of ruggedBoard .

11.ruggedBoard# ./ MQTTAsync\_publish.

12\. view the Data on MQTT-App //Make sure to subscribe fill with Topic-Name.

&#x20;                                **---------Enjoy the MQTT Cloud experience-------**

