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.
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