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 ... 12 13 [14] 15
196
mc-Module / Odd Memory Behaviour
« on: August 17, 2016, 12:28:00 pm »
Hi,

I have observed some strange behavior with memory.

Now I realize that memory is managed by the GarbageCollector, which runs when memory is low. Not sure what is defined as "low", but if I have a small program, really doing nothing but publishing uptime and battery/memory levels, then memory gradually drops (2-300 bytes at a time) until it hits less than 1k or so, then there is a pause, and the the program continues with 15k free again (Garbage Collection activity I assume).

If I add in a new object (Temperature sensor) every event cycle - as a local variable, memory drops by 500 bytes or so every cycle, until it gets "low", then the module resets.

the output looks like this:

Code: [Select]
MCThings/000111BA/Count 23
MCThings/000111BA/Temperature 26.500000
MCThings/000111BA/Uptime 190
MCThings/000111BA/BatteryVoltage 2823
MCThings/000111BA/FreeMemory 1676
MCThings/000111BA/Count 25
MCThings/000111BA/Temperature 26.500000
MCThings/000111BA/Uptime 201
MCThings/000111BA/BatteryVoltage 2823
MCThings/000111BA/FreeMemory 976
MCThings/000111BA/Count 26
MCThings/000111BC/Uptime 12663
MCThings/000111BA/Temperature 26.500000
MCThings/000111BA/Uptime 211
MCThings/000111BA/BatteryVoltage 2823
MCThings/000111BA/FreeMemory 280
MCThings/000111BA/Count 27
MCThings/000111BA/Status Booted
MCThings/000111BA/Temperature 26.500000
MCThings/000111BA/Uptime 0
MCThings/000111BA/BatteryVoltage 2612
MCThings/000111BA/FreeMemory 15072
MCThings/000111BA/Count 6
MCThings/000111BA/Temperature 26.562500
MCThings/000111BA/Uptime 10
MCThings/000111BA/BatteryVoltage 2601
MCThings/000111BA/FreeMemory 14360
MCThings/000111BA/Count 7


