Before you begin
Install SPX with MQTT and SPX UI. Have a reachable MQTT broker and client ready. This quickstart uses the ready-made environment sensor model. SPX Setup can run an MQTT broker when the service is selected and the stack is started.
Run the test
1. Start the sensor
- In Instances → New instance, select
Env.EnvSensor.Mqtt. If the model is missing, import the linked YAML using Models → Load model from file. - Configure the broker address reachable from SPX and topic prefix
spx/demo/env, then create and start the instance. - Open Communication → mqtt to check the connection settings.

2. Subscribe and send a command
- Connect an MQTT client to the same broker. The address used by a desktop client can differ from the address used by SPX in Docker.
- Subscribe to
spx/demo/env/telemetry/#before publishing: this model usesretain=false. - Publish plain text
24.0tospx/demo/env/command/setpoint_c.
3. Verify the result
- Look for
24.0onspx/demo/env/telemetry/target_c, and observetelemetry/temperature_cchange over time. Broker acknowledgement alone does not confirm a device change. - Publish
22.0to restore the initial target and check the response. Stop your test instance when finished.

Check the messages
This model sends separate numeric UTF-8 messages per telemetry topic, not a combined JSON document. Use the topic names and prefix shown by your instance.
Protocol communication
Use these settings and messages with the library’s environment sensor model.
- Client / transport
- MQTT client → BROKER_HOST:1883; same broker as SPX
- Example prefix
- spx/demo/env (override); library default: spx/examples/env
- Delivery
- Model QoS 1; retain=false; subscribe before sending commands
Replace host placeholders with reachable addresses and use your published ports.
Swipe the table to see requests and replies.
| Address / message | Operation / payload | Expected reply |
|---|---|---|
spx/demo/env/telemetry/# | Subscribe to the full telemetry subtree | Separate topic/value messages, not a combined JSON object |
spx/demo/env/telemetry/temperature_c | Subscribe — measured temperature | Numeric UTF-8 text, for example 22.5; changes while running |
spx/demo/env/command/setpoint_c | Publish plain text 24.0 | telemetry/target_c on the same prefix → 24.0 |
spx/demo/env/telemetry/target_c | Subscribe — target readback | Numeric text; initially 22.0 on a fresh instance |
spx/demo/env/telemetry/humidity_percent | Subscribe — humidity | Numeric percentage text; for example 45.0; changes while running |
Values describe this model’s nominal setup unless noted. Live measurements change as the simulation runs.
Example request and reply
Keep the subscription open, publish 24.0, and verify target_c=24.0 plus a changing temperature_c. Publish 22.0 to restore the target.
SUBSCRIBE spx/demo/env/telemetry/#
PUBLISH spx/demo/env/command/setpoint_c payload: 24.0
RECEIVE spx/demo/env/telemetry/target_c payload: 24.0
PUBLISH spx/demo/env/command/setpoint_c payload: 22.0
RECEIVE spx/demo/env/telemetry/target_c payload: 22.0No reply or an unexpected value?
- BROKER_HOST is the broker address reachable from your client. A container name such as mosquitto-server may work for SPX but not for a desktop client.
- Use your actual prefix on every topic. Send 24.0 as plain text, without JSON braces or extra quote characters.
- PUBACK confirms broker delivery; telemetry/target_c confirms device state. With retain=false, a late subscriber may miss an unchanged target.
Ask your AI agent
Open your SPX workspace in a local AI agent and ask it to run the ready-made example:
Prompt for your AI agent
Run a live MQTT quickstart using the catalog model `Env.EnvSensor.Mqtt`. Create a fresh instance with a unique name that does not conflict with existing instances. Before starting it, determine and report the existing broker address and port reachable from SPX, and separately the address and port reachable by a local MQTT client; use the same existing broker without changing any broker or network configuration. Set topic prefix `spx/demo/env`. Start the instance and confirm it reaches RUNNING. Subscribe a local MQTT client to `spx/demo/env/telemetry/#` before sending a command. Read the instance’s current `k__target_c` attribute, publish the plain-text command `24.0` to `spx/demo/env/command/setpoint_c`, then compare the received `telemetry/target_c` MQTT payload with the instance’s `k__target_c` attribute and report both values and whether they match. Confirm that `telemetry/temperature_c` arrives and changes over time. Repeat with `22.0` and verify the MQTT target and attribute both return to 22.0. Report exact topics, values, and any connection or subscription errors. Stop only the fresh test instance when done.
Tested with GPT-6 Luna · Medium
Estimated API cost · $0.0071 per run
In our test, the client received 24.0 and 22.0 on telemetry/target_c; both matched the SPX target attribute. Temperature telemetry also changed over time.
Next steps
Create a custom MQTT device with an AI agent. See the MQTT guide for adapter settings and topic bindings.
