Author Topic: re-Post "Finding my way around McThings"  (Read 609 times)

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: re-Post "Finding my way around McThings"
« on: June 07, 2016, 03:32:38 am »
Hello.
If you download mcStudio V0.7-891+ then it is possible to use the temperatur sensor.
I cant get MQTT running with version V0.6-355 of the mcRouter so right now i recommend using V0.6-354.

1: Start mcStudio and click Tools / Devices, Connect to your gateway and then click Gateway Config. Enter your MQTT broker IP address and port and save the config.
2: Connect to one of your mcModules.
3: create a new project and a simple code like this will do a reading from the temperatur sensor and then publish the result to your MQTT broker with topic mcThings/Temperature/BasementA and the temperatur as the payload.

Code: [Select]
Class MQTTTest
    Shared Event sendMQTT() RaiseEvent Every 1 Minutes
        LedRed = True
       
        Dim payload As ListOfByte = New ListOfByte()
        Dim TempC As Float = TempSensor.GetTemp
        Dim TempString As String = TempC.ToString()
       
        payload.Add(TempString)
       
        Lplan.Publish("mcThings/Temperature/BasementA", payload)
       
        LedRed = False
    End Event
End Class

4: click File / Add Library Code and select Temp Sensor.
5: Save / Build / Run the application and your mcModule will start sending MQTT messages with the temperatur to the broker.
6: when you are happy with the function click Save / build/ Load the program in the device, to save the code so that it will continue to run when you stop the debugging

mcThings have published information videos on some of the parts mentioned above, please take a look at it and i think things fill fall into place for you.
https://www.youtube.com/channel/UC3vwTRcjtJ9Y8_h5M3-oRtw/videos

And if you have any questions, just let us know.

Like Like x 1 View List