Android Open Source - BleSensorTag Ti Humidity Sensor

From Project

Back to project page BleSensorTag.


The source code is released under:

MIT License

If you think the Android project BleSensorTag listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package sample.ble.sensortag.sensor;
/*from   w w w.  j  av  a2 s . c  o  m*/
import android.bluetooth.BluetoothGattCharacteristic;

 * Created by steven on 9/3/13.
public class TiHumiditySensor extends TiSensor<Float> {

    private static final String UUID_SERVICE = "f000aa20-0451-4000-b000-000000000000";
    private static final String UUID_DATA = "f000aa21-0451-4000-b000-000000000000";
    private static final String UUID_CONFIG = "f000aa22-0451-4000-b000-000000000000";

    TiHumiditySensor() {

    public String getName() {
        return "Humidity";

    public String getServiceUUID() {
        return UUID_SERVICE;

    public String getDataUUID() {
        return UUID_DATA;

    public String getConfigUUID() {
        return UUID_CONFIG;

    public String getDataString() {
        final float data = getData();
        return ""+data;

    public Float parse(BluetoothGattCharacteristic c) {
        int a = TiSensorUtils.shortUnsignedAtOffset(c, 2);
        // bits [1..0] are status bits and need to be cleared according
        // to the userguide, but the iOS code doesn't bother. It should
        // have minimal impact.
        a = a - (a % 4);

        return (-6f) + 125f * (a / 65535f);


Java Source Code List