Author Topic: Getting started with a mcPlug  (Read 320 times)


  • Newbie
  • *
  • Posts: 9
    • View Profile
Getting started with a mcPlug
« on: April 01, 2017, 11:28:30 pm »
I just received my mcPlugs and I'm trying to figure out how to get started.  It looks like I need to provide my own power cables, I've got to see if I can find anything that matches this, but I was kind of expecting to have the cables included. 

How do we go about controlling the mcPlug?  Are there any examples of code that I can use to work with them?

Share on Facebook Share on Twitter


  • Administrator
  • Sr. Member
  • *****
  • Posts: 252
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: Getting started with a mcPlug
« Reply #1 on: April 03, 2017, 09:54:10 am »
Hey Veleek,

Glad you received your plugs! We were trying to get a project done using the mcPlug last week to showcase on however this didn't quite happen - mostly because we were too busy setting up the new website (It is live now so check it out!).
We are going to try and put together a project to showcase the mcPlug and some of the cool things you can do with it this week.
In the meantime, below is some code to help you get going:

Code: [Select]
Class mcPlugSub
    Const mcPlugTopic As String = "mcThings/plug"
    Shared Event Boot()
    End Event
    Shared Event SubscriptionDelivery()
        Dim msg As Message = Lplan.GetDelivery()
        If msg.Topic= mcPlugTopic Then
            Relay = Not Relay
        End If
    End Event
End Class

The above code sets the plug to be in mid-power mode (basically a constant connection to the mcGateway). If the device receives the MQTT topic "mcThings/plug" it will then turn on the relay and provide power to whatever you have connected to the plug!
Some examples of what you can do:
- Setup a fan connected to the plug. You can then have another module checking temperature and if too hot, then it can send a message and turn on the fan
- I have setup a module connected to a switch/button (there is also a switch built-in to the mcModules too!) that can turn on or off the relay on the plug.

We'll do our best to get a project up this week to give you a better starting point. Hope that helps!
Need more mc-Modules, mc-Gateways or other mc-Things? Check out our product page: mc-Development kits are available too!
Check out a live Dashboard using mcThings and Losant! Click here: