1.5 KiB
1.5 KiB
MQTT Configuration
This project can publish weather and public transport data to an MQTT broker. To enable MQTT, follow these steps:
1. Install dependencies
Ensure you have Rust and Cargo installed. The MQTT support uses the Paho MQTT client crate. Run:
cargo update
2. Set the MQTT_BROKER environment variable
Before running the client, define MQTT_BROKER
to your broker address.
- Without URI scheme (defaults to TCP):
export MQTT_BROKER=localhost:1883
- With URI scheme:
export MQTT_BROKER=tcp://broker.example.com:1883
3. Run the LED board client
Pass the LED board IP address as the only argument:
export MQTT_BROKER=localhost:1883
cargo run --bin ledboard_client -- 192.168.1.50
Topics and Payloads
The client publishes two topics:
weather
JSON payload with fields:
dt
: timestamp (Unix seconds)temp
: temperature in °Cweather
: object withmain
,description
,icon
rain
: rain volume in last 3h (optional)pop
: probability of precipitationwind
: object withspeed
,deg
,gust
straba
JSON payload with fields:
outbound_station
: name of outbound stationoutbound_diff
: seconds until outbound departureinbound_station
: name of inbound stationinbound_diff
: seconds until inbound departure
Customization
You can adjust MQTT topics, QoS, and message formats in client/bin/src/main.rs
under the publish_to_mqtt
function.