Author Topic: Temperature Reporting  (Read 543 times)

EthanSpitz

  • Newbie
  • *
  • Posts: 11
    • View Profile
Temperature Reporting
« on: August 03, 2016, 01:14:02 am »
Hi All,

I wrote script to report the temperature of the freezer, problem is the topic seems to be posting wrong.

I'm using CloudMQTT (for now)

McModule Code:
Code: [Select]
Class Temperature
    Shared Event GetTemp() RaiseEvent Every 10 Seconds
        Dim TempC As Float = TempSensor.GetTemp
        Dim TempF As Float = TempSensor.ToFarenheit(TempC)
       
        Dim payload As ListOfByte = New ListOfByte
       
        payload.AddFloat(TempF)
        Lplan.Publish("FreezerTemp", payload)
    End Event
End Class

The Websocket shows "mcThings/beacon/00010F09/00011168" as the topic.

Anyone know why? Is this a bug?

Share on Facebook Share on Twitter Share on Google+


EthanSpitz

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Temperature Reporting
« Reply #1 on: August 03, 2016, 01:20:12 am »
Seems to be a bug. I restarted mc-Studio and reconnected and rebuilt and it worked that time.

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Temperature Reporting
« Reply #2 on: August 03, 2016, 02:49:13 am »
Hello.
That is not a bug, when you setup a MQTT server for your mcGateway then the mcGateway publish all the beacons that your mcModules is communicating to the mcGateway.
So what you did see was not published from your code it was the beacon.

EthanSpitz

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Temperature Reporting
« Reply #3 on: August 13, 2016, 10:06:04 pm »
Thanks! I don't know why I didn't respond to this when you replied! :)

Arham.Mansoor

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Temperature Reporting
« Reply #4 on: October 20, 2016, 03:09:43 pm »
Hello,
So Im also using cloud MQTT also going through same thing. So what are you guys using for publishing? Im not programmer so if anyone can please do a short walkthrough of whats being used & how it would be great help.
much thanks in advance.

Nick_W

  • Full Member
  • ***
  • Posts: 214
    • View Profile
Re: Temperature Reporting
« Reply #5 on: October 20, 2016, 11:04:28 pm »
Arham,

When you publish, for example

Code: [Select]
Lplan.publish("Temperature","info")

It will be published to <base>Temperature whatever your <base> is on cloudMqtt. To make this easier, I use a leading /MCThings/, so that I can list <base>/MCThings/#

I'm not using cloud Mqtt (mosquito), but it's the same. If you see mcThings/beacon/xxxx these are the beacons from your modules, they publish to automatic topic names.

There is no automatic naming for things you publish yourself.

Arham.Mansoor

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Temperature Reporting
« Reply #6 on: October 21, 2016, 10:13:26 am »
Thanks. I see what you mean. But me after trying to figure out what going on I cant see modules publications as well. They have batteries & beacon data is being updated on gateway but when I see it in cloud MQTT not there anymore. I have not changed the configuration much on MC Gateway. Im sorry if these questions seem simple. Im trying to learn this and any help is appreciated. 

Nick_W

  • Full Member
  • ***
  • Posts: 214
    • View Profile
Re: Temperature Reporting
« Reply #7 on: October 21, 2016, 10:25:44 am »
I think one of the problems is that I don't know what you see on Cloud MQTT. I use mosquito, and if I publish to "/MCThings/test" I see that in my subscriptions.

One thing that is a bit of a challenge is that you can only publish ListOfByte objects, but the examples should all work.

You have to do the following:

Code: [Select]
Dim payload As ListOfByte = New ListOfByte
payload.Add("test")
Lplan.Pubish("MyTopic", payload)

Then look for "MyTopic", I publish once per 10 seconds minimum, don't do less (say 1 second) as it doesn't work. You can't hit the gateway with lots of publishing one after the other. Eventually the module just stops publishing.

Ignore the mcThings/XXX stuff, that's just beacons from the modules showing they are alive (you can put data in the beacon, but walk before you run!).

Hope this helps.

Arham.Mansoor

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Temperature Reporting
« Reply #8 on: October 23, 2016, 11:22:03 pm »
Nick_W,
Appreciate your help alot. I got what I needed & have much better understanding now. Would not have accomplished without your assistance.
Thanks

PS...Should be able to do more experimenting now.