Things used in this project

Hardware components:
Mcplug perspective 1000px 4nu2utqvdj
mcThings mcPlug
A relay with an embedded mcModule120 that allows you to provide power to a 'plugged in' device/appliance/etc!
×1
Mc devkit100a scojkvv1ol
mcThings mcModule120 Dev Kit
We recommend a kit for this example so that you have multiple modules to gather information from (Not required but you will need at least one mcModule, one mcGateway and an mcDongle)
×1
Product mcmod120 top front back p8hs3xepwv
mcThings mcMod120 Module
You'll need at least one mcModule120 for this project
×1
Mcgateway110 perspective 1000px iqkgknswa5
mcThings mcGateway110
You'll need an mcGateway for this project
×1
Mcdongle perspective 1000px pcdfntbxl3
mcThings mcDongle
You'll need one of these to complete your firmware updates! Be sure to update your firmware to the latest versions before starting
×1
Software apps and online services:
Mcstudio h8lhxdnyfz
mcThings mcStudio
IDE for programming mcThings gear
Screen%20shot%202016 03 01%20at%209.14.06%20pm
Losant Platform
Comprehensive IoT cloud application
Losant icon
Losant Go Mobile App
Losant's mobile app - not required but fun to use!
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service
Used if you wish to send the information to another service using IFTTT
MQTT

Schematics

mcMod120 brief

Code

mcPlug Subscribe codemcScript
Used to program the mcPlug to receive incoming MQTT messages and then give power or not to a device/appliance/etc
Class FanTempSubscribe
    Shared Event Boot()
        Lplan.SetMidPowerMode(1)
        Lplan.Subscribe("mcThings/FanOn")
        Lplan.Subscribe("mcThings/FanOff")
    End Event
    Shared Event SubscriptionDelivery()
        Dim msg As Message = Lplan.GetDelivery()
        If msg.Topic= "mcThings/FanOn" Then
            Relay = True
        ElseIf msg.Topic= "mcThings/FanOff" Then
            Relay = False
        End If
    End Event
End Class
mcModule MQTT and IFTTT publishmcScript
checking the temperature and then sending a unique MQTT topic to your broker as well as option to send information to IFTTT
Class FanTempPublish
    
    'Set a constant MQTT topic
    Const mcPlugOn As String = "mcThings/PlugOn"
    Const mcPlugOff As String = "mcThings/PlugOff"
    
    'Optional to set module to mid-power mode if you wish
    'Shared Event Boot()
    '    Lplan.SetMidPowerMode(2)
    'End Event
    
    'Check temperature every XX seconds/minutes/days
    Shared Event CheckTemp() RaiseEvent Every 30 Seconds
        Dim TempC As Float = TempSensor.GetTemp
        Dim TempF As Float = TempSensor.ToFarenheit(TempC)
        'program logic for IFTTT and MQTT topic publish  
        If TempC > 25.0 Then
            LedRed = True
            Lplan.IFTTT("YOURIFTTKEYHERE", "FanOn")
            Dim payloadOn As ListOfByte = New ListOfByte()
            payloadOn.Add(1)
            'publish topic to MQTT broker
            Lplan.Publish(mcPlugOn, payloadOn)
            LedRed = False
        ElseIf TempC < 24.99 Then
            LedGreen = True
            Lplan.IFTTT("YOURIFTTTKEYHERE", "FanOff")
            Dim payloadOff As ListOfByte = New ListOfByte()
            payloadOff.Add(1)
            'publish topic to MQTT broker
            Lplan.Publish(mcPlugOff, payloadOff)
            LedGreen = False
        Else   
        End If
    End Event
End Class 

Credits

Avatar 2 1464902871 1r3seyaity
mcThings

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

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Drink Alert!!! (Beverage Can Monitor)
Easy
  • 281
  • 4

Full instructions

Tired of going to grab a soda only to find they're all gone!? Well now you have an alert system to let you know when you need to refill.

The Food Thief Catcher
Easy
  • 123
  • 4

Work in progress

Are you tired of all of your pesky roommates stealing your food? Me too, thats why we have the Food Thief Catcher!

Happy Wife =  Happy Life
Easy
  • 228
  • 3

Full instructions

Wife not a morning person? Improve your life by improving your wife's temperament in the morning. Fresh coffee makes wife happy!

Happy Wife = Happy Life

Team We Are Not Coders

Temperature Sensor
Easy
  • 332
  • 5

Full instructions

A photon that measures the temperature and humididty with a DHT 22 sensor and communicates the temperature data to another photon.

MQTT for IoT Devices, Support TLS/SSL, QoS Level: 0, 1, 2
Easy
  • 189
  • 7

Protip

This project describes MQTT library for an IoT Platfrom so-called PHPoC. This library supports MQTT over TLS/SSL and all QoS Level: 0, 1, 2.

IFTTT's Android SMS Service with PHPoC Blue
Easy
  • 286
  • 7

This project shows how to use IFTTT Maker channel.

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback