.NET with sensor

Moderator: Telldus

Post Reply
weekendowel
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

.NET with sensor

Post by weekendowel »

I am using this code to get value from a temperature sensor:

Code: Select all

 private void Form1_Load(object sender, EventArgs e)
        {
             TelldusNETWrapper t = new TelldusNETWrapper();
           
            t.tdRegisterRawDeviceEvent(EventCallbackFunction, null);

        }
        public int EventCallbackFunction(string data, int controllerId, int callbackId, Object obj)
        {
            listBox1.Items.Add(DateTime.Now + data);
          


           

            return 0;
        }

It works and as soon as the temp sensor sends it value it shows up in the listbox. But it works only once, then it stops. What am I doing wrong?
weekendowel
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

Re: .NET with sensor

Post by weekendowel »

I wrote the code in VB.NET instead and for anybody interested here it is:

Code: Select all

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        Dim t As New TelldusNETWrapper()

        Dim k As New RawListeningCallbackFunction(AddressOf eventhappened)




        t.tdRegisterRawDeviceEvent(k, Nothing)


    End Sub

    Function eventhappened(ByVal data As String, ByVal controllerId As Integer, ByVal callbackid As Integer, ByVal obj As Object) As Integer

        ListBox1.Items.Add(data)


    End Function
And it is working great. Values keep coming in :-)
Brungle
Posts: 1
Joined: Fri Mar 17, 2023 9:45 am

Re: .NET with sensor

Post by Brungle »

hi,
thanks for the code, which temp sensor are you using?
thanks
weekendowel
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

Re: .NET with sensor

Post by weekendowel »

I´m using a jenkinsbird sensor, but the code should be valid for any sensor
pekkak
Posts: 29
Joined: Fri Mar 17, 2023 9:45 am

Re: .NET with sensor

Post by pekkak »

Does anyone have a working C# example to read sensors? I can't figure it out from previous posts.
Post Reply