FlutterMindWaveMobile2 is a plugin to connect and receive data from the Neurosky MindWave Mobile 2 using Flutter, a new mobile SDK to help developers build modern apps for iOS and Android.
FlutterMindWaveMobile2 aims to offer the most from both the Android Developer Tools 4.2 and iOS Developer Tools 4.8 from Neurosky. Data is fed from the COMM SDK into the EEG Algorithm SDK (see note below).
Android by default uses the EEG Algorithm, but iOS requires a license key to use the EEG Algorithm SDK. However, the COMMS SDK (used to feed the EEG Algorithm SDK) is still available and providing values on all channels except Band Power (BP) (see supported algorithms below).
Please contact Neurosky for a client specific license key.
This plugin will NOT connect in Android Emulator and will NOT build on iOS simulator.
All algorithm data have a fixed output interval of 1 second.
Android | iOS (with License) | iOS (without License) | Description | |
---|---|---|---|---|
Attention (Att) | ✔️ | ✔️ | ✔️ | Attention index ranges from 0 to 100. The higher the index, the higher the attention level. |
Meditation (Med) | ✔️ | ✔️ | ✔️ | Meditation index ranges from 0 to 100. The higher the index, the higher the meditation level. |
Band Power (BP) | ✔️ | ✔️ | EEG bandpowers (in dB) index for: delta, theta, alpha, beta, and gamma. | |
Eye Blink Detection (Blink) | ✔️ | ✔️ | ✔️ | Eye blink strength (no baseline data collection will be needed). |
Signal Quality | ✔️ | ✔️ | ✔️ | Signal quality value of the device ranges from 0 to 200. The lower the value, the better the signal. |
Add flutter_mindwave_mobile_2
as a dependency in your pubspec.yaml file:
dependencies:
flutter_mindwave_mobile_2: '^0.1.0'
Then import the plugin into your dart file.
import 'package:flutter_mindwave_mobile_2/flutter_mindwave_mobile_2.dart';
This plugin requires the MindWave Mobile 2 Bluetooth device ID. An easy way to accomplish this is with using FlutterBlue. For example:
import 'package:flutter_blue/flutter_blue.dart';
FlutterBlue flutterBlue = FlutterBlue.instance;
var scanSubscription = flutterBlue
.scan()
.listen((ScanResult scanResult) {
var device = scanResult.device;
var name = device.name;
if (name == 'MindWave Mobile') {
var deviceId = device.id.toString();
}
});
FlutterMindWaveMobile2 flutterMindWaveMobile2 = FlutterMindWaveMobile2();
Returns MWMConnectionState
var connectionSubscription = flutterMindWaveMobile2
.connect(deviceId, licenseKey) // licenseKey is optional for iOS EEG Algorithm
.listen((MWMConnectionState connectionState) {
// Handle state
});
connectionSubscription.cancel();
flutterMindWaveMobile2.disconnect();
Returns AlgoStateAndReason
var algoStateAndReasonSubscription = flutterMindWaveMobile2
.onAlgoStateAndReason()
.listen((AlgoStateAndReason algoStateAndReason) {
// Handle algo state and reason
});
Returns int
var attentionSubscription = flutterMindWaveMobile2
.onAttention()
.listen((int attention) {
// Handle attention
});
Returns int
var meditationSubscription = flutterMindWaveMobile2
.onMeditation()
.listen((int meditation) {
// Handle meditation
});
Returns BandPower
var bandPowerSubscription = flutterMindWaveMobile2
.onBandPower()
.listen((BandPower bandPower) {
// Handle band power
});
Returns int
var eyeBlinkDetectionSubscription = flutterMindWaveMobile2
.onEyeBlink()
.listen((int eyeBlinkStrength) {
// Handle eye blink strength
});
Returns int
var signalQualitySubscription = flutterMindWaveMobile2
.onSignalQuality()
.listen((int signalQuality) {
// Handle signal quality
});
Property | Type |
---|---|
state | AlgoState |
reason | AlgoReason |
Property | Type |
---|---|
delta | double |
theta | double |
alpha | double |
beta | double |
gamma | double |
Values |
---|
disconnected |
scanning (not used in package, but used in example with FlutterBlue) |
connecting |
connected |
Values |
---|
inited |
analysingBulkData |
collectingBaseline |
pause |
running |
stop |
uninited |
Values |
---|
baselineExpired |
byUser |
cbChanged (Android only collecting baseline changed) |
configChanged |
noBaseline |
signalQuality |
userProfileChanged |
unknown |
This plugin is inspired by react-native-mindwave-mobile, but adds on the EGG Algorithm SDK.
This plugin is not affiliated or sponsored by Neurosky in any way.