You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 20, 2025. It is now read-only.
SDK for creating MetaWear apps on the Linux platform. This 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.
9
+
SDK for creating MetaWear apps on the Linux platform. Supported for Linux only.
10
10
11
-
Also, check out the scripts in the [examples](https://github.com/mbientlab/MetaWear-SDK-Python/tree/master/examples) folder for sample code.
11
+
This 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.
12
+
13
+
Also, check out the Python [examples](https://github.com/mbientlab/MetaWear-SDK-Python/tree/master/examples).
12
14
13
15
> ADDITIONAL NOTES
14
16
This is not the pymetawear package. That is a community developed Python SDK which you can find over [here](https://github.com/mbientlab-projects/pymetawear).
17
+
You 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.
15
18
16
19
### Overview
17
20
18
21
[MetaWear](https://mbientlab.com) is a complete development and production platform for wearable and connected device applications.
19
22
20
-
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!
23
+
MetaWear 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!
21
24
22
25
The MetaWear hardware comes pre-loaded with a wirelessly upgradeable firmware, so it keeps getting more powerful over time.
23
26
24
27
### Requirements
25
28
-[MetaWear board](https://mbientlab.com/store/)
26
-
- A Linux or Windows 10+ machine with Bluetooth 4.0
29
+
- A linux machine with Bluetooth 4.0/5.0
27
30
28
31
### License
29
32
See the [License](https://github.com/mbientlab/MetaWear-SDK-Python/blob/master/LICENSE.md).
@@ -33,58 +36,252 @@ Reach out to the [community](https://mbientlab.com/community/) if you encounter
33
36
34
37
## Getting Started
35
38
36
-
### Installation
39
+
### Pre-Installation
40
+
41
+
#### Python
42
+
You need to make sure you have Python2 or Python3 installed as well as Pip. We don't cover this in this README, you can google-fu how to install Python and Pip.
43
+
```
44
+
python -V
45
+
python3 -V
46
+
```
47
+
48
+
You installation might look like this for Python3:
It will be entirely up to you to figure out how you want to install Python and if you want to use Python 2 or 3.
64
+
65
+
You should also check where Python was installed:
66
+
```
67
+
which python
68
+
which python3
69
+
```
70
+
71
+
##### Pip
72
+
You can install packages from the Python Package Index (PyPI). To do so, use the pip tool (google-fu how to install).
73
+
74
+
It will look something like this:
75
+
```
76
+
curl -O https://bootstrap.pypa.io/get-pip.py
77
+
sudo python3 get-pip.py
78
+
```
79
+
80
+
There are two versions of pip:
81
+
82
+
- pip for installing Python 2 modules
83
+
- pip3 for Python 3 modules
84
+
85
+
Under normal circumstances, you should only be using Python 3 and therefore pip3.
86
+
87
+
You 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:
88
+
```
89
+
sudo pip3 install guizero
90
+
```
91
+
You may or may not need to install with sudo:
92
+
```
93
+
pip3 install guizero
94
+
```
95
+
And you may or may want to install packages for the local user only:
96
+
```
97
+
pip3 install --user guizero
98
+
```
99
+
Again this is all up to you.
100
+
101
+
Here are a few useful commands:
102
+
- Upgrade an already installed module:
103
+
```
104
+
sudo pip3 install --upgrade name_of_module
105
+
```
106
+
- Uninstall a module:
107
+
```
108
+
sudo pip3 uninstall name_of_module
109
+
```
110
+
- List all installed modules:
111
+
```
112
+
sudo pip3 list
113
+
```
114
+
115
+
You 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.
116
+
117
+
Using sudo python and non-sudo python might even change which Python is being used.
It 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
132
+
133
+
To make sure you're installing it for the version of python you're using:
134
+
```
135
+
/path/to/your/python -m pip install <package>
136
+
```
137
+
Or you will get the error:
138
+
```
139
+
ImportError: No module named <package_name>
140
+
```
141
+
You can also update your $PATH but the best way to avoid all this is to use Python virtual environments (google-fu this).
142
+
143
+
##### Using sudo - a Warning
144
+
It 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).
145
+
```
146
+
terminate called after throwing an instance of 'BLEPP::HCIScanner::IOError'
147
+
what(): Setting scan parameters: Operation not permitted
148
+
```
149
+
150
+
##### Using bluez, BLE Dongles, and Python
151
+
At 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).
152
+
153
+
Bluez 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)
37
154
38
-
Use pip to install the metawear package. It depends on [PyWarble](https://github.com/mbientlab/PyWarble) so ensure your target environment has the necessary [dependencies](https://github.com/mbientlab/Warble#build) installed.
155
+
If 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).
39
156
40
-
```ruby
157
+
If 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.
158
+
159
+
#### Pre-Requisites
160
+
MetaWear depends on [PyWarble](https://github.com/mbientlab/PyWarble) so ensure your target environment has the necessary [dependencies](https://github.com/mbientlab/Warble#build) installed.
161
+
162
+
### Installation
163
+
You have two options for installation:
164
+
165
+
#### 1. Use PIP (recommended)
166
+
You can simply install the MetaWear package lib with Pip using the command line:
167
+
```
41
168
pip install metawear
42
169
```
170
+
For Python 3:
171
+
```
172
+
pip3 install metawear
173
+
```
174
+
Or maybe (depends on your setup - see section above):
175
+
```
176
+
/usr/bin/python3 -m pip install metawear
177
+
```
43
178
44
-
### Usage
179
+
If you install metawear with Python2, you will get an older version (we are no longer supporting Python2 but the older libs work).
180
+
We recommend using Python3 and our Pypi3 metawear package (this should automatically be resolved with pip).
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev libboost-all-dev build-essential
204
+
```
205
+
206
+
Make sure warble is installed and listed:
207
+
```
208
+
pip3 list
209
+
pip3 freeze
210
+
```
211
+
212
+
Make sure your bluetooth system and dongles are working usin `bluetoothctl`.
213
+
214
+
#### Running your first Script
215
+
Once the install is successful, you can run our example scripts in the example folder (see the example folder in our repository):
216
+
```
217
+
sudo python3 scan_connect.py
218
+
```
45
219
46
-
Import the MetaWear class and libmetawear variable from the metawear module and everything from the cbindings module.
220
+
If you get the following error:
221
+
```
222
+
error 1609703819.483035: Setting scan parameters: Operation not permitted
223
+
```
224
+
Please ignore it, it is coming from a low level third party dependence (blecpp) and does not affect your script.
225
+
226
+
#### Notes
227
+
You 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.
228
+
229
+
### Usage
230
+
Require the metawear package by importing the MetaWear class and libmetawear variable from the metawear module and everything from the cbindings module.
47
231
```python
48
232
from mbientlab.metawear import MetaWear, libmetawear
49
233
from mbientlab.metawear.cbindings import*
50
234
```
51
235
52
-
If you do not know the MAC address of your device, use ``PyWarble`` to scan for nearby devices.
236
+
If you do not know the MAC address of your device, use `PyWarble` to scan for nearby devices.
53
237
```python
54
-
from mbientlab.warble import*
55
-
from mbientlab.metawear import*
56
-
from threading import Event
57
-
58
-
e = Event()
59
-
address =None
60
-
defdevice_discover_task(result):
61
-
global address
62
-
if (result.has_service_uuid(MetaWear.GATT_SERVICE)):
63
-
# grab the first discovered metawear device
64
-
address = result.mac
65
-
e.set()
66
-
67
238
BleScanner.set_handler(device_discover_task)
68
239
BleScanner.start()
69
240
e.wait()
70
-
71
241
BleScanner.stop()
72
242
```
73
243
74
-
Once you have the device's MAC address, create a MetaWear object with the MAC address and connect to the device.
244
+
Or a specific MAC address
245
+
```python
246
+
address = C8:4B:AA:97:50:05
247
+
```
248
+
249
+
After that, you must connect to the device
75
250
```python
76
251
device = MetaWear(address)
77
252
device.connect()
78
253
```
79
254
80
-
Upon a successful connection, you can begin calling any of the functions from the C++ SDK, for example, blinking the LED green.
255
+
At this point you can call any of the MetaWear API's, for example, you can blink the LED green
0 commit comments