Hier ist jetzt der Hauptcode für Temperatur und Luftfeuchte zum auslesen.
Nur die Erebnisse sind sehr seltsam und ergeben noch keinen Sinn.
Dim bc As ByteConverter
For Each id As String In Characteristics.Keys
If id = "f000aa21-0451-4000-b000-000000000000" Then
Log("Temp Hex: "&bc.hexFromBytes(Characteristics.Get("f000aa21-0451-4000-b000-000000000000")))
Dim ArrayBytes() As Byte = Characteristics.Get("f000aa21-0451-4000-b000-000000000000")
Dim temp As Float = bc.FloatsFromBytes(Array As Byte(ArrayBytes(0), ArrayBytes(1), ArrayBytes(2), ArrayBytes(3)))(0)
Log($"TestVal: ${temp}"$)
Dim te1 As String = ArrayBytes(0)
Log("te1 " & te1)
Dim te2 As String = ArrayBytes(1)
Log("te2 " & te2)
Dim te3 As String = ArrayBytes(2)
Log("te3 " & te3)
Dim te4 As String = ArrayBytes(3)
Log("te4 " & te4)
End If
Next
Nur weis ich noch nicht wie ich die Werte richtig verarbeiten kann.
Anbei auch mal der OrginalCode von der TI Seite.
Humidity Sensor
The humidity sensor used on the SensorTag is
HDC1000 from Texas Instruments. The humidity sensor is implemented with the following source code files:
Application: sensortag_hum.c
Driver: SensorHdc1000.c
Profile: humidityservice.c
Humidity Sensor
Type UUID Access Size (bytes) Description
Data AA21* R/N 4 Temp[0:7], Temp[8:15], Hum[0:7], Hum[8:15]
Notification 2902 R/W 2 Write 0x0001 to enable notifications, 0x0000 to disable.
Configuration AA22* R/W 1 Write 0x01 to enable data collection, 0x00 to disable.
Period AA23* R/W 1 Resolution 10 ms. Range 100 ms (0x0A) to 2.55 sec (0xFF). Default 1 second (0x64).
Configuration
When an enable command (0x01) is written to the
configuration characteristic, the sensor starts to perform measurements each second and the data is stored in the
data characteristic. When the disable command (0x00) is issued, the sensor's measurement cycle is stopped, the data are cleared and no longer reported.
Data
The data from the humidity sensor consists of two 16-bit unsigned integers: the temperature in bytes 0 and 1, and the pressure in bytes 2 and 3. Conversion to temperature and relative humidity is done as shown below. The temperature unit is degrees Celsius (°C), the humidity unit is relative humidity (%RH).
void sensorHdc1000Convert(uint16_t rawTemp, uint16_t rawHum,
float *temp, float *hum)
{
//-- calculate temperature [°C]
*temp = ((double)(int16_t)rawTemp / 65536)*165 - 40;
//-- calculate relative humidity [%RH]
rawHum &= ~0x0003; // remove status bits
*hum = ((double)rawHum / 65536)*100;
}