A daemon written in C for reading data of an DHT22 sensor connected to an Raspberry PI. The read data will be published to an MQTT server with a given topic.
These instructions will get you a copy of the project up and running on your local machine.
You need a Raspberry PI board and a DHT22 sensor connected to Pin 7 (GPIO4) of the Raspberry to use this daemon.
The daemon uses 3 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
wiringpi - Wiring Pi GPIO Interface library for the Raspberry Pi
apt-get install wiringpi
MQTT server - MQTT server running and reachable form the Raspberry.
- Build the executable file by running "make"
cd ~/dhtpubmqttd
make
- Edit the config file dhtpubmqttd.conf according to your needs
nano dhtpubmqttd.conf
- Copy the binary dhtpubmqttd and the config file dhtpubmqttd.conf to /opt/dhtpubmqttd/
sudo mkdir /opt/dhtpubmqttd
sudo cp dhtpubmqttd /opt/dhtpubmqttd
sudo cp dhtpubmqttd.conf /opt/dhtpubmqttd
- Copy the service configuration file dhtpubmqttd.service to /lib/systemd/system/
sudo cp dhtpubmqttd.service /lib/systemd/system/
- Enable DHTpubMqttDaemon service
sudo systemctl enable dhtpubmqttdaemon.service
- Start DHTpubMqttDaemon.service
sudo systemctl start dhtpubmqttd.service
- check syslog for errors
sudo tail -f /var/log/syslog
- 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.
{"Humidity":"42.00","Temperature":"20.10"}
This project is licensed under the GNU General Public License - see the LICENSE file for details