MQTT c client on raspberry pi
What you will learn here about MQTT c client on raspberry pi
- How to install MQTT c client on raspberry pi
- MQTT c client as MQTT subscriber on raspberry pi
- MQTT c client as MQTT publisher on raspberry pi
How to install MQTT c client on raspberry pi
Please follow the following steps to install MQTT c client on raspberry pi:
1)In order to use MQTT c client on raspberry pi, you need a MQTT broker. If you do not know how to install MQTT broker on raspberry pi please click on the below link.
Steps to Install MQTT Broker on Raspberry Pi
2)Assuming you have successfully installed MQTT broker on raspberry pi
3)Now open the raspberry pi terminal.
4)Now execute the following command to go on Desktop
5)Now please create a MQTTClients folder on Desktop which is shown below.
6)Execute the following command to navigate in MQTTClients folder.
7)Now please execute the following command to download MQTT c client on raspberry pi which is shown below
8)Now execute the following command to download libssl files which is shown below
9)Now execute the following to go in paho.mqtt.c folder
10)Execute the following command
11)Execute the following command
If you are able see following response means, MQTT clients installed successfully.
12)Execute the following command to go in samples folder which is inside src folder
13)Execute the following command to make all .c file as executable which is shown below
MQTT c client as MQTT Subscriber on raspberry pi
please follow the following steps to know, howto use MQTT c client as MQTT subscriber
1)Assuming you have followed above all steps successfully
2)Now open the raspberry terminal
3)Now please go to the samples folder. Please execute the following command to go in sample folder.
4)Execute following command to compile MQTTClient_subscribe.c file which is shown below
5)Now execute the following command to run MQTTSUB file which is compiled the file. Once you run MQTTSUB file, Your subscriber will start listening on topic “MQTT Examples” which is shown below
6)Now please open another terminal on raspberry pi
7)Use the following command to publish data on the topic “MQTT Examples” which is shown below
MQTT c client as MQTT publisher on raspberry pi
please follow the following steps to know, how to use MQTT c client as MQTT subscriber
1)Assuming you have followed above all steps successfully
2)Now open the raspberry terminal
3)Now please go to the samples folder. Please execute the following command to go in sample folder which is shown below
4)Execute following command to compile MQTTClient_publish.c file which is shown below
5)Now please open another terminal on raspberry pi
6)Use the following command to subscribe data on the topic “MQTT Examples”
7)Now execute the following command from first terminal to run MQTTPUB file which is compiled file. Once you run MQTTSUB file, Your subscriber will start listening on topic “MQTT Examples” which is shown below
Please click on the below link to become master in MQTT.