/RPIpubmqttDaemon

Primary LanguageCOtherNOASSERTION

RPIpubMqttDaemon for Raspberry PI

A daemon written in C for reading system data from Raspberry PI. The read data will be published to an MQTT server with a given topic.

Getting Started

These instructions will get you a copy of the project up and running on your local machine.

Hardware prerequisites

You need a Raspberry PI board.

Software prerequisites

The daemon uses 2 non standard libraries which must be installed first:

libconfig-dev - This library allows parsing, manipulating and writing structured configuration files.

apt-get install libconfig-dev

libmosquitto-dev - Library for implementing MQTT version 3.1/3.1.1 clients.

apt-get install libmosquitto-dev

MQTT server - MQTT server running and reachable form the Raspberry.

Installing

  1. Build the executable file by running "make"
cd ~/rpipubmqttd
make
  1. Edit the config file rpipubmqttd.conf according to your needs
nano rpipubmqttd.conf
  1. Copy the binary rpipubmqttd and the config file rpipubmqttd.conf to /opt/rpipubmqttd/
sudo mkdir /opt/rpipubmqttd
sudo cp rpipubmqttd /opt/rpipubmqttd
sudo cp rpipubmqttd.conf /opt/rpipubmqttd
  1. Copy the service configuration file rpipubmqttd.service to /lib/systemd/system/
sudo cp rpipubmqttd.service /lib/systemd/system/
  1. Enable RPIpubMqttDaemon service
sudo systemctl enable rpipubmqttd.service
  1. Start RPIpubMqttDaemon.service
sudo systemctl start rpipubmqttd.service
  1. check syslog for errors
sudo tail -f /var/log/syslog
  1. Start an MQTT client and subscripe the topic configured in the config file. You should get a string in JSON format with the read data.
{"CPU_Temp":"45.08","Disk_Usage":"20.10"}

License

This project is licensed under the GNU General Public License - see the LICENSE file for details