Sensorclouds
MQTT Connectivity

Connecting Your Device

Connect a device to Sensorclouds, send its first reading, and set up online/offline status

ADMIN ENGINEER

This page takes a registered device from "nothing" to "first reading in Live Data".

Before you begin

  • A registered device. See Registering Devices.
  • Its Device Token and MQTT password, from Device → Settings.
  • Its topics, from Device → Overview → MQTT Topics (use the copy buttons).
  • A device profile using the CUSTOM codec with a decoder for your payload. For JSON, use the JSON decoder.

Step 1: Configure the connection

ParameterValue
Hostmqtt.sensorclouds.app
Port8883
TLSOn. Trust the Let's Encrypt ISRG Root X1 certificate (most systems already do)
UsernameDevice Token, for example dev_9f2c41a7…
PasswordThe generated MQTT password
Client IDDevice Token
Keep-aliveThe same as the profile (60 seconds by default)

Step 2: Set the Last Will (before connecting)

Registering a Last Will lets the broker mark the device offline automatically if it drops.

SettingValue
Will topictenant/{tenantId}/app/{applicationId}/device/{deviceToken}/status
Will payload{"status": "offline"}
Will QoS1
Will retaintrue

Step 3: Connect and publish your first reading

Publish JSON to the data topic:

tenant/{tenantId}/app/{applicationId}/device/{deviceToken}/data
{"temperature": 21.5, "humidity": 48}

Quick test from a computer (with the mosquitto_pub MQTT command-line client installed):

mosquitto_pub \
  -h mqtt.sensorclouds.app -p 8883 \
  --capath /etc/ssl/certs \
  -i "dev_9f2c41a7..." -u "dev_9f2c41a7..." -P "YOUR_MQTT_PASSWORD" \
  -q 1 \
  -t "tenant/TENANT_ID/app/APP_ID/device/dev_9f2c41a7.../data" \
  -m '{"temperature": 21.5, "humidity": 48}'

On Windows or macOS, replace --capath /etc/ssl/certs with --cafile isrgrootx1.pem (download it from letsencrypt.org).

Step 4: Set up online / offline status

Right after connecting, publish to the status topic with retain = true:

{"status": "online"}

Together with the Last Will, this gives you accurate online/offline status. See Device Status.

Step 5: Subscribe to commands

Subscribe to the command topic (QoS 1) so the device can receive commands and firmware updates:

tenant/{tenantId}/app/{applicationId}/device/{deviceToken}/cmd

See Command Lifecycle for the message format and how to acknowledge.

Step 6: Verify

Open the application's Live Data page. You should see Uplink received within a second or two.

Click the row. Decoded payload should show your fields.

The device's status should read ONLINE.

You seeNext step
Uplink received with fieldsYou're done. Build a dashboard
Uplink received, but no decoded fieldsSet the profile's codec to CUSTOM with a decoder
Decode failedFix the decoder. See Payload Decoder
Nothing at allSee Connection Troubleshooting

Next Steps

On this page