Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
I did this at first, you can still see the original definition but I commented because it didn't work. If I put the whole routine in the main class it works. When I move it to the subclass it doesn't work any more, I wanted to make the source cleaner and making some kind of subclass so I can use this more,  so I thought to trick it by putting a event call in the main program and redirect it to the subclass, but even that doesn't do the job.
22
You have define is as an event and not as an Sub

Shared Event Uart0Receive

End Event
23
mc-Demo205 / Re: Water temperatures
« Last post by mc-T2 on December 14, 2017, 02:39:04 pm »
@Andrew - This is awesome! Great Job!

To address your question - we have done some testing with the mcDemo205 outside in the middle of winter as well - Using Lithium is the best choice as they are rated for much more extreme temperatures (versus Alkaline) and have a higher capacity. Using Lithium should perform very well outside!
24
mc-Demo205 / Water temperatures
« Last post by AndrewPratt on December 14, 2017, 12:34:13 pm »
Thanks to Josh's help we've now deployed our Demo 205 with the thermistor outside our office here to see how well it stands up to winter temperatures. I've installed lithium batteries but am curious what other people's experience has been with these when left outside?
25
mc-Module / Re: NTC Thermistor Demo
« Last post by AndrewPratt on December 13, 2017, 10:19:07 am »
Quote
That is great, what was the root of the problem?

An idIOT error ;) When I copied the code from the 120 to the 205 I originally left the resistor value at 100k not 10k ::)
26
mc-Module / Re: NTC Thermistor Demo
« Last post by mc-Josh on December 13, 2017, 09:51:14 am »
That is great, what was the root of the problem?

Thanks,

Josh
27
This is my sub-class:
Code: [Select]
Class UART_Debug
    Shared ser As Uart
    Shared Buffer As ListOfByte
   
    Public Sub New()
        //Lplan.SetMidPowerMode(2000)
        ser = Uart.Create(9600, Pin.Pin1, Pin.Pin0) // Pin 1 to Rxd and pin 0 to TxD; Dev-Board default jumper config
        ser.Write("DEBUG-TERMINAL started") ser.Write(13) ser.Write(10)
        Buffer = New ListOfByte
    End Sub
   
    //Shared Event Uart0Receive() Doesn't work in a class so I try to call this in the main-program but it doesn't work either.
    Public Sub UartReceive()
        Dim chr As Integer = ser.Read
        While chr >= 0
            If chr = 13 Then ' CR echo as CR/LF
                ser.Write(10)
                ParseBuffer()
            Else
                Buffer.AddByte(chr.ToByte)
            End If
            ser.Write(chr.ToByte)
            chr = ser.Read()
        End While
    End Sub
   
    Public Sub print(S As String)
        ser.Write(S)
    End Sub
   
    Public Sub println(S As String)
        ser.Write(S)
        ser.Write(13) ser.Write(10)
    End Sub
   
    Private Sub ParseBuffer()
        Dim S As String
        S = Buffer.ToString
        If S = "help" Then
            ser.Write("Wait I'm going to help you\n\r")
        End If
        Buffer.Clear
    End Sub
End Class

And this is my main-program:
Code: [Select]
Class UART_Terminal_v2
    Shared Terminal As UART_Debug
   
    Shared Event Boot()
        Lplan.SetMidPowerMode(2000)
        //Data = New ListOfObject()
        Terminal = New UART_Debug
    End Event
   
    Shared Event Uart0Receive()
        Terminal.UartReceive()
    End Event
   
    Shared Event Every15Seconds() RaiseEvent Every 15000 milliSeconds
       
        Terminal.println("Every 15 seconds")
       
    End Event
   
End Class

The message is printed every 15 seconds. But the Uart0Receive() Event isn't doing anything.  ???
28
mc-Module / Re: NTC Thermistor Demo
« Last post by AndrewPratt on December 12, 2017, 02:45:10 pm »
Thanks Josh I now have it working on the Demo 205 as well using the following.


Define PinMode Pin0 As AnalogInput Alias USP10972_VOLTAGE
Define PinMode Pin6 As DigitalOutput Alias USP10972_DIVIDER_ENABLE

Class ThermistorTheThings
   
    Const USP10972_BETA As Integer = 3892
    Const USP10972_R25 As Integer = 10000 '10kOhm
    Const USP10972_DIVIDER_R1 As Integer = 10000 '10kOhm
   
    Shared USP10972 As NTCTermistor
   
    Shared Event Boot()
        USP10972_DIVIDER_ENABLE = False
        USP10972 = New NTCTermistor(USP10972_BETA, USP10972_R25)
    End Event
   
    Shared Event measureTemperature() RaiseEvent Every 1 Hours
        USP10972_DIVIDER_ENABLE = True
        Device.EnableOpamp()
        Thread.Sleep(10000) 
        Dim thermistorResistance As Float = USP10972_DIVIDER_R1 * (1 / ((Device.BatteryVoltage().ToFloat/ USP10972_VOLTAGE.ToFloat) - 1))
        USP10972_DIVIDER_ENABLE = False
        Device.DisableOpamp()
       
        Dim battShort As Short = Device.BatteryVoltage()
        Dim battFloat As Float = battShort / 1000
        Dim battString As String = battFloat.ToString()
        Dim tempTMP102string As String = Temperature.GetTemp().ToString
        Dim tempPstring As String = USP10972.TemperatureCFromResistance(thermistorResistance).ToString         
       
        Dim LosantTopic As String = "losant/myDeviceID/state"
        Dim losantPayload As Json = New Json       
        Dim mcJson As Json = New Json
       
        mcJson.Add("probeTemp", tempPstring)
        mcJson.Add("temperature", tempTMP102string)
        mcJson.Add("batteryVoltage", battString)
       
        losantPayload.Add("data", mcJson)
        Lplan.Publish(LosantTopic, losantPayload.ToListOfByte)
    End Event
End Class
29
mc-Module / Re: NTC Thermistor Demo
« Last post by mc-Josh on December 12, 2017, 02:05:10 pm »
Andrew,

You don't need the AnalogInputPullUp if you are providing the pullup yourself. The CWF1B104F3950 thermistor does not need an external pullup since it uses the 100k pullup on the mod120. The USP10972 uses the 10k pullup that you added to the circuit.

Josh
30
mc-Module / Re: NTC Thermistor Demo
« Last post by AndrewPratt on December 12, 2017, 11:14:04 am »
Now that I have it working on the mc120 how do you suggest I port it to the 205 given that the 205 doesn't seem to support the AnalogInputPullUp?
Pages: 1 2 [3] 4 5 ... 10