Author Topic: McPlug  (Read 239 times)

davecason

  • Newbie
  • *
  • Posts: 9
    • View Profile
McPlug
« on: May 14, 2017, 03:54:58 pm »
Hi, 

Can you guys point me in the right direction for using a mcplug to turn on a light using the time of day?

Is there already code written to use the gateway to monitor the computers time or a NIST server out there for the correct time of the day.
Then tell the mcplug to turn on and off at set times ?

That's gotta be a common use for a mcplug I would think ..........

Cheers'
Dave

Social Buttons


mc-T2

  • Administrator
  • Full Member
  • *****
  • Posts: 246
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: McPlug
« Reply #1 on: May 16, 2017, 12:37:46 am »
Hey Dave,

We have created an example project that we posted on the forum and on our Hackster hub.
Check out this post here: http://mcthings.createaforum.com/mc-innovations/mcplug-hackster-project!-396/msg1918/#msg1918

Check out the Hackster project here: https://www.hackster.io/mc-Things/using-the-mcplug-for-iot-applications-8c2183

In regards to your question, there is no specific function to set an even to happen at a specific time however what you can do is have the device check the time at certain intervals and if the device finds that the time is within your specifications, then you can have the plug turn on or off something.

Hope that helps!
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

davecason

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: McPlug
« Reply #2 on: May 18, 2017, 09:43:38 pm »

Ya no,  I saw that .....it's no good.

I just want a simple script that pings a time server, or gets the time and keeps track of it, or tracks a standard clock.

And at time "A " it turns on the mcplug and at time " B " it turns it off.

Pretty much the most obvious thing for a 120v switch ..... do you guys have anything?
A buddy sent me this:

VER 1
-----------------------------------------------------------------------
Class test
    Shared Event ACPlug() RaiseEvent Every 1 Minutes
        Dim Hr As Byte
       
        Hr = Hour (DateTime.Hour ())
        Relay = (Hr >= 8 And Hr < 20)
    End Event
End Class

--------------------------------------------------------------------

VER 2

1. Start McStudio
2. File -> New Project. Lets say you call it "Plug1" this time.
3. Give it a name WITHOUT spaces in it. That's a known bug.
4. Set the dropdown device type to mcPlug120
5. Try this out:

Class Plug1
    Shared Event ACPlug RaiseEvent Every 1 Minutes
        Dim Hr as Byte

        Hr = Hour()
        Relay = (Hr >= 8 and Hr <20)
    End Event
End Class


Cheers'
Dave

mc-T2

  • Administrator
  • Full Member
  • *****
  • Posts: 246
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: McPlug
« Reply #3 on: May 21, 2017, 09:03:35 am »
Quote
it's no good.
The example does work quite well, so I am not sure what the issue is other than that it doesn't do exactly as you wish. I pointed it out as an example of mcPlug code that you can take and modify for your own use

As mentioned, this is not a function that is built-in to the platform at this time. However, as mentioned, there are work-arounds so that you can design your own program. Have you tried to write your own script? Here is the help I provided in my previous reply:
Quote
there is no specific function to set an even to happen at a specific time however what you can do is have the device check the time at certain intervals and if the device finds that the time is within your specifications, then you can have the plug turn on or off something.

Have you looked at incorporating the examples your buddy sent over? You may also want to check around the forum as there are some recent questions and discussions about timestamps and their usage.
As mentioned, there are ways to do this. Part of the great thing about the mcThings platform is that there are almost endless ways you can program and modify devices which is why it is nearly impossible to have an example of everything you can do.

That said, if you read the documentation and take the time to putting something together, you can then provide an example script to others if you wish.
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

davecason

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: McPlug
« Reply #4 on: May 24, 2017, 05:19:52 pm »
Ya know  ......  This getting annoying ! 

Here I have a fuggen Dell Workstation - a T7400 with two Xeon E5440's processors and 64 GB of RAM and for shits and giggles 9.3TB of space.

It'd be freaken great if the damm McStudio app didn't crash every single time I write something in the app for the McPlug.

I'm pretty sure it's NOT the computer and everything else connected to it, or in it, seems to run pretty damm happy, and has so done for a year !

(sigh) 

Cheers'
Dave

mc-T2

  • Administrator
  • Full Member
  • *****
  • Posts: 246
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: McPlug
« Reply #5 on: May 30, 2017, 02:30:57 pm »
Dave,
There is a new release today of mcStudio (and new versions of mcOS for all devices/modules). There are a lot of bugs/crashes that were fixed i this version so please be sure to download it. Should help to resolve the issues you noted about the application crashing sometimes

You can check out a portion of the release notes for mcStudio in this post: http://mcthings.createaforum.com/system-updates/new-release!-v0-9-for-mcstudio-mcos-for-all-devices!/
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