Skip to content

Go application for receiving moisture data via MQTT and notifying users via XMPP

License

Notifications You must be signed in to change notification settings

ThomasLeister/plantmonitor

Repository files navigation

Plantmonitor

Backend for a LoRaWAN-based / MQTT-based soil moisture sensor, which sends notifications via XMPP.

Also see: Blog post on thomas-leister.de [German]

Context

This project is meant to be used with the plantmonitor-sensor software component ("LoRaWAN Sensor"). It will receive raw ADC sensor values from the TTN network MQTT broker and notify defined XMPP users when moisture thresholds are hit.

Drawio Diagram

Features

Features of Plantmonitor:

  • Receive sensor values via MQTT
  • Convert raw values to normalized percentage values
  • Quantify percentage values and assign a quantification level, such as "low moisture", "normal moisture" and "high moisture" level.
  • Notify users via XMPP chat messages if moisture level is not "normal"
  • Remind users if no action has been taken against non-normal levels for a certain period of time
  • Notify users if no more sensor updates have been received
  • Respond to users via XMPP if they ask for the current status

Chat messages can be defined via a language-specific config file. If a language is unsupported, yet, define your own chat message set!

Building Plantmonitor

Download source:

git clone https://github.com/ThomasLeister/plantmonitor.git
cd plantmonitor

Download module dependencies:

go mod download

Run build script:

./build-release.sh

The plantmonitor binary will contain the application.

Installing Plantmonitor

Starting as rootuser, take the following steps to install Plantmonitor manually:

Create a new user account on your system:

adduser --disabled-login --disabled-password plantmonitor

Change to the new account:

su - plantmonitor

Upload the plantmonitor binary, config.example.yaml and lang_de.yaml (or any other language file) to /home/plantmonitor/.

Switch back to the root user:

exit

and create a new Systemd service file at /etc/systemd/system/plantmonitor.service by copying the original file dist/plantmonitor.service from this repository. Make sure the paths in the service file are correct and enable the new service:

systemctl daemon-reload
systemctl enable plantmonitor.service

Configuring Plantmonitor

Rename config.example.yaml to config.yaml and adapt the following settings:

  • MQTT
  • XMPP
  • Giphy (requires Giphy API key. Developer key is sufficient.)

You can also change the level thresholds and more settings, but I'd suggest to leave that for later.

Note: YAML configuration syntax is very picky with Tabs vs. Spaces! Use spaces only for identation!

Running Plantmonitor

You can now start Plantmonitor and check the logs:

systemctl start plantmonitor
journalctl -u plantmonitor -f

No errors should appear in the log. You can check the output by either waiting for sensor updates or sending the plant's XMPP account some messages, e.g. "help".

In case you fine-tuned some settings regarding level thresholds (config.yaml) or chat messages (lang_de.yaml) there is not need to restart the full backend and lose all the sensor history. You can easily load the new values by running:

systemctl reload plantmonitor

(note: This will only affect chat messages and level definitions. The change of other settings such as MQTT and XMPP settings requirea full restart via systemctl restart plantmonitor).

About

Go application for receiving moisture data via MQTT and notifying users via XMPP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published