mc-Things

mc-Platform => MQTT => Topic started by: sketchet on December 28, 2016, 06:12:45 pm

Title: Cayenne My Devices
Post by: sketchet on December 28, 2016, 06:12:45 pm
Has anyone had any luck getting an mc-Gateway connected to Cayenne? I have been able to publish to CloudMQTT but have not been able to connect the mc-Gateway to Cayenne.
Title: Re: Cayenne My Devices
Post by: mc-T2 on January 03, 2017, 09:27:40 am
Hello,
MyDevices is still working to allow connection through MQTT. Hopefully this is available soon. As soon as this is good to go we will announce it on the forum
Thanks!
Title: Re: Cayenne My Devices
Post by: Labmaster on November 27, 2017, 11:41:42 pm
My Devices has MQTT support now.  I'm trying to send temperature, but I can't figure out correct lplan.publish stuff.

Code: [Select]
// MQTT topic in MyDevices.com - v1/username/things/clientID/data/channel
    Const mdTopic As String = "v1/" + mdUserId + "/things/" + mdClientId + "/data/" + mdChannel
    Shared Event CheckTemp() RaiseEvent Every 10 Seconds
        Dim temp As Float = TempSensor.GetTemp() // Get Temp from sensor
        Dim tempString As String = temp.ToString()
        // Create temp JSON object - { "temperature" : "23.06" }
        Dim tempJson As Json = New Json
        //tempJson.Add("temperature", tempString)
        tempJson.Add("temp,c=", "99")
        // Create Wia preferred JSON object - { "data" : {"temperature" : "23.06"}}
        Dim wiaPayload As Json = New Json
        //wiaPayload.Add("data", tempJson)
        wiaPayload.Add("temp,c=99")
        Dim mdData As String = "temp,c=99"
        // Publish to wia MQTT
        Lplan.Publish(mdTopic, mdData.ToListOfByte)
        Lplan.
       
        // Blink Red LED after publish to MyDevices.com
        LedRed = True
        Thread.Sleep(100000)
        LedRed = False
    End Event   
Title: Re: Cayenne My Devices
Post by: mc-John on November 30, 2017, 10:05:19 am
Can you show your gateway set?
Title: Re: Cayenne My Devices
Post by: Labmaster on December 01, 2017, 11:06:10 am
I actually got it working last night.  It turns out that I had 2 devices defined in MyDevices.com, and I was using the correct client ID in the gateway, and the wrong clientID in the code.

This is the most recent version of my working code:
Code: [Select]
    // MQTT topic in MyDevices.com - v1/username/things/clientID/data/channel
    Const mdTopic As String = "v1/" + mdUserId + "/things/" + mdClientId + "/data/" + mdChannel
    //Const mdTopic As String = "kevin/MyDevicesCom/test"
    Shared Event CheckTemp() RaiseEvent Every 3600 Seconds
        Dim temp As Float = TempSensor.GetTemp() // Get Temp from sensor
        Dim tempString As String = temp.ToString()
        // Create temp JSON object - { "temperature" : "23.06" }
        Dim tempJson As Json = New Json
        //tempJson.Add("temperature", tempString)
        tempJson.Add("temp,c=", "99")
        // Create Wia preferred JSON object - { "data" : {"temperature" : "23.06"}}
        Dim wiaPayload As Json = New Json
        //wiaPayload.Add("data", tempJson)
        wiaPayload.Add("temp,c=99")
        Dim mdPayload As ListOfByte = New ListOfByte
        Dim mdData As String = "temp,c=" + tempString
        //mdData = "temp,c=99"
        mdPayload.Add(mdData)
        // Publish to wia MQTT
        Lplan.Publish(mdTopic, mdPayload)
Title: Re: Cayenne My Devices
Post by: mcThings on December 01, 2017, 01:46:05 pm
@Labmaster - Great work! Thanks for keeping us posted!