Archive for August 2012

The Meaning of GLOMP

Using PushOver with .net

Dim Parameters = New NameValueCollection() From {
            {"token", "xxxxxxxEnterAPIKeyHerexxxxxxx"},
            {"user", "xxxxxxxEnterUserKeyHerexxxxxxx"},
            {"message", "A Test to see if PushOver is working"},
            {"url", ""},
            {"url_title", "Google"},
            {"title", "Search for something"}}
Dim client as New WebClient()
client.UploadValues("", Parameters)

Retrieving Saved Data From COSM/Pachube in php

Use Pachube PHP Library

$api_key = "xxxxxxxEnterAPIKeyHerexxxxxxx";
$pachube = new Pachube($api_key);
$feed = xxxxx;
$data = $pachube->retrieveData ( $feed, "csv" );
$array = explode(',', $data, 6);
// Datastream 1
echo $array[0];
// Datastream 2
echo $array[1];
// Datastream 3
echo $array[2];
// Datastream 4
echo $array[3];
// Datastream 5
echo $array[4];
// Datastream 6
echo $array[5];

Saving Data To COSM/Pachube in .net

Dim data As String = ""
data += "Sensor1" & "," & ValueForSensor1 & vbNewLine
data += "Sensor2" & "," & ValueForSensor2 & vbNewLine
Dim dataBytes As Byte() = Encoding.ASCII.GetBytes(data)
Dim webClient As New WebClient()
webClient.Headers.Add("X-PachubeApiKey", "xxxxxxxEnterAPIKeyHerexxxxxxx")
webClient.UploadData("", "PUT", dataBytes)

Accessing a PicoTech TC-08 Data Logger in .net

Inherited a PicoTech TC-08 data logger.

To access the data without using the package software, use usbtc08.dll and declare the methods directly:

Declare Function usb_tc08_set_channel Lib "C:\usbtc08.dll" (ByVal handle As Integer, ByVal channel As Integer, ByVal tc_type As Byte) As Integer
Declare Function usb_tc08_get_single Lib "C:\usbtc08.dll" (ByVal handle As Integer, ByRef temp As Single, ByRef overflow_flags As Boolean, ByVal units As Integer) As Long
Declare Function usb_tc08_open_unit Lib "C:\usbtc08.dll" () As Integer
Declare Function usb_tc08_close_unit Lib "C:\usbtc08.dll" (ByVal handle As Integer) As Integer
Declare Function usb_tc08_stop Lib "C:\usbtc08.dll" (ByVal handle As Integer) As Integer
Declare Function usb_tc08_set_mains Lib "C:\usbtc08.dll" (ByVal handle As Integer, ByVal sixty_hertz As Integer) As Integer
Declare Function usb_tc08_get_last_error Lib "C:\usbtc08.dll" (ByVal handle As Integer) As Integer

Then use it like so:

Dim tc08_handle As Integer
Private Function GetTemperatures() as List(Of Single)
        Dim ok As Boolean
        If (tc08_handle < 1) Then
            tc08_handle = usb_tc08_open_unit()             
            If (tc08_handle > 0) Then
                Call usb_tc08_set_mains(tc08_handle, True)
                ok = usb_tc08_set_channel(tc08_handle, 0, Asc("K"))
                ok = usb_tc08_set_channel(tc08_handle, 1, Asc("K"))
                ok = usb_tc08_set_channel(tc08_handle, 2, Asc("K"))
                ok = usb_tc08_set_channel(tc08_handle, 3, Asc("K"))
                ok = usb_tc08_set_channel(tc08_handle, 4, Asc("K"))
                ok = usb_tc08_set_channel(tc08_handle, 5, Asc("K"))
                ok = usb_tc08_set_channel(tc08_handle, 6, Asc("K"))
                ok = usb_tc08_set_channel(tc08_handle, 7, Asc("K"))
                ok = usb_tc08_set_channel(tc08_handle, 8, Asc("K"))
            End If
        End If
        Dim temp_buffer(9) As Single
        Dim overflow_flag As Integer
        Dim Results as New List(Of Single)
        If (tc08_handle > 0) Then
            ok = usb_tc08_get_single(tc08_handle, temp_buffer(0), overflow_flag, 0)
            If (ok) Then
                End If
            End If
        End If
        Return Results
End Function