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 that run on node.js or in the browser (web-bluetooth support not widespread yet, but growing). This is a thin wrapper around the [MetaWear C++ API](https://github.com/mbientlab/Metawear-CppAPI) 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 that run on node.js. Supported on Linux only.
10
10
11
-
Also, check out the JavaScript [examples](https://github.com/mbientlab/MetaWear-SDK-JavaScript/tree/master/examples).
11
+
This is a thin wrapper around the [MetaWear C++ API](https://github.com/mbientlab/Metawear-CppAPI) 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
12
13
-
Under the hood it uses [Noble](https://github.com/mbientlab/noble) for Bluetooth Low Energy communications.
13
+
Also, check out the JavaScript [examples](https://github.com/mbientlab/MetaWear-SDK-JavaScript/tree/master/examples).
14
+
15
+
Under the hood it uses [Noble-Device](https://github.com/mbientlab/noble-device) and [Noble](https://github.com/mbientlab/noble) for Bluetooth Low Energy communications. These third party libraries have been abandoned and we are currently supporting a custom fork (with help from @abandonware).
16
+
17
+
> ADDITIONAL NOTES
18
+
You can try to get our JS SDK running on OSX or Windows at your own risk. This requires that you get Noble to work under those OSs yourself. We do not provide examples or support for this; experts ONLY. Please see the Noble README.
14
19
15
20
### Overview
16
21
17
22
[MetaWear](https://mbientlab.com) is a complete development and production platform for wearable and connected device applications.
18
23
19
-
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!
24
+
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!
20
25
21
26
The MetaWear hardware comes pre-loaded with a wirelessly upgradeable firmware, so it keeps getting more powerful over time.
22
27
23
28
### Requirements
24
29
-[MetaWear board](https://mbientlab.com/store/)
25
-
- A linux or Windows 10+ machine with Bluetooth 4.0
30
+
- A linux machine with Bluetooth 4.0/5.0
26
31
27
32
### License
28
-
See the [License](https://github.com/mbientlab/MetaWear-SDK-JavaScript/blob/master/LICENSE).
33
+
See the [License](https://github.com/mbientlab/MetaWear-SDK-JavaScript/blob/master/LICENSE.md).
29
34
30
35
### Support
31
36
Reach out to the [community](https://mbientlab.com/community/) if you encounter any problems, or just want to chat :)
32
37
33
38
## Getting Started
34
39
40
+
### Pre-Installation
41
+
42
+
#### Node and NPM
43
+
You need to make sure you have node and npm installed on your machine. Here's a quick rundown but you should google-fu proper steps for your specific OS and Node version.
44
+
45
+
We are currently supporting Node 10.23.0. Here are steps to install Node on Linux (Ubuntu). You have 3 options:
46
+
47
+
##### 1. You can install Node from the repositories:
48
+
```
49
+
sudo apt install nodejs
50
+
sudo apt install npm
51
+
nodejs -v
52
+
```
53
+
This will install the latest Node. You may need to alias nodejs to node.
This will install node v10.23.0 (latest stable release of node 10). You can replace the 10 with 12 if you want to install node 12. You may need to alias nodejs to node.
Check the latest version of NVM before you install (it might be higher than v0.35.3). You can go online to learn how to use NVM to switch node versions on the fly.
75
+
76
+
##### Using sudo - a Warning
77
+
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 warning and the scripts won't work). You need to decide if you are ok to use sudo or not. If you are not, follow this [guide](https://github.com/sandeepmistry/noble#running-on-linux)
78
+
79
+
You also need to check that the version of node you are using is as expected for sudo:
80
+
```
81
+
$ node -v
82
+
v0.10.23
83
+
$ sudo node -v
84
+
v0.11.8-pre
85
+
```
86
+
As you can see here, the sudo node version is not the same as the current user version. Here's a [workaround](https://stackoverflow.com/questions/21215059/cant-use-nvm-from-root-or-sudo). You can google-fu more about this topic.
87
+
```
88
+
n=$(which node); \
89
+
n=${n%/bin/node}; \
90
+
chmod -R 755 $n/bin/*; \
91
+
sudo cp -r $n/{bin,lib,share} /usr/local
92
+
```
93
+
94
+
##### Using bluez, BLE Dongles, and Node
95
+
At the time of this release, Node 10 is supported. Node 12 is not currently supported as `node-ffi` and some other libraries have not been updated.
96
+
We have to use a custom fork of node-ffi until then (see package.json). Hopefully node-ffi will be updated to support Node 10 and Node 12 officially.
97
+
98
+
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)
99
+
100
+
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).
101
+
102
+
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.
103
+
104
+
This may or may not work on arm64. Works on armhf and raspberryPi 3 and RaspberryPi 4.
105
+
35
106
### Installation
36
107
37
-
Before getting started, you need to setup the [prerequisites for Noble](https://github.com/mbientlab/noble#prerequisites). While you are there, familiarize yourself with the reset of the README since there a few limitiations and other gotchas spelled out.
108
+
You have three options for installation:
38
109
39
-
Then you can simply install the NPM module:
40
-
```javascript
110
+
#### 1. Use NPM
111
+
The Mbient JavaScript SDK relies on [Noble](https://github.com/mbientlab/noble) and [Noble-Device](https://github.com/mbientlab/noble-device) for Bluetooth Low Energy communications.
112
+
113
+
You need to setup the relevant [prerequisites for Noble](https://github.com/mbientlab/noble#prerequisites) and then [install Noble](https://github.com/mbientlab/noble#install). Make sure you use our versions of these libraries as the original packages have been abandoned.
114
+
115
+
Then you can simply install the MetaWear package lib with NPM using the command line:
116
+
```
41
117
npm install metawear
42
118
```
119
+
This step takes a long time as all the packages are installed and the MetaWear CPP library will be compiled on your machine. You may or may not need to update.
120
+
```
121
+
npm update metawear
122
+
```
43
123
44
-
### Usage
124
+
#### 2. Use our Repository
125
+
You can install the metawear package straight from our repository by using:
Then you can simply install all the dependencies you need by building the npm project with command line:
140
+
```javascript
141
+
npm install
142
+
```
143
+
This step takes a long time as all the packages are installed and the MetaWear CPP library will be compiled as well.
144
+
145
+
#### Errors and Issues
146
+
If you have any issues with the npm installation, make sure you are using the correct version of node, npm, nvm (if used), bluez, and that your machine is bluetoothLE compliant. Follow the errors and correct them as indicated by the npm output log.
147
+
148
+
If you have any issues compiling the `MetaWear-CPP-SDK` (this is a post script that runs at the end of npm install), simply build it from source.
149
+
If you cloned the repo:
150
+
```
151
+
cd MetaWear-SDK-Cpp/
152
+
make
153
+
```
154
+
If you ran an npm command:
155
+
```
156
+
cd node_modules/
157
+
cd MetaWear-SDK-Cpp/
158
+
make
159
+
```
45
160
161
+
#### Running your first Script
162
+
Once the install is successful, you can run our example scripts in the example folder (see the example folder in our repository):
163
+
```javascript
164
+
node led.js
165
+
```
166
+
167
+
Please note that depending on your node and npm installation, you may need to run sudo:
168
+
```javascript
169
+
sudo node led.js
170
+
```
171
+
172
+
Please note that the examples in our examples folder will use the local metawear libraries (as this repository is meant for development):
173
+
```javascript
174
+
var MetaWear =require('../index')
175
+
```
176
+
This is using the local metawear code.
177
+
178
+
Simply change it to this:
179
+
```javascript
180
+
var MetaWear =require('metawear');
181
+
```
182
+
This would be using the metawear code in your local npm `node_modules` directory as installed with npn.
183
+
184
+
#### Notes
185
+
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.
0 commit comments