This guide will walk you through how to subscribe your devices’ messages as well as how to send a command to a specific device, using Eclipse Mosquitto’s CLIs to subscribe or publish messages.



Browse SenseCAP Portal, navigate to “Security/Access API keys”, click the “Create Access Key”, and you can get the “Access API keys”, set down it as <Password>, and also “Organization ID” as <OrgID>.

Receive Devices’ Messages

Let’s listen for all of your devices’ messages.

1.Open a terminal window and execute the following command.

  • OrgID = Organization ID
  • Password = Access API keys
mosquitto_sub \
    -h \
    -t '/device_sensor_data/<OrgID>/+/+/+/+' \
    -u 'org-<OrgID>' \
    -P '<Password>' \
    -I 'org-<OrgID>-quickstart' \

Please replace the Organization ID and Access API Key you just obtained with the <OrgID> and <Password> above.

2.Power up devices, while devices keep sending messages, you should receive the data like:

/device_sensor_data/1234/2CF7F12000000001/1/vs/4105 {"value":2,"timestamp":1544151824139}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4097 {"value":23,"timestamp":1544151900992}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4101 {"value":101629,"timestamp":1544151901112}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4098 {"value":71,"timestamp":1544151900992}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4099 {"value":69.12,"timestamp":1544151902224}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4100 {"value":437,"timestamp":1544151922137}
example field description
1234 OrgId Organization ID
2CF7F12000000001 DeviceEUI Unique identification of device
1 Channel A physical socket on the device for a sensor to be connected
vs Reserved The reserved field
4105 MeasureID The type of measurement, 4105 is the Wind Speed
2 value Collected measurements, the Wind Speed is 2m/s
1544151824139 timestamp The collection timestamp of the data

Subscribe a Specific Key

Specifying a specific key enables you to subscribe to data for a particular device or channel.

Subscribe to the temperature value collected by the Air Temperature and Humidity Sensor (DeviceEUI: 2CF7F12210400083;Channel: 1;).The temperature measurement ID is 4097.
Replace <OrgID> as Organization ID, <Password> as Access API Key, execute the command:

mosquitto_sub \
    -h \
    -t '/device_sensor_data/<OrgID>/2CF7F12210400083/1/vs/4097' \
    -u 'org-<OrgID>' \
    -P '<Password>' \
    -I 'org-<OrgID>-quickstart' \

Received the data:

/device_sensor_data/521853156991/2CF7F12210400083/1/vs/4097 {"value":28,"timestamp":1561373812474}

Congratulations! Now you know how to monitor and receive messages via MQTT. Go build something awesome!