Skip to content

borhenryk/MetaWear-SDK-Python

 
 

Repository files navigation

MetaWear SDK for Python by MBIENTLAB

Platforms License Version

alt tag

SDK for creating MetaWear apps on the Linux platform. This is a thin wrapper around the MetaWear C++ API so you will find the C++ documentation and API reference useful.

Also, check out the scripts in the examples folder for sample code.

ADDITIONAL NOTES
This is not the pymetawear package. That is a community developed Python SDK which you can find over here.

Overview

MetaWear is a complete development and production platform for wearable and connected device applications.

MetaWear features a number of sensors and peripherals all easily controllable over Bluetooth 4.0 Low Energy using this SDK, no firmware or hardware experience needed!

The MetaWear hardware comes pre-loaded with a wirelessly upgradeable firmware, so it keeps getting more powerful over time.

Requirements

License

See the License.

Support

Reach out to the community if you encounter any problems, or just want to chat :)

Getting Started

Installation

Use pip to install the metawear package. It depends on PyWarble so ensure your target environment has the necessary dependencies installed.

pip install metawear

Usage

Import the MetaWear class and libmetawear variable from the metawear module and everything from the cbindings module.

from mbientlab.metawear import MetaWear, libmetawear
from mbientlab.metawear.cbindings import *

If you do not know the MAC address of your device, use PyWarble to scan for nearby devices.

from mbientlab.warble import *
from mbientlab.metawear import *
from threading import Event

e = Event()
address = None
def device_discover_task(result):
    global address
    if (result.has_service_uuid(MetaWear.GATT_SERVICE)):
        # grab the first discovered metawear device
        address = result.mac
        e.set()

BleScanner.set_handler(device_discover_task)
BleScanner.start()
e.wait()

BleScanner.stop()

Once you have the device's MAC address, create a MetaWear object with the MAC address and connect to the device.

device = MetaWear(address)
device.connect()

Upon a successful connection, you can begin calling any of the functions from the C++ SDK, for example, blinking the LED green.

pattern= LedPattern(repeat_count= Const.LED_REPEAT_INDEFINITELY)
libmetawear.mbl_mw_led_load_preset_pattern(byref(pattern), LedPreset.BLINK)
libmetawear.mbl_mw_led_write_pattern(device.board, byref(pattern), LedColor.GREEN)
libmetawear.mbl_mw_led_play(device.board)

Tutorials

Tutorials can be found here.

About

MetaMotion / MetaWear Python SDK for Windows/Linux

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%