Author Topic: Cayenne My Devices  (Read 1395 times)

sketchet

  • Newbie
  • *
  • Posts: 1
    • View Profile
Cayenne My Devices
« 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.

Share on Facebook Share on Twitter


mc-T2

  • Administrator
  • Sr. Member
  • *****
  • Posts: 252
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: Cayenne My Devices
« Reply #1 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!
Need more mc-Modules, mc-Gateways or other mc-Things? Check out our product page: www.mcthings.com/products. mc-Development kits are available too!
Check out a live Dashboard using mcThings and Losant! Click here: https://goo.gl/ST43hB

Labmaster

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Cayenne My Devices
« Reply #2 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   

mc-John

  • Global Moderator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Cayenne My Devices
« Reply #3 on: November 30, 2017, 10:05:19 am »
Can you show your gateway set?

Labmaster

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Cayenne My Devices
« Reply #4 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)
Winner Winner x 1 View List

mcThings

  • We Connect Things To The Internet... That Can't Be Plugged In.
  • Administrator
  • Jr. Member
  • *****
  • Posts: 68
    • View Profile
    • www.mcthings.com
Re: Cayenne My Devices
« Reply #5 on: December 01, 2017, 01:46:05 pm »
@Labmaster - Great work! Thanks for keeping us posted!