2

There is an Ambient Light Sensor with Microsoft Band, and some apps in the Windows Store show the ALS value in Lux, But I can't find a way in the Band SDK to read the ALS Lux value.

How can I access the ALS?

Sameh
  • 934
  • 1
  • 14
  • 40

4 Answers4

2

If you're on Win or iOS use can you RFCOMM. But then you have to write everything by yourself. Subscribing for sensor data is easy, so is parsing the response. But it gets complicated if you need interaction with the device - communicating the tiles and so on. If you're on Android you get the support of MS Health app, but as it does not expose this functionality you cannot use it. Only if you disable (uninstall?) MS Health app and again write everything by yourself.

rastik
  • 2,537
  • 2
  • 12
  • 14
  • Can't you communicate via Bluetooth protocol on Android just like you'd do on a Windows Phone? Do you have any idea how could I find out the communication protocol to subscribe to a sensor data? – PeppeDAlterio Aug 18 '15 at 17:44
  • Yes you can, but as I mentioned you have to uninstall MS Health app first. If you have Android 4.4 or newer you can enable hci snoop log in developer settings and then open it in Wireshark. Just try some actions with regular app using SDK and you'll see everything there. Try that prior uninstalling MS Health or it won't work. – rastik Aug 19 '15 at 18:25
  • Ok, I managed to figure out the protocol communication between the Band and the Android device, I know how to parse all the subscription data received and I'm able to subscribe to all the non-hidden sensors. Now the problem is: how can I find out the IDs associated with the hidden sensors? :\ – PeppeDAlterio Aug 27 '15 at 06:49
  • Which sensor ID you're looking for? If it is ALS, then ID = 25 and you should get 6 bytes. Lux value are bytes 5-6 (unsigned short int). – rastik Aug 28 '15 at 10:07
  • ALS and GSR. I think GSR ID is 15, can you confirm it? – PeppeDAlterio Aug 28 '15 at 10:30
  • Yes, GSR is 15. You should get 7 bytes. First one: 1 = contact, 3 = contact. Then 4 bytes with resistance (kOhm) and last 2 bytes I don't understand. – rastik Aug 30 '15 at 20:27
  • Last 2 bytes (actually a short) are "CapSenseCounts". But I have no idea what it means xD – PeppeDAlterio Aug 30 '15 at 21:08
  • Uhm... I've been doing some testing and the GSR value doesn't look very reliable to me (and maybe that's why they didn't expose it yet on the SDK). What do you think? – PeppeDAlterio Sep 13 '15 at 07:17
  • Why do you think it's not reliable? I was not comparing it to some other measurement, but I can see difference between worn and not worn. But I haven't done any tests with different skin moisture. – rastik Sep 14 '15 at 08:14
1

As mentioned, that sensor is not exposed by the public SDK - but it is apparently possible to get the information (and a heap of other stuff) by using the raw Bluetooth interface - the public API is a kind of wrapper around the raw Bluetooth protocol.

So, if you're not afraid of reverse-engineering and fiddling around with raw bytes you may be able to figure out how to decode the sensor data. You can use the Windows.Devices.Bluetooth.Rfcomm library - there's a code sample from Microsoft that shows how to setup basic Bluetooth rfccomm communication: https://code.msdn.microsoft.com/windowsapps/Bluetooth-Rfcomm-Chat-afcee559

Jens
  • 169
  • 7
0

The ALS is not currently exposed by the Public SDK for 3rd party apps. You can add a feature request for access to this sensor in a future version of the SDK at: http://microsofthealth.uservoice.com/

Mark Thistle
  • 1,871
  • 14
  • 21
0

the Microsoft Band SDK (NuGet package v1.3.11121) now exposes the ambient light sensor.

if (bandClient.SensorManager.AmbientLight.IsSupported)
{
    bandClient.SensorManager.AmbientLight.ReadingChanged += (s, args) =>
    {
        Debug.WriteLine(bandClient.SensorManager.AmbientLight.Brightness);
    };
    await bandClient.SensorManager.AmbientLight.StartReadingsAsync();
    await Task.Delay(TimeSpan.FromSeconds(5));
    await bandClient.SensorManager.AmbientLight.StopReadingsAsync();
}
danvy
  • 2,085
  • 12
  • 17