Author Topic: mc-Things MQTT Reed Switch Example  (Read 154 times)

mcThings

  • We Connect Things To The Internet... That Can't Be Plugged In.
  • Administrator
  • Jr. Member
  • *****
  • Posts: 68
    • View Profile
    • www.mcthings.com
mc-Things MQTT Reed Switch Example
« on: July 19, 2016, 11:12:03 am »
mc-Things MQTT Reed Switch Example
In this video Tom Edworthy goes over the set up and implementation of MQTT in a Reed Switch example, with a door opening and closing.

https://youtu.be/WfkQmg5P-3k

Code: [Select]
Class ProductionRoom/YOURPROJECTNAMEHERE
Shared Event ReedSwitchChanged()

Dim payload As ListOfByte = New ListOfByte
Dim payString As String = ""

If ReedSwitch = True Then
LedRed = True
payString = "Open"
Else
LedRed = False
payString = "Closed"
End If
payload.Add(payString)
Lplan.Publish("mcThings/ProductionRoomDoor/YOURTOPICNAMEHERE", payload)
Thread.Sleep(10000)
Thread.ClearHardwareEvent()
Dim uptime As Integer = Device.Uptime()

End Event

Shared Event CheckVoltage() RaiseEvent Every 2 Days
Dim BattVolt As Short = Device.BatteryVoltage
If BattVolt < 2200 Then
Lplan.IFTTT("YOURIFTTTKETHERE", "ProductionRoomBattery/YOURTOPICHERE")
Else

End If

End Event

Social Buttons