Question regarding the use of channels


#1

In the BYOT MQTT message format, the topic for sending sensor data is:

v1/username/things/clientID/data/channel

Can a single channel be used to send multiple different sensor data?

In my topology, I might have a gateway, with several bluetooth sensor nodes attached, each having multiple sensors on it (Temperature, Pressure, Humidity).

Should I do this? I could send three messages with different data on the same topic (channel), for example:
v1/username/things/clientID/data/0
temp,c=value
v1/username/things/clientID/data/0
press,psi=value
v1/username/things/clientID/data/0
rel_hum,p=value

Or would I need to separate each sensor by channel?

v1/username/things/clientID/data/0
temp,c=value
v1/username/things/clientID/data/1
press,psi=value
v1/username/things/clientID/data/2
rel_hum,p=value


#2

Cayenne widgets are tied to individual data channels at the moment, so I would recommend using the latter publishing strategy. There shouldn’t be any limit to the amount of channels you can utilize.

We are experimenting with a JSON format where you can send multiple data points like above in the same payload, which may offer an alternative in the future if it’s more convenient for you to cluster the data.


#3

Thanks! I’ve been able to get one sensor to show up in the dashboard. But i’m having problems getting multiple sensors to show up.

I’m publishing data for each sensor immediately after publishing the previous sensor like this. I’m getting some timeouts, though. Is it possible that the Cayenne MQTT broker needs some time in between publishes?

Also, another thing - it looks like I can make the Channel to be anything I want, so I’ve concatenated a device ID for the sensor (a bluetooth MAC address) and a number to indicate the sensor. Does that present a problem for Cayenne in the long run?

// Send temp on channel 0
ub_ustdio_snprintf(topic, sizeof(topic), "v1/%s/things/%s/data/%s-%d" ,
		MQTT_USERNAME, MQTT_CLIENT_ID, deviceid,0);

msglen =  ub_ustdio_snprintf( msg, sizeof(msg),
            "temp,c=%d", temp);

mqtt_publish_data_mydevices(session,topic,msg, msglen+1);

// Send humidity on channel 1
ub_ustdio_snprintf(topic, sizeof(topic), "v1/%s/things/%s/data/%s-%d" ,
		MQTT_USERNAME, MQTT_CLIENT_ID, deviceid,1);

msglen =  ub_ustdio_snprintf( msg, sizeof(msg),
            "rel_hum,%%=%u", humidity);

mqtt_publish_data_mydevices(session,topic,msg,msglen);

// Send ambient light on channel 2
ub_ustdio_snprintf(topic, sizeof(topic), "v1/%s/things/%s/data/%s-%d" ,
		MQTT_USERNAME, MQTT_CLIENT_ID, deviceid,2);

msglen =  ub_ustdio_snprintf( msg, sizeof(msg),
            "lighting_sense,lux=%u", ambient);

mqtt_publish_data_mydevices(session,topic,msg,msglen);

#4

BTW, I think this is an excellent idea. Let me know if you need a beta tester for that.