A data logger for IoT devices and smart sensors that publish their data using MQTT.
This is a fork of the original by Mahabub Alam.
The system adopts a microservices architecture, consisting of a collector module and a logger module for each sensor type. This enables you to run multiple instances of the modules as well as easily add and expand the modules. Each module is a Spring Boot application, written in Java or Kotlin. A collector module subscribes MQTT topics from the broker and then sends it to the logger module which then writes it to the database (currently PostgreSQL).
- LoRaWAN sensors (via ChirpStack)
- ESPHome-based devices
- Clone the repository
- Run
./mvnw -e package spring-boot:repackage(macOS/Linux) or.\mvnw.cmd -e package spring-boot:repackage(Windows) to build
The output .jar files are located in <module_name>/target/<module_name>-<version>.jar.
This is the fastest and easiest way to deploy Taatta as it also deploys and sets up PostgreSQL, Mosquitto and ChirpStack for you.
You will need to have Docker and Docker Compose installed.
- Copy the environment variable file
.env.exampleto.env - review the
.envfile values- The hostnames and port numbers are already set up, but you should change the Postgres and Mosquitto passwords, especially for production instances
- Review the Mosquitto and ChirpStack configuration at
configurationdirectory- For example, you might want change the LoRa frequency for ChirpStack, or allow unauthenticated MQTT connections for Mosquitto
- Review
docker-compose.ymland make any changes required for your setup - Deploy the containers:
docker compose up -dTo run specific containers:
docker compose up -d <containers>For example, if you only need to log Athom smart plug
data: docker compose up -d mosquitto postgresql collector athom-smart-plug
See the docker-compose.yml file for the full list of containers.
Note: this method assumes you already have Mosquitto, PostgreSQL and all other services installed and configured
- Create
taattauser and group:
sudo groupadd taatta
sudo useradd --system -s /usr/bin/nologin -G taatta taatta- Create a new folder for module executable and change the owner of folder
sudo mkdir -p /usr/local/taatta
sudo chown -R taatta:taatta /usr/local/taatta- Copy all jar files to
/usr/local/taatta, stripping version number from its filename ( e.g.collector-1.1-SNAPSHOT.jarbecomescollector.jar) - Copy systemd service files to
/usr/local/lib/systemd/system - Copy the environment variables from
.env.exampleto/etc/taatta.env - Adjust
/etc/taatta.envas follows (change the passwords!)
# mosquitto
TAATTA_MOSQUITTO_HOST=localhost
TAATTA_MOSQUITTO_PORT=1883
# You may remove these if you don't want authenticated MQTT connections
# In that case, don't forget to set `allow_anonymous` to true and remove `password_file` in mosquitto.conf
TAATTA_MOSQUITTO_USER=taatta
TAATTA_MOSQUITTO_PASSWORD=changeme
# postgresql
TAATTA_POSTGRES_HOST=localhost
TAATTA_POSTGRES_PORT=5432
TAATTA_POSTGRES_USER=taatta
TAATTA_POSTGRES_PASSWORD=changeme
TAATTA_SENSOR_ROUTER=/usr/local/taatta/sensorRouters.json-
Modify the hostnames on
configuration/collector/sensorRouters.jsonso the urls arehttps://localhost:<port_number>, so that the collector sends the data to the correct URL -
Copy
configuration/collector/sensorRouters.jsonto/usr/local/taatta -
Enable and run the services
sudo systemctl enable --now <service_name>.serviceTo check service status:
systemctl status <service_name>.serviceTo temporarily stop service:
sudo systemctl stop <service_name>.serviceTo permanently stop service:
sudo systemctl disable --now <service_name>.serviceIt is possible to log the data to multiple databases across different devices. You can do this by adding URLs to the
hostnames field for each sensor in sensorRouters.json. We recommend running only one collector which subscribes to
MQTT broker on the local side, and then run each sensor's logger module on each device. Here's an example setup for a
logger on local network and on a cloud server:
If you run the logger over the internet (e.g. in the cloud), we also recommend using a reverse proxy to minimise the
number of open ports, and to allow easy HTTPS setup. A basic Nginx reverse proxy configuration is available
in taatta.nginx.
One weakness to this approach is that the databases aren't synchronised, so the databases will slowly diverge from each other when the data can't be sent to the remote logger. You might want to use some sort of DB replication setup instead, but that's beyond the scope of this project.
Special thanks to Mahabub Alam who initially developed this application.
Licensed under Apache License 2.0.

