{"id":14976757,"url":"https://github.com/mbientlab/metawear-sdk-python","last_synced_at":"2025-06-19T11:34:24.995Z","repository":{"id":27660356,"uuid":"104033513","full_name":"mbientlab/MetaWear-SDK-Python","owner":"mbientlab","description":"MetaWear Python SDK - Linux / Windows - Python3","archived":false,"fork":false,"pushed_at":"2023-09-01T07:15:08.000Z","size":195,"stargazers_count":55,"open_issues_count":10,"forks_count":37,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-14T07:53:15.748Z","etag":null,"topics":["bluetooth-le","linux","metamotion","metawear","python3","raspberrypi","windows10"],"latest_commit_sha":null,"homepage":"https://mbientlab.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbientlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-19T06:06:56.000Z","updated_at":"2025-05-26T19:36:39.000Z","dependencies_parsed_at":"2024-06-21T05:45:56.703Z","dependency_job_id":"5f52ef06-f5aa-48d6-8477-1d97d6e741ed","html_url":"https://github.com/mbientlab/MetaWear-SDK-Python","commit_stats":{"total_commits":55,"total_committers":8,"mean_commits":6.875,"dds":0.6727272727272727,"last_synced_commit":"84baa9643adcb50a302d715cc7e7c841016fb281"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/mbientlab/MetaWear-SDK-Python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbientlab%2FMetaWear-SDK-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbientlab%2FMetaWear-SDK-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbientlab%2FMetaWear-SDK-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbientlab%2FMetaWear-SDK-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbientlab","download_url":"https://codeload.github.com/mbientlab/MetaWear-SDK-Python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbientlab%2FMetaWear-SDK-Python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260743149,"owners_count":23055903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluetooth-le","linux","metamotion","metawear","python3","raspberrypi","windows10"],"created_at":"2024-09-24T13:54:22.317Z","updated_at":"2025-06-19T11:34:19.981Z","avatar_url":"https://github.com/mbientlab.png","language":"Python","readme":"# MetaWear SDK for Python by MBIENTLAB\n\n[![Platforms](https://img.shields.io/badge/platform-linux-lightgrey?style=flat)](https://github.com/mbientlab/MetaWear-SDK-Python)\n[![License](https://img.shields.io/cocoapods/l/MetaWear.svg?style=flat)](https://github.com/mbientlab/MetaWear-SDK-Python/blob/master/LICENSE.md)\n[![Version](https://img.shields.io/badge/python-3.5%20%7C%203.6%20%7C%203.7-blue?style=flat)](https://github.com/mbientlab/MetaWear-SDK-Python)\n\n![alt tag](https://raw.githubusercontent.com/mbientlab/MetaWear-SDK-iOS-macOS-tvOS/master/Images/Metawear.png)\n\nSDK for creating MetaWear apps on the Linux platform.  Supported for Linux only.\n\nThis is a thin wrapper around the [MetaWear C++ API](https://github.com/mbientlab/MetaWear-SDK-Cpp) so you will find the C++ [documentation](https://mbientlab.com/cppdocs/latest/) and [API reference](https://mbientlab.com/docs/metawear/cpp/latest/globals.html) useful.\n\nAlso, check out the Python [examples](https://github.com/mbientlab/MetaWear-SDK-Python/tree/master/examples).\n\n\u003e ADDITIONAL NOTES  \nThis is not the pymetawear package.  That is a community developed Python SDK which you can find over [here](https://github.com/mbientlab-projects/pymetawear).\nYou can try to get our Python SDK running on OSX or Windows at your own risk. This requires that you get Warble to work under those OSs yourself. We do not provide examples or support for this; experts ONLY. Please see the Noble README.\n\n### Overview\n\n[MetaWear](https://mbientlab.com) is a complete development and production platform for wearable and connected device applications.\n\nMetaWear features a number of sensors and peripherals all easily controllable over Bluetooth 4.0/5.0 Low Energy using this SDK, no firmware or hardware experience needed!\n\nThe MetaWear hardware comes pre-loaded with a wirelessly upgradeable firmware, so it keeps getting more powerful over time.\n\n### Requirements\n- [MetaWear board](https://mbientlab.com/store/)\n- A linux machine with Bluetooth 4.0/5.0\n\n### License\nSee the [License](https://github.com/mbientlab/MetaWear-SDK-Python/blob/master/LICENSE.md).\n\n### Support\nReach out to the [community](https://mbientlab.com/community/) if you encounter any problems, or just want to chat :)\n\n## Getting Started\n\n### Pre-Installation\n\n#### Python\nYou need to make sure you have Python3 installed as well as Pip. We don't cover this in this README, you can google-fu how to install Python and Pip.\n```\npython3 -V\n```\n\nYou installation might look like this for Python3:\n```\nsudo apt update\nsudo apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev\nsudo apt install python3\n```\nOr like this:\n```\nwget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz\ntar xf Python-3.9.0.tar.xz\ncd Python-3.9.0\n./configure --prefix=/usr/local/opt/python-3.9.0\nmake -j 4\nsudo make altinstall\n```\nIt will be entirely up to you to figure out how you want to install Python 3.\n\nYou should also check where Python was installed:\n```\nwhich python3\n```\n\n##### Pip\nYou can install packages from the Python Package Index (PyPI). To do so, use the pip tool (google-fu how to install). \n\nIt will look something like this:\n```\ncurl -O https://bootstrap.pypa.io/get-pip.py\nsudo python3 get-pip.py\n```\n\nThere are two versions of pip:\n\n- pip for installing Python 2 modules\n- pip3 for Python 3 modules\n\nUnder normal circumstances, you should only be using Python 3 and therefore pip3.\n\nYou can install modules using the pip3 install command. For example, if you wanted to download the guizero module, you would type this into a terminal window:\n```\nsudo pip3 install guizero\n```\nYou may or may not need to install with sudo:\n```\npip3 install guizero\n```\nAnd you may or may want to install packages for the local user only:\n```\npip3 install --user guizero\n```\nAgain this is all up to you.\n\nHere are a few useful commands:\n- Upgrade an already installed module:\n```\nsudo pip3 install --upgrade name_of_module\n```\n- Uninstall a module:\n```\nsudo pip3 uninstall name_of_module\n```\n- List all installed modules:\n```\nsudo pip3 list\n```\n\nYou will need to make sure when you install packages/libraries/dependencies using pip, that they are installed in the correct directory. Some can be installed in /usr/bin/, some in /usr/local/bin/ or /usr/.local/bin/. If you are having issues with modules not being found, a little google-fu will go a long way.\n\nUsing sudo python and non-sudo python might even change which Python is being used.\n\nFor example, this might work:\n```\n/usr/local/bin/python3 -m pip install cassandra-driver \n```\nBut this might not work:\n```\npip3 install cassandra-driver\n```\nBut this might works also:\n```\nsudo pip3 install cassandra-driver\n```\nIt entirely depends on your setup because a different location/version of Python may be called in each case such that cassandra-driver may be installed in `/usr/local/lib/python3/dist-packages` or\n\nTo make sure you're installing it for the version of python you're using:\n```\n/path/to/your/python -m pip install \u003cpackage\u003e\n```\nOr you will get the error: \n```\nImportError: No module named \u003cpackage_name\u003e\n```\nYou can also update your $PATH but the best way to avoid all this is to use Python virtual environments (google-fu this).\n\n##### Using sudo - a Warning\nIt is important to note that because our scripts use OS level Bluetooth libraries, it may be required to use sudo (or you will get a Bluetooth warning).\n```\nterminate called after throwing an instance of 'BLEPP::HCIScanner::IOError'\nwhat():  Setting scan parameters: Operation not permitted\n```\n\n##### Using bluez, BLE Dongles, and Python\nAt the time of this release, Python3.7 is supported. We are moving away from Python 2.7 (use the older 1.2.0 release for Python2).\n\nBluez 5.50 works but 5.54 might not work. Here's a good [tutorial](https://learn.adafruit.com/install-bluez-on-the-raspberry-pi/installation)\n\nIf you are not using a BLE dongle, you need to make sure your system is working and supports Bluetooth 4.0 or later (Bluetooth low energy).\n\nIf you are using a BLE dongle, you need to make sure it's working. You can google-fu how to use tools such as `bluetoothctl`, `hciconfig`, `btmon` and more to confirm this.\n\n#### Pre-Requisites\nMetaWear depends on [PyWarble](https://github.com/mbientlab/PyWarble) so ensure your target environment has the necessary [dependencies](https://github.com/mbientlab/Warble#build) installed.  \n\n### Installation\nYou have two options for installation:\n\n#### 1. Use PIP (recommended)\nYou can simply install the MetaWear package lib with Pip using the command line: \n```\npip install metawear\n```\nFor Python 3:\n```\npip3 install metawear\n```\nOr maybe (depends on your setup - see section above): \n```\n/usr/bin/python3 -m pip install metawear\n```\n\nIf you install metawear with Python2, you will get an older version (we are no longer supporting Python2 since it has been deprecated. \nWe recommend using Python3 and our Pypi3 metawear package (this should automatically be resolved with pip).\n\n#### 2. Clone our Repository (local deps - developers only)\nWe packaged everything for you already in this repository.\n\nMake sure that when you clone this repository, that you clone the submodule with it.\n```\ngit clone --recurse-submodules https://github.com/mbientlab/MetaWear-SDK-Python.git\n```\n\nThen you can simply install:\n```\npython3 setup.py build\n```\nThis will compile the underlying cpp libraries and may take a few seconds.\n\n#### Errors and Issues\nIf you have any issues with the installation, make sure you have warble and all the dependencies installed correctly.\n\nMake sure all python, and warble dependencies are installed:\n```\nsudo apt update\nsudo apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev\nsudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev libboost-all-dev build-essential\n```\n\nMake sure warble is installed and listed:\n```\npip3 list\npip3 freeze\n```\n\nMake sure your bluetooth system and dongles are working usin `bluetoothctl`.\n\n#### Running your first Script\nOnce the install is successful, you can run our example scripts in the example folder (see the example folder in our repository):\n```\nsudo python3 scan_connect.py\n```\n\nIf you get the following error:\n```\nerror 1609703819.483035: Setting scan parameters: Operation not permitted\n```\nPlease ignore it, it is coming from a low level third party dependence (blecpp) and does not affect your script.\n\n#### Notes\nYou should familiarize yourself with this README and our tutorials since there a few limitiations and other gotchas spelled out, such as the maximum number of simultaneous Bluetooth connections. \n\n### Usage\nRequire the metawear package by importing the MetaWear class and libmetawear variable from the metawear module and everything from the cbindings module.\n```python\nfrom mbientlab.metawear import MetaWear, libmetawear\nfrom mbientlab.metawear.cbindings import *\n```\n\nIf you do not know the MAC address of your device, use `PyWarble` to scan for nearby devices.\n```python\nBleScanner.set_handler(device_discover_task)\nBleScanner.start()\ne.wait()\nBleScanner.stop()\n```\n\nOr a specific MAC address\n```python\naddress = C8:4B:AA:97:50:05 \n```\n\nAfter that, you must connect to the device\n```python\ndevice = MetaWear(address)\ndevice.connect()\n```\n\nAt this point you can call any of the MetaWear API's, for example, you can blink the LED green\n```python\npattern= LedPattern(repeat_count= Const.LED_REPEAT_INDEFINITELY)\nlibmetawear.mbl_mw_led_load_preset_pattern(byref(pattern), LedPreset.SOLID)\nlibmetawear.mbl_mw_led_write_pattern(device.board, byref(pattern), LedColor.GREEN)\nlibmetawear.mbl_mw_led_play(device.board)\n```\n\n### Example\n```python\n# usage: python led.py [mac]\nfrom __future__ import print_function\nfrom mbientlab.metawear import MetaWear, libmetawear\nfrom mbientlab.metawear.cbindings import *\nfrom time import sleep\nfrom threading import Event\nimport sys\ndevice = MetaWear(sys.argv[1])\ndevice.connect()\nprint(\"Connected\")\npattern= LedPattern(repeat_count= Const.LED_REPEAT_INDEFINITELY)\nlibmetawear.mbl_mw_led_load_preset_pattern(byref(pattern), LedPreset.SOLID)\nlibmetawear.mbl_mw_led_write_pattern(device.board, byref(pattern), LedColor.GREEN)\nlibmetawear.mbl_mw_led_play(device.board)\nsleep(5.0)\nlibmetawear.mbl_mw_led_stop_and_clear(device.board)\nsleep(1.0)\ndevice.disconnect()\n```\n\n### Tutorials\nTutorials can be found [here](https://mbientlab.com/tutorials/).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbientlab%2Fmetawear-sdk-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbientlab%2Fmetawear-sdk-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbientlab%2Fmetawear-sdk-python/lists"}