Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Nick_W

Pages: 1 ... 13 14 [15]
211
mc-Module / 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.

212
mc-Module / Re: Connection Problem
« on: July 20, 2016, 12:49:41 pm »
This is what I'm doing

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(uptime.ToString)
       
        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

I think it's the
Code: [Select]
Uptimepayload.Add(uptime.ToString) that is the problem, as the one module I have that is working keeps resetting, but does publish from time to time. (that's why uptime is always 0).

I'm currently stuck in debug mode - so as soon as I get out of that I'll revert to the two step assignment and see if that fixes the reset.

213
mc-Module / How do Variables work?
« on: July 20, 2016, 12:25:59 pm »
I am having a hard time understanding how Variables work.

I want to use the device UID for the MQTT publish string (to identify the device publishing). I can do that by defining
Code: [Select]
Dim mcUIDString as String = Device.mcUID().ToString()in each Shared Event (although this may not work, as I had to do it as a two step thing earlier, ie dim an integer, then convert to string).

I thought, OK just define this as a class variable, then use it in each Shared Event, no need to duplicate. Cannot figure this out. Very frustrating >:(. Have read the manual, but the very few examples are obscure and not very helpful.

I would think that you could define the variables as Public or Private Class variables (like many OO languages).

Code: [Select]
Public mcUIDString As String = Device.mcUID().ToString()
Then in a Shared Event use:

Code: [Select]
Lplan.Publish("MCThings/" + mcUIDString + "/Temperature", Temppayload)
No. Error is "Cannot refer to an instance method of a class without an explicit instance of the class". Hmm, add the class name?  ("Temperature.mcUIDString"?). No. "Variable is not a shared member". Add reference to the current instance ("Me.mcUIDString"?). No. same error as first try. I just can't figure out how to use Private or Public like a static variable. Must involve the use of New somehow. Shared variables only take a literal as an initializer, so...

The thing that worked (and is very odd) is:

Code: [Select]
Shared mcUIDString As String
    Shared Event Boot()
        mcUIDString = Device.mcUID().ToString()
    End Event

Now I can use  mcUIDString as a string in my class for the MQTT publish topic, like this :

Code: [Select]
Lplan.Publish("MCThings/" + mcUIDString + "/Temperature", Temppayload)
Is it really this hard? what am I missing? How do you define class variables that you can use in any class sub/function/event like a static variable? I cant define variables outside a class. How do you define a variable that is not class instance specific but common to all instances of that class?

I am familiar with C/C++ and python, not VB.NET.

Any help/explanation is appreciated.

214
mc-Module / Connection Problem
« on: July 20, 2016, 11:44:09 am »
Just Got my MC Modules etc. and set up. Downloaded all the latest versions, and updated firmware. See screenshot.


Had all sorts of problems connecting to a test module with the gateway hard wired (Ethernet), but beacons showed OK. So I changed to WiFi and moved everything close together (hard wired Ethernet is in the basement, so I though distance may be a factor). RSSI was showing 177 (what units? not standard db units anyway).

Now I can connect (occasionally), so I modified the temperature example (which is incomplete by the way), and set MQTT publishing to my MQTT broker (mosquitto) every 1 minute. This sort of worked (ie it published every 5 minutes or so).

I added UID and uptime, and again it sort of worked. Downloaded to flash RAM, and now it doesn't work at all. Does not publish, and will not connect. Device is 000111BC.

Green LED flashes immediately followed by red LED every 5 seconds. Beacon updates, and I can see it in devices (see screenshot). I assume the module is resetting (hence red led flashes every 5 seconds), but I can't connect to try to reload the program/script.

I have tried another test module, and that sort of seems to work (works in "run" but when embedded publishes every so often - misses some - and uptime is always 0). I can connect to this module (000111C2).

How can I recover the module that refuses to connect? is there a "factory reset" procedure or something? I have re flashed the mcModule code via the OTA updater (that works) but still no luck connecting.

Is this module toast? ???

Pages: 1 ... 13 14 [15]