CreaTeBME


NameCreaTeBME JSON
Version 1.2.3 PyPI version JSON
download
home_pagehttps://github.com/CreaTe-M8-BME/CreaTeBME
SummaryPython Package for interfacing the bluetooth IMU module for CreaTe M8 BME.
upload_time2024-06-05 14:51:30
maintainerNone
docs_urlNone
authorJonathan Matarazzi
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CreaTeBME

[![Build](https://github.com/CreaTe-M8-BME/CreaTeBME/actions/workflows/build_publish.yml/badge.svg)](https://github.com/CreaTe-M8-BME/CreaTeBME/actions/workflows/build_publish.yml)
[![PyPI](https://img.shields.io/pypi/v/CreaTeBME)](https://pypi.org/project/CreaTeBME/)

Python Package for interfacing the bluetooth IMU module for CreaTe M8 BME.

# Installation
To install the latest stable version simply run this in your terminal.
If you are using PyCharm then you can open the terminal on the bottom left of the screen.
```shell
pip install CreaTeBME
```

# Example
A simple example to connect to a sensor and read and print the data indefinitely.
The package automatically connects to the device, so you do not have to connect to it manually.
```python
from CreaTeBME import SensorManager

# Create a sensor manager for the given sensor names using the given callback
manager = SensorManager(['0BE6'])

# Start the sensor manager
manager.start()

while True:
    measurements = manager.get_measurements()
    for sensor, data in measurements.items():
        if len(data) > 0:
            print(sensor, data)

# Stop the sensor manager
manager.stop()
```

# Usage

## SensorManager (asyncio wrapper)
This package uses [Bleak](https://github.com/hbldh/bleak) for the bluetooth communication.
Bleak uses asyncio, thus this package has to use this too.
To ease usage, a wrapper has been made for people not experienced with asyncio.
This wrapper also automates the connection of the sensors over bluetooth.

To connect to the sensors, simply initialize a `SensorManager` object with the sensor names.
```python
from CreaTeBME import SensorManager

manager = SensorManager(['A1B2', 'C3D4'])
```
Then start reading data from the sensors by calling the `start` method of the `SensorManager`.
```python
manager.start()
```

To get the IMU measurements the `get_measurements()' method can be used.
This returns the measurements received since the last time this method was called.
```python
measurements = manager.get_measurements()
```

The data returned by this method is a dictionary containing a list for each sensor with the received measurements.
A single measurement is a list of 6 floats.
The measurements are structured like this
- **[0:2]** = x,y,z of accelerometer in (g).
- **[3:5]** = x,y,z of gyroscope in (deg/s).

Finally, make sure to also call the `stop` method when exiting your program.
```python
manager.stop()
```

## Manual Connection
⚠️**Understanding of** asyncio **required**⚠️

Another way of connecting IMU sensors is to manually create `ImuSensor` objects.
This can be done by specifying the BLE device that should be connected as a sensor.
```python
from CreaTeBME import ImuSensor

sensor = ImuSensor(device)
```

The device has to be a Bleak _BLEDevice_ object that can be acquired using the `discover` method of `BleakScanner`.
```python
from bleak import BleakScanner
from CreaTeBME import ImuSensor

async def connect():
    devices = await BleakScanner.discover(return_adv=True)
    sensor = ImuSensor(devices[0])
```

# API reference

For the API reference look [here](https://github.com/CreaTe-M8-BME/CreaTeBME/blob/main/docs/README.md)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/CreaTe-M8-BME/CreaTeBME",
    "name": "CreaTeBME",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Jonathan Matarazzi",
    "author_email": "git@jonathanm.nl",
    "download_url": "https://files.pythonhosted.org/packages/e4/a6/24cf1ec890de1c91efefc85aa9dcc1d2767397fc35a0a40c30956a14a69c/createbme-1.2.3.tar.gz",
    "platform": null,
    "description": "# CreaTeBME\n\n[![Build](https://github.com/CreaTe-M8-BME/CreaTeBME/actions/workflows/build_publish.yml/badge.svg)](https://github.com/CreaTe-M8-BME/CreaTeBME/actions/workflows/build_publish.yml)\n[![PyPI](https://img.shields.io/pypi/v/CreaTeBME)](https://pypi.org/project/CreaTeBME/)\n\nPython Package for interfacing the bluetooth IMU module for CreaTe M8 BME.\n\n# Installation\nTo install the latest stable version simply run this in your terminal.\nIf you are using PyCharm then you can open the terminal on the bottom left of the screen.\n```shell\npip install CreaTeBME\n```\n\n# Example\nA simple example to connect to a sensor and read and print the data indefinitely.\nThe package automatically connects to the device, so you do not have to connect to it manually.\n```python\nfrom CreaTeBME import SensorManager\n\n# Create a sensor manager for the given sensor names using the given callback\nmanager = SensorManager(['0BE6'])\n\n# Start the sensor manager\nmanager.start()\n\nwhile True:\n    measurements = manager.get_measurements()\n    for sensor, data in measurements.items():\n        if len(data) > 0:\n            print(sensor, data)\n\n# Stop the sensor manager\nmanager.stop()\n```\n\n# Usage\n\n## SensorManager (asyncio wrapper)\nThis package uses [Bleak](https://github.com/hbldh/bleak) for the bluetooth communication.\nBleak uses asyncio, thus this package has to use this too.\nTo ease usage, a wrapper has been made for people not experienced with asyncio.\nThis wrapper also automates the connection of the sensors over bluetooth.\n\nTo connect to the sensors, simply initialize a `SensorManager` object with the sensor names.\n```python\nfrom CreaTeBME import SensorManager\n\nmanager = SensorManager(['A1B2', 'C3D4'])\n```\nThen start reading data from the sensors by calling the `start` method of the `SensorManager`.\n```python\nmanager.start()\n```\n\nTo get the IMU measurements the `get_measurements()' method can be used.\nThis returns the measurements received since the last time this method was called.\n```python\nmeasurements = manager.get_measurements()\n```\n\nThe data returned by this method is a dictionary containing a list for each sensor with the received measurements.\nA single measurement is a list of 6 floats.\nThe measurements are structured like this\n- **[0:2]** = x,y,z of accelerometer in (g).\n- **[3:5]** = x,y,z of gyroscope in (deg/s).\n\nFinally, make sure to also call the `stop` method when exiting your program.\n```python\nmanager.stop()\n```\n\n## Manual Connection\n\u26a0\ufe0f**Understanding of** asyncio **required**\u26a0\ufe0f\n\nAnother way of connecting IMU sensors is to manually create `ImuSensor` objects.\nThis can be done by specifying the BLE device that should be connected as a sensor.\n```python\nfrom CreaTeBME import ImuSensor\n\nsensor = ImuSensor(device)\n```\n\nThe device has to be a Bleak _BLEDevice_ object that can be acquired using the `discover` method of `BleakScanner`.\n```python\nfrom bleak import BleakScanner\nfrom CreaTeBME import ImuSensor\n\nasync def connect():\n    devices = await BleakScanner.discover(return_adv=True)\n    sensor = ImuSensor(devices[0])\n```\n\n# API reference\n\nFor the API reference look [here](https://github.com/CreaTe-M8-BME/CreaTeBME/blob/main/docs/README.md)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python Package for interfacing the bluetooth IMU module for CreaTe M8 BME.",
    "version": "1.2.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/CreaTe-M8-BME/CreaTeBME/issues",
        "Homepage": "https://github.com/CreaTe-M8-BME/CreaTeBME"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25ffafdb5234abd3c085126b5cce7b000e865d6166725fdc6ae14851bd9999cf",
                "md5": "051d2b28a4287a1182795a1d18fcc4fc",
                "sha256": "19afb8876207bcc6ba7697a07f0498150d34189b70a0eab033afa4494507d872"
            },
            "downloads": -1,
            "filename": "CreaTeBME-1.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "051d2b28a4287a1182795a1d18fcc4fc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 20452,
            "upload_time": "2024-06-05T14:51:26",
            "upload_time_iso_8601": "2024-06-05T14:51:26.935662Z",
            "url": "https://files.pythonhosted.org/packages/25/ff/afdb5234abd3c085126b5cce7b000e865d6166725fdc6ae14851bd9999cf/CreaTeBME-1.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4a624cf1ec890de1c91efefc85aa9dcc1d2767397fc35a0a40c30956a14a69c",
                "md5": "02c09a2dda704e30c9704d7501137456",
                "sha256": "376b75857355266e0700e203fd6bc03e099ab13ec648b763ddc82892dd237b93"
            },
            "downloads": -1,
            "filename": "createbme-1.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "02c09a2dda704e30c9704d7501137456",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 19855,
            "upload_time": "2024-06-05T14:51:30",
            "upload_time_iso_8601": "2024-06-05T14:51:30.082538Z",
            "url": "https://files.pythonhosted.org/packages/e4/a6/24cf1ec890de1c91efefc85aa9dcc1d2767397fc35a0a40c30956a14a69c/createbme-1.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-05 14:51:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CreaTe-M8-BME",
    "github_project": "CreaTeBME",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "createbme"
}
        
Elapsed time: 0.33555s