const mqtt = require('mqtt');
const client = mqtt.connect('mqtts://mqtt.datacake.co', {
username: "yourauthtoken",
password: "yourauthtoken"
client.on('connect', () => {
console.log('Connected to Datacake Cloud');
// subscribe to all fields from that devices
// can be used to send messages from datacake onto device
client.subscribe('dtck/my-mqtt-device/b4fb3cae-9387-46ac-8d6c-687f3d94f1e2/+');
client.on('message', (topic, message) => {
// Publish a value of 23.02 to Datacake and Device Field
client.publish('dtck-pub/my-mqtt-device/b4fb3cae-9387-46ac-8d6c-687f3d94f1e2/TEMPERATURE', 23.02);