Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read Lux value from GoDirect Light and Color Sensor with native BLE protocol #39

Open
TheMen4ce opened this issue Nov 20, 2021 · 2 comments

Comments

@TheMen4ce
Copy link

Not sure if that's the right place to post this question but I'm trying it anyway (please forgive me if not🙏).

I'm trying to connect to the Light and Color sensor and read it's current Lux value from my Swift iOS app for a university project. Connecting to the sensor and detecting the services and characteristics works well, but I couldn't figure out which values to write/read exactly. I went through all the example, JS and Python code but couldn't find anything useful.

Since the light sensor is the default sensor I'd expect not much configuration. Also when I connect to the sensor with the Graphical Analysis App, the Lux value is read and updated immediately without any actions required by the user. I'd like to implement a similar behavior.

I've enabled notifications for the B41E6675-A329-40E0-AA01-44D2F444BABE characteristic and I'm getting updates (approx. 20 per second <- default sample rate?) for the 8E6F094A-5819-11E6-8B77-86F30CA893D3 characteristic. The data is 8 bytes long, but if I try to convert it to a double or float it doesn't seem to make any sense (example data in hex: ba0d2c8d08000000 ).

Could anyone help me and explain if and how I can configure the sensor to update me with meaningful data or how to interpret the data correctly. Any hints would be highly appreciated. It would also suffice if you could tell me how to achieve this, using a BLE App (like nRF connect or BLE Scanner) that allows to read/write/notify to services and characteristics.

@dvernier
Copy link

Hello,

I think the problem is that the default channel is to take sound readings to display a waveform, sampling very fast. We do not support that in Python.

It is easy to do sound level readings (A weighted or C weighted), just set the channel.

Compare with Graphical Analysis and experiment with changing channels and you will see what I mean.

Dave

@stocktonkincade
Copy link
Contributor

The Go Direct devices use a custom command protocol. We created the godirect-py and godirect-js modules to encapsulate the details of that protocol. For the approach that you have described, you will need to implement the protocol and various commands in Swift. We cannot provide direct support for that. However, the details you would need can be gleaned directly from the godirect modules, as they are open source projects. It would be a matter of porting from Python/JavaScript to Swift. The files to start with would be device.py or Device.js, respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants