mcThings
Published © GPL3+

Wireless IoT Temperature Monitoring Displayed in Cayenne

This project uses the mcModule120 to send temperature into myDevices' Cayenne application using MQTT!

Beginner30 minutes1,055
Wireless IoT Temperature Monitoring Displayed in Cayenne

Things used in this project

Hardware components

mcMod120 Module
mcThings mcMod120 Module
×1
mcGateway110
mcThings mcGateway110
×1

Software apps and online services

mcStudio
mcThings mcStudio
Cayenne
myDevices Cayenne
MQTT
MQTT

Story

Read more

Schematics

mcModule120 Product brief

Code

mcMod120 programming

mcScript
Class MyDevicesTemp
    
    Const mdUserId As String = "YOUR CAYENNE MQTT USERNAME"
    Const mdClientId As String = "YOUR CAYENNE MQTT CLIENT ID"
    Const mdChannel As String = "0"
    
    // 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 60 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 MyDevices preferred JSON object - { "data" : {"temperature" : "23.06"}}
        Dim myDevicesPayload As Json = New Json
        
        
        myDevicesPayload.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 Cayenne MQTT
        Lplan.Publish(mdTopic, mdPayload)
        
    End Event
End Class 

Credits

mcThings

mcThings

17 projects • 52 followers
Use mcThings to quickly & easily create, test and deploy IoT solutions for industrial, business/commercial and individual needs!

Comments

Add projectSign up / Login