mqtt.pub
- utilities for publishing Rpi sensors to MQTT topicsmqtt.sub
- utilities for subscribing to MQTT topicssensors
- modules to read Rpi sensor data
# Clone this git repo
git clone https://github.com/ismarslomic/rpi-mqtt.git
cd rpi-mqtt
# Create python virtual environment (required in Bookworm)
python3 -m venv --system-site-packages .venv
source .venv/bin/activate
# Install poetry
pip3 install poetry
# Disable keyring, otherwise poetry will be hanging
keyring --disable
# Install required python packages defined in pyproject.toml
poetry install --without dev --no-root
# Run python program
cd src
python3 -m sensors.main -s /Users/john/rpi-mqtt/settings.yml
You can provide user settings by providing a settings.yml
file according to the JSON
schema settings.json or markdown settings.md.
Example settings.yml
:
mqtt:
# The hostname or IP address of the MQTT broker to connect to. Default 127.0.0.1.
hostname: 127.0.0.1
# The TCP port the MQTT broker is listening on. Default: 1883.
port: 1883
# Override the default sensor_name (rpi-<hostname>) with own name of sensor to be used in MQTT topic name.
sensor_name: my-macbook
script:
# The interval to update sensor data to MQTT broker. In seconds. Default: 60.
update_interval: 120
# The log level for the python script. Default: INFO.
log_level: DEBUG
# Override default settings by enabling (true) or disabling (false) sensors you want to be published to MQTT broker
sensors:
boot_loader: False
cpu: True
disk: True
fan: False
Read DEVELOPMENT.md for more information about how to contribute.