0

I am writing an app which is receiving values from a Light Sensor of a BLE device. I am trying to determine what it is that I am receiving. I am trying to get the Lux value which is provided by the sensor, but am concerned that it needs conversion. I do not know what the unit of measure is for this sensor. For example, the unit for an Android phone is SI Lux. Should be easy enough, but for this sensor, the specs do not state.

Here is the code which is giving me output:

case MSG_LIGHT:
            characteristic = (BluetoothGattCharacteristic) msg.obj;
            if (characteristic.getValue() == null) {
                Log.w(TAG, "Error obtaining light value");
                return;
            }
            int formatlgt1 = -1;                
            formatlgt1 = BluetoothGattCharacteristic.FORMAT_SINT8;

            Log.i(LIGHT, "Light RawValue1 " + characteristic.getIntValue(formatlgt1, 0));
            Log.i(LIGHT, "Light RawValue2 " + characteristic.getIntValue(formatlgt1, 1));
            Log.w(LIGHT, "Light UUID " + characteristic.getUuid());
            Log.w(LIGHT, "Light Stored Value " + characteristic.getValue());
            Log.w(LIGHT, "Light Descriptors " + characteristic.getDescriptors());
            Log.d(LIGHT, "Light Characteristic " + characteristic);
            updateLightValues(characteristic);
            break;

Simple enough, just read the sensor and give me the various outputs from that sensor at the time of reading. Next here is the output:

Light RawValue1 4
Light RawValue2 9
Light UUID 0000aa91-0000-1000-8000-00805f9b34fb
Light Stored Value [B@431d30b0
Light Descriptors [android.bluetooth.BluetoothGattDescriptor@4300e508, android.bluetooth.BluetoothGattDescriptor@4300eaf8]
Light Characteristic android.bluetooth.BluetoothGattCharacteristic@43002b10

I am interpreting that the measurement of this is the RawValues 1 & 2 but am logging what is stored to help. Problem is that the StoredValue is [B@431d30b0 which is beyond me. According to the description form the manufacturer, it states that the first byte is the HILUX at address 00x03 and the second is LOLUX at address 00x04 with a default value of 00:00.

What am I looking at here and where am I going wrong? Where I am hurting is my understanding of what I am reading. Can't seem to get a good search context to learn about it.

Thanks

  • Well, assuming that the first two bytes are a 16 bit value, they give 23362 - which seems a bit high for a straight Lux reading - so perhaps there is some scaling involved? 233.62 lux? – Paulw11 Jun 12 '14 at 05:31
  • How did you come by that value? According to the specs, that value may be pretty close. –  Jun 12 '14 at 08:20
  • I took the values of the first two characters as ASCII 91 & 66. 91 x 256 + 66 = 23362 – Paulw11 Jun 12 '14 at 08:54

0 Answers0