Now this memory management system is weird (I'm used to local variables being released when out of scope), but it seems that the module is running out of memory before Garbage collection can free up some RAM - hence the reset.

There is no way to "Delete" or "free" an object, but I can manually run Garbage Collection.

Is this normal behavior? Do I need to manually run GarbageCollection when memory is low? this isn't the "automatic" memory management I was expecting...

197
mc-Module / Problems with I2c configuration
« on: August 17, 2016, 09:42:58 am »
I'm having some problems with my BME280 module, so I tried some experiments with the internal Temperature Sensor (to eliminate external errors).

I don't seem to be able to define an I2c object as shared (might not be just I2c, but this is what I am testing).

For example, this code works (the MQTT class just makes MQTT stuff easier):

Code: [Select]
Class MQTT
    Shared mcUIDString As String
   
    Shared Sub Publish(topic As String, value As String)
        If mcUIDString = Nothing Then
            mcUIDString = Device.mcUID().ToString("X8")
        End If
        Dim text_string As ListOfByte = New ListOfByte()
        text_string.Add(value)
        Lplan.Publish("MCThings/" + mcUIDString + "/" + topic, text_string)
    End Sub
   
    Shared Sub Publish(topic As String, value As Object)
        Dim text As String = value.ToString()
        If mcUIDString = Nothing Then
            mcUIDString = Device.mcUID().ToString("X8")
        End If
        Dim text_string As ListOfByte = New ListOfByte()
        text_string.Add(text)
        Lplan.Publish("MCThings/" + mcUIDString + "/" + topic, text_string)
    End Sub
   
    Shared Sub Publish_exact(topic As String, text As String)
        Dim text_String As ListOfByte = New ListOfByte()
        text_String.Add(text)
        Lplan.Publish(topic, text_String)
    End Sub
   
    Shared Sub BeaconPublish(data_Type As Byte, data As Integer)
        data = data & 0x0fffffff //blank top byte (can only send 24 bits maximum)
        Dim hi_byte As Byte = ((data >> 16) & 0xff).ToByte()
        Dim mid_byte As Byte = ((data >> 8) & 0xff).ToByte()
        Dim low_byte As Byte = (data & 0xff).ToByte()
        Dim beconData As ListOfByte = New ListOfByte()
        beconData.Add(data_Type)
        beconData.Add(hi_byte)
        beconData.Add(mid_byte)
        beconData.Add(low_byte)
        Lplan.SetBeaconData(beconData)
        Lplan.SendBeacon()
    End Sub
   
    Shared Sub Subscribe(topic As String)
        Lplan.Subscribe(topic)
    End Sub
   
End Class

Class Main
   
    //Shared Internal_Temp As TempSensor
    Shared booted As Boolean
    Shared count As Integer
   
    Shared Event Boot()
       
        booted = True
        count = 5
        //Internal_Temp = New TempSensor()
       
    End Event
   
    Shared Event Publish_Values() RaiseEvent Every 10 Seconds
        LedGreen = True
       
        If booted Then
            MQTT.Publish("Status", "Booted")
            booted = False
        End If   
       
        Dim Internal_Temp As TempSensor = New TempSensor()
        Dim TempC As Float = Internal_Temp.GetTemp()
        MQTT.Publish("Temperature", TempC)
        Dim Uptime As Integer = Device.Uptime()
        MQTT.Publish("Uptime", Uptime)
        Dim BattVolt As Integer = Device.BatteryVoltage()
        MQTT.Publish("BatteryVoltage", BattVolt)
        count = count + 1
        MQTT.Publish("Count", count)
       
        LedGreen = False
    End Event 
End Class

Class TempSensor
    // Function returns the temperature in degree celcius or
    // Float.NaN if something is wrong
   
    Public sensor As I2c
   
    Public Sub New()
        sensor = I2c.Create(400000, Pin.SCL, Pin.SDA, 0x48)
    End Sub
   
    Public Function GetTemp() As Float
        // Define the properties of the I2C peripheral and device address
        //Dim sensor As I2c
        //sensor = I2c.Create(400000, Pin.SCL, Pin.SDA, 0x48)
       
        // Power up the sensor and give it some time to settle
        Device.EnableTempSensor()
        Thread.Sleep(40000) // See page 13 of the datasheet
       
        // Read the sensor (only 2 bytes to read
        Dim res As ListOfByte = sensor.Read(2)
       
        // See Tmp102 documentation how to interpret the data (page 8)
        Dim temp As Float = Float.NaN
        If res <> Nothing Then
            // Shift the partial part to the right nibble
            Dim part As Float = res(1) >> 4
            // Temperature partial is 1/16*n where n is between 0 and 15           
            part = part / 16
            // Sign extend the byte to an integer
            temp = res(0).SignExtend() + part
        Else
            LedRed = True
            Thread.Sleep(50000)
            LedRed = False
        End If
       
        // power off
        Device.DisableTempSensor()
        Return temp
    End Function
   
    Shared Function GetDieTemp() As Float
        // Just get the temperature and return
        Return Device.TempDie
    End Function
   
    Shared Function ToFarenheit(celcius As Float) As Float
        Return (celcius * 9) / 5 + 32
    End Function
   
    Shared Function ToCelcius(farenheit As Float) As Float
        Return (farenheit - 32) * 5 / 9
    End Function
   
End Class

Note the "Dim Internal_Temp As TempSensor = New TempSensor()" in Class Main.

If I Try to Make this a shared variable of class main, it causes the module to reset. This does not work:

Code: [Select]
Class MQTT
    Shared mcUIDString As String
   
    Shared Sub Publish(topic As String, value As String)
        If mcUIDString = Nothing Then
            mcUIDString = Device.mcUID().ToString("X8")
        End If
        Dim text_string As ListOfByte = New ListOfByte()
        text_string.Add(value)
        Lplan.Publish("MCThings/" + mcUIDString + "/" + topic, text_string)
    End Sub
   
    Shared Sub Publish(topic As String, value As Object)
        Dim text As String = value.ToString()
        If mcUIDString = Nothing Then
            mcUIDString = Device.mcUID().ToString("X8")
        End If
        Dim text_string As ListOfByte = New ListOfByte()
        text_string.Add(text)
        Lplan.Publish("MCThings/" + mcUIDString + "/" + topic, text_string)
    End Sub
   
    Shared Sub Publish_exact(topic As String, text As String)
        Dim text_String As ListOfByte = New ListOfByte()
        text_String.Add(text)
        Lplan.Publish(topic, text_String)
    End Sub
   
    Shared Sub BeaconPublish(data_Type As Byte, data As Integer)
        data = data & 0x0fffffff //blank top byte (can only send 24 bits maximum)
        Dim hi_byte As Byte = ((data >> 16) & 0xff).ToByte()
        Dim mid_byte As Byte = ((data >> 8) & 0xff).ToByte()
        Dim low_byte As Byte = (data & 0xff).ToByte()
        Dim beconData As ListOfByte = New ListOfByte()
        beconData.Add(data_Type)
        beconData.Add(hi_byte)
        beconData.Add(mid_byte)
        beconData.Add(low_byte)
        Lplan.SetBeaconData(beconData)
        Lplan.SendBeacon()
    End Sub
   
    Shared Sub Subscribe(topic As String)
        Lplan.Subscribe(topic)
    End Sub
   
End Class

Class Main
   
    Shared Internal_Temp As TempSensor
    Shared booted As Boolean
    Shared count As Integer
   
    Shared Event Boot()
       
        booted = True
        count = 5
        Internal_Temp = New TempSensor()
       
    End Event
   
    Shared Event Publish_Values() RaiseEvent Every 10 Seconds
        LedGreen = True
       
        If booted Then
            MQTT.Publish("Status", "Booted")
            booted = False
        End If   
       
        //Dim Internal_Temp As TempSensor = New TempSensor()
        Dim TempC As Float = Internal_Temp.GetTemp()
        MQTT.Publish("Temperature", TempC)
        Dim Uptime As Integer = Device.Uptime()
        MQTT.Publish("Uptime", Uptime)
        Dim BattVolt As Integer = Device.BatteryVoltage()
        MQTT.Publish("BatteryVoltage", BattVolt)
        count = count + 1
        MQTT.Publish("Count", count)
       
        LedGreen = False
    End Event 
End Class

Class TempSensor
    // Function returns the temperature in degree celcius or
    // Float.NaN if something is wrong
   
    Public sensor As I2c
   
    Public Sub New()
        sensor = I2c.Create(400000, Pin.SCL, Pin.SDA, 0x48)
    End Sub
   
    Public Function GetTemp() As Float
        // Define the properties of the I2C peripheral and device address
        //Dim sensor As I2c
        //sensor = I2c.Create(400000, Pin.SCL, Pin.SDA, 0x48)
       
        // Power up the sensor and give it some time to settle
        Device.EnableTempSensor()
        Thread.Sleep(40000) // See page 13 of the datasheet
       
        // Read the sensor (only 2 bytes to read
        Dim res As ListOfByte = sensor.Read(2)
       
        // See Tmp102 documentation how to interpret the data (page 8)
        Dim temp As Float = Float.NaN
        If res <> Nothing Then
            // Shift the partial part to the right nibble
            Dim part As Float = res(1) >> 4
            // Temperature partial is 1/16*n where n is between 0 and 15           
            part = part / 16
            // Sign extend the byte to an integer
            temp = res(0).SignExtend() + part
        Else
            LedRed = True
            Thread.Sleep(50000)
            LedRed = False
        End If
       
        // power off
        Device.DisableTempSensor()
        Return temp
    End Function
   
    Shared Function GetDieTemp() As Float
        // Just get the temperature and return
        Return Device.TempDie
    End Function
   
    Shared Function ToFarenheit(celcius As Float) As Float
        Return (celcius * 9) / 5 + 32
    End Function
   
    Shared Function ToCelcius(farenheit As Float) As Float
        Return (farenheit - 32) * 5 / 9
    End Function
   
End Class

So if I change Internal_sensor from a local variable to a Shared variable, the module resets. What am I doing wrong? The TempSensor object should be created at boot, and should persist as a shared variable of class Main, but I'm guessing from the resets, it is being destroyed. No errors in MCStudio, and builds fine.

I'm wanting to do this as I want to create a BME280 object (one per sensor), but it seems that I have to create a new object every time I want to use it. I can't make a persistent I2C object.

Any suggestions would be appreciated.

198
mc-Module / Re: Variables Signed/Unsigned and such
« on: July 29, 2016, 04:25:05 pm »
I was going to do this, but I've been having all sorts of problems all day. I now seem to have bricked my module (can't connect, and just resets continually - really need the "erase flash RAM" option) .

Anyway, I've attached a zip with two projects in it (same project as I've been working on). Both have no compile errors, but one works, and one does not. The working one uses a shared object (so you don't have to instantiate it), the other (not working) uses public subs/functions/variables so you do.

Ignore all the calculations etc, What am I doing wrong on creating my object?

I have tried debugging to see if there is a run time error, but I can't get the "run" option to work (works on simple projects, just not complicated ones).

Any Help would be appreciated.

199
mc-Studio / Turn Off Auto Syntax Checking?
« on: July 28, 2016, 05:33:03 pm »
Is there a way to turn off the auto syntax checking?

Every time I type 3 or so characters, the whole thing pauses for 10-15 seconds to check the syntax (and give an error as I haven't finished typing). It's incredibly painful (no I don't have the fastest computer).

I've been entering code in Notepad+ as it's much easier, then starting mc-Studio, but I can't even make simple changes without long pauses, or exiting and restarting mc-Studio.

It would be better to disable this, and have a manual push to check, or check on build system.

This makes the editor unusable for me. Please tell me there is a way to turn this off!

200
mc-Module / Re: Variables Signed/Unsigned and such
« on: July 28, 2016, 05:27:43 pm »
OK,

After some testing, I have to say your pressure compensation routine does not work, it gives all sorts of random results. My routine also gives wrong results, but they are consistently wrong (ie it gives a large number which varies slightly with each reading). Yours gives medium positive or negative numbers which do not look like pressure readings, and vary a lot.

Still trying to track down the errors, the lack of a uint32_t makes life very hard! Not being able to do bit-wise arithmetic (because they get converted to Floats) is mind bendingly difficult. Some things just do not have a negative value...

This is my attempt:

Code: [Select]
    Shared Function BME280_compensate_P_int32(adc_P As Integer) As Float
        // Returns pressure in Pa as float. Output value of “96386” equals 96386 Pa = 963.86 hPa
       
        Dim var1 As Integer
        Dim var2 As Integer
        Dim p As Integer
        var1 = (t_fine >> 1) - 64000
        var2 = (((var1 >> 2) * (var1 >> 2)) >> 11) * dig_P6
        var2 = var2 + ((var1 * dig_P5) << 1)
        var2 = (var2 >> 2) + (dig_P4 << 16)
        var1 = (((dig_P3 * (((var1 >> 2) * (var1 >> 2)) >> 13)) >> 3) + ((dig_P2 * var1) >> 1)) >> 18
        var1 = (((32768 + var1)) * dig_P1) >> 15
        If var1 = 0 Then
            Return 0 // avoid exception caused by division by zero
        End If
        p = ((1048576 - adc_P.ZeroExtend()) - (var2 >> 12)) * 3125
        If p < 0x80000000 Then
            p = (p << 1) / var1.ZeroExtend()
        Else
            p = (p / var1.ZeroExtend()) * 2
        End If
        var1 = (dig_P9 * ((((p >> 3) * (p >> 3)) >> 13))) >> 12
        var2 = ((p >> 2) * dig_P8) >> 13
        p = p + ((var1 + var2 + dig_P7) >> 4)
        Return p.ZeroExtend()
    End Function

output is
Code: [Select]
MCThings/70074/Pressure 1201306112.000000

Which varies slightly, but is consistent.

I'll look at it again tomorrow, mind is too boggled to think straight now.

201
mc-Module / Re: Variables Signed/Unsigned and such
« on: July 28, 2016, 02:06:41 pm »
Thank you!  ;D

I was aware of the 32 bit compensation function, and I implemented this. Nice to know 64 integers will be supported in the future.

I will compare your implementation with mine - I'm sure I will learn a lot.

I guess I'm just not used to dealing with all integers. I did the same thing as you and just converted all the calibration values to Integers.

This sensor is nice because the standby current (and active current for that matter) is so low, it makes a nice battery powered environmental sensor.

I'm reading temperature and humidity fine at the moment, but pressure is giving me weird results - probably due to the complicated maths, which I no doubt have wrong somewhere.

I'll let you know how it goes.

Thanks again.

202
mc-Module / How to do power of calculations
« on: July 27, 2016, 10:26:30 am »
Hi,

I'm trying to calculate a "power of" value using floats.

The calculation involves pressure (variables are Floats) and has this in it: (atmospheric / seaLevel) ^ 0.1903

The error is "Operand(0) is not a byte, short, or Integer in bit-wise Xor (^)"

Now, the bitwise operator is ^ but the power of operator is also ^, and I want the power-of operator. How does VB.Net type languages differentiate?

In C I use pow(A, B) where I want A^B (to the power of, not bit-wise).

What's the equivalent?

Thanks,

203
mc-Module / Variables Signed/Unsigned and such
« on: July 26, 2016, 05:30:09 pm »
Hi,

I'm converting a library from Arduino (C) for use with a sensor, and it's proving a right pain.

The main problem comes from trying to convert signed/unsigned bytes, shorts and ints using ZeroExtend() and SignExtend(). This makes things either an Integer or a Float, and is very difficult to deal with. Is there no easier way to represent these values? can we not introduce the concept of signed bytes and unsiged short/ints? it would make things so much simpler to convert from C.

Also my pressure transducer uses a 64 bit integer for full precision. I can use a  32 bit variable, if I reduce precision - but a coretx M0 or M3 can handle 64 bit integers, is there no way to represent an int64_t or uint64_t? Do I have to sacrifice precision because of this weird restriction?

The calculation (in C) is here:

Code: [Select]
float readPressure(void) {
  int64_t var1, var2, p;

  readTemperature(); // must be done first to get t_fine

  int32_t adc_P = read24(BME280_REGISTER_PRESSUREDATA);
  adc_P >>= 4;

  var1 = ((int64_t)t_fine) - 128000;
  var2 = var1 * var1 * (int64_t)_bme280_calib.dig_P6;
  var2 = var2 + ((var1*(int64_t)_bme280_calib.dig_P5)<<17);
  var2 = var2 + (((int64_t)_bme280_calib.dig_P4)<<35);
  var1 = ((var1 * var1 * (int64_t)_bme280_calib.dig_P3)>>8) +
    ((var1 * (int64_t)_bme280_calib.dig_P2)<<12);
  var1 = (((((int64_t)1)<<47)+var1))*((int64_t)_bme280_calib.dig_P1)>>33;

  if (var1 == 0) {
    return 0;  // avoid exception caused by division by zero
  }
  p = 1048576 - adc_P;
  p = (((p<<31) - var2)*3125) / var1;
  var1 = (((int64_t)_bme280_calib.dig_P9) * (p>>13) * (p>>13)) >> 25;
  var2 = (((int64_t)_bme280_calib.dig_P8) * p) >> 19;

  p = ((p + var1 + var2) >> 8) + (((int64_t)_bme280_calib.dig_P7)<<4);
  return (float)p/256;
}

204
mc-Gateway / Re: Gateway hangs after about 10 hours
« on: July 26, 2016, 02:28:48 pm »
Hi,

Just to confirm I have 3 modules posting to a local MQTT server via a gateway on WiFi - all with latest firmware. The gateway hangs after 12 hours or so (usually overnight - ie it's hung in the morning, so I don't have more precise timing). Works after reset (module reset not needed).

Usually the green light is ON - that's how I know it's hung.

Just FYI, not a big deal yet, I'm still developing code for the modules.

205
mc-Module / Re: Connection Problem
« on: July 20, 2016, 03:46:01 pm »
New (or maybe not) weird thing, don't know if this is related:

Now reporting via MQTT, it looks like the data is cached somewhere. I'm reporting uptime, battery voltage and temperature every minute, in 3 topics.

What happens is that the green LED flashes (indicating a report) every minute, but in MQTT, the values are published every 2 minutes, but for both reports - ie flash - no report, minute later flash - two reports (uptime shows correctly, which is why it looks like it's being cached).

see the output of my MQTT monitor below:

Code: [Select]
MCThings/70082/Uptime 600
MCThings/70082/BatteryVoltage 2907
MCThings/70082/Temperature 25.125000
MCThings/70082/Uptime 660
MCThings/70082/BatteryVoltage 2907
MCThings/70082/Temperature 25.062500
MCThings/70076/Uptime 480
MCThings/70076/BatteryVoltage 2875
MCThings/70076/Temperature 25.250000
MCThings/70076/Uptime 540
MCThings/70076/BatteryVoltage 2875
MCThings/70076/Temperature 25.187500
MCThings/70082/Uptime 720
MCThings/70082/BatteryVoltage 2907
MCThings/70082/Temperature 25.062500
MCThings/70082/Uptime 780
MCThings/70082/BatteryVoltage 2907
MCThings/70082/Temperature 25.000000
MCThings/70076/Uptime 600
MCThings/70076/BatteryVoltage 2875
MCThings/70076/Temperature 25.062500
MCThings/70076/Uptime 660
MCThings/70076/BatteryVoltage 2875
MCThings/70076/Temperature 25.000000
MCThings/70082/Uptime 840
MCThings/70082/BatteryVoltage 2907
MCThings/70082/Temperature 25.000000
MCThings/70082/Uptime 900
MCThings/70082/BatteryVoltage 2907
MCThings/70082/Temperature 25.000000
MCThings/70076/Uptime 720
MCThings/70076/BatteryVoltage 2875
MCThings/70076/Temperature 24.937500
MCThings/70076/Uptime 780
MCThings/70076/BatteryVoltage 2875
MCThings/70076/Temperature 24.937500

This is from two modules, one was the bricked one (now alive!). If you look at the report from module 70076 the last two reports (uptime 720 and 780) arrive at the same time  - but the uptime is 60 second apart, and the dual reports arrive at 2 minute intervals (event is set for 1 minute, and LED flash shows every minute).

Could the gateway be caching these? where would they be cached if they in fact are?

Any ideas?

206
mc-Module / Re: Connection Problem
« on: July 20, 2016, 03:26:48 pm »
Success!  ;D

After a complete restart of everything I managed to get everything back, beacons MQTT reporting etc. Connected to the bricked module and successfully downloaded working code, and it is now reporting via MQTT also!

Thank you for the quick response (and fix).

On now to the next problem....

207
mc-Module / Re: Connection Problem
« on: July 20, 2016, 03:19:07 pm »
I may have spoken too soon.

Just restarted mcStudio, and now I get nothing, no beacons - cannot see the modules at all. Restarting the gateway, mcStudio etc, see if anything shows up. Good module is still reporting via MQTT (not every minute, misses one or two - but it's alive).

208
mc-Module / Re: Connection Problem
« on: July 20, 2016, 03:10:32 pm »
OK, progress! :)

Not getting the same resets as before. Good module seems to be reporting more normally now.

Bricked module also does not reset as before, and I did get it to connect! However when I tried downloading my new code, the whole mcStudio UI froze until I removed the battery.

Trying to reconnect again (but it's difficult...).

I'll let you know if I succeed, but this is good progress...

209
mc-Module / Re: How do Variables work?
« on: July 20, 2016, 02:43:10 pm »
OK,

I have re-written like this:

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

Class Events
    Shared Event Publish() RaiseEvent Every 1 Minutes
        LedGreen = True
        Dim Sensors As Values = New Values
        Lplan.Publish("MCThings/" + Sensors.mcUIDString + "/Uptime", Sensors.GetUptime)
        Lplan.Publish("MCThings/" + Sensors.mcUIDString + "/BatteryVoltage", Sensors.GetBattVoltage)
        Lplan.Publish("MCThings/" + Sensors.mcUIDString + "/Temperature", Sensors.GetTemp)
        LedGreen = False
    End Event 
End Class

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

This works - sort of (still getting unexplained resets every minute or so).

Good thing you don't need to be a programmer to figure this out, or we would all be stuck.

210
mc-Module / Re: Connection Problem
« on: July 20, 2016, 02:22:08 pm »
The code I have works in debug mode, not if you embed it to flash ram. Did you try embedding it?

Pages: 1 ... 12 13 [14] 15