Gateways and the Mosquitto bridge
A common field pattern: sensor nodes have no Celestian credentials. They talk to a local Mosquitto on the gateway, and only the gateway connects to Celestian through a bridge.
Preparing Celestian
Section titled “Preparing Celestian”- Create a channel (for example the route
warehouse-telemetry). - Create a device with Gateway mode on, and save the device key (shown once).
- Connect the gateway to the channel with the publish type. Add subscribe if the gateway must receive commands, configuration, or rules.
- Add a storage rule for that channel (the quick button on the channel page).
- Register the nodes as regular devices with Serial = the node’s MAC if you want Telemetry and status per node (Gateways).
The Mosquitto bridge
Section titled “The Mosquitto bridge”An example mosquitto.conf on the gateway (the ID, key, workspace, and channel are yours):
connection celestianaddress celestian.example.com:1883 # MQTT 3.1.1; or :1884 for MQTT 5clientid <gateway-ID> # production: must start with the gateway's device ID (<ID>-bridge is fine)remote_username <gateway-ID>remote_password <gateway-device-key>bridge_protocol_version mqttv311try_private false # the Celestian broker is not Mosquittocleansession false # store & forward while the WAN is downnotifications false # bridge notification topics are not channel topicskeepalive_interval 30
# A local "node/" prefix becomes a channel subtopic:# node/room-a1/telemetry → m/<workspace>/c/<channel>/node/room-a1/telemetrytopic node/# out 1 "" m/<workspace>/c/<channel>/
# Commands and configuration to the nodes (requires a subscribe connection)topic +/config in 1 m/<workspace>/c/<channel>/ ""topic +/cmd in 1 m/<workspace>/c/<channel>/ ""Notes:
<workspace>and<channel>can be a route or a UUID. Use the same form as the control widgets and the Device settings page use.- With the
client_idpolicy that requires the device ID prefix, a free-formclientidis refused. notifications truemust be off: bridge notification topics are not channel topics and are refused.cleansession falsemakes Mosquitto and the Celestian broker queue messages while the WAN link is down. The queue on Celestian lasts about one hour.allow_anonymous trueon the local listener is safe as long as it is only reachable on the LAN.- Configuration and rules sent to nodes use retained messages, so a node that powers on later still receives them. Make sure
persistence trueis set in Mosquitto.
Payload format on the gateway
Section titled “Payload format on the gateway”Nodes (or the gateway) send SenML or SenFlat so latest values, aggregation, and dashboards work. bn or id = the node MAC without separators, in lowercase. See Payload formats and SenFlat v2 for history.