Author Topic: Connection Problem  (Read 922 times)

Nick_W

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Connection Problem
« on: July 20, 2016, 01:03:28 pm »
This works in run mode, but causes resets in embed mode.

Code: [Select]
//
// This example logs the mc Unique IDentifier (mcUID) and the Temperature
// to MQTT.
//

Class Temperature
   
    Shared mcUIDString As String
    Shared Event Boot()
        mcUIDString = Device.mcUID().ToString()
    End Event
   
    Shared Event GetTemp() RaiseEvent Every 1 Minutes
        LedGreen = True
       
        Dim TempC As Float = TempSensor.GetTemp
        Dim Temppayload As ListOfByte = New ListOfByte()
       
        Temppayload.Add(TempC.ToString)
       
        Lplan.Publish("MCThings/" + mcUIDString + "/Temperature", Temppayload)
       
        LedGreen = False
    End Event
   
    Shared Event GetUptime() RaiseEvent Every 1 Minutes
        //LedRed = True
       
        Dim uptime As Integer = Device.Uptime()
        Dim uptimeString As String = uptime.ToString()
        Dim Uptimepayload As ListOfByte = New ListOfByte()
       
        Uptimepayload.Add(uptimeString)
       
        Lplan.Publish("MCThings/" + mcUIDString + "/Uptime", Uptimepayload)
       
        //LedRed = False
    End Event
   
    //Shared Event CheckVoltage() RaiseEvent Every 2 Days
    Shared Event CheckVoltage() RaiseEvent Every 2 Minutes
        Dim BattVolt As Short = Device.BatteryVoltage
        Dim Battpayload As ListOfByte = New ListOfByte()
        Battpayload.Add(BattVolt.ToString)
        Lplan.Publish("MCThings/" + mcUIDString + "/BatteryVoltage", Battpayload)
        //If BattVolt < 2200 Then
        //Lplan.IFTTT("YOURIFTTTKETHERE", "ProductionRoomBattery/YOURTOPICHERE")
        //Else
       
        //End If
       
    End Event
End Class

It will publish, but resets every minute or so (so uptime is 0). Works fine in debug though. the difference is in lines 30-33 (two step). Will continue to investigate.