Skip to content

jonghee-son/RPi_MQTT_Client_C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

RPi_MQTT_Client_C

MQTT Client for Raspberry Pi written in C

How to use

  1. Clone this repository & install dependency
$ wget https://github.com/eclipse/paho.mqtt.c/releases/download/v1.3.10/Eclipse-Paho-MQTT-C-1.3.10-Linux.tar.gz
$ tar -xvzf Eclipse-Paho-MQTT-C-1.3.10-Linux.tar.gz
$ cd Eclipse-Paho-MQTT-C-1.3.10-Linux
$ make
$ sudo make install
$ cd ~
$ git clone https://github.com/jonghee-son/RPi_MQTT_Client_C.git
  1. Edit the code to fit your environment
#define ADDRESS "tcp://172.30.1.50:1883" //Broker IP Address
#define ADDRESS_SECURE "tcp://172.30.1.50:8883" //Broker IP Address but with TLS encryption
#define CLIENTID "CLIENT_SUB" //Client Name
#define TOPIC_1 "lab/light" //Topic Configuration (Light)
#define TOPIC_2 "light/stat" //Topic for current status of light
#define PAYLOAD_1 "Switch is ON" //Defining message for status message publication
#define PAYLOAD_2 "Switch is OFF"

Edit these pre-defined parameters.

  1. compile editted code with preferred c compiler (gcc, clang etc.)
$ gcc -o client src.c -lwiringPi -lpaho-mqtt3c
$ ./client

About

MQTT Client for Raspberry Pi written in C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages