The Neblina™ module is a low-power self-contained AHRS, VRU and IMU with Bluetooth® SMART connectivity developed by Motsai. The miniature board built with the latest HDI PCB technology, features a high-performance patent-pending sensor fusion algorithm on-board, that makes it perfect for wearable technology devices in applications such as biomechanical analysis, sports performance analytics, remote physical therapy monitoring, quantified self, health and fitness tracking, among others.
The ProMotion Development Kit serves as a reference design for Neblina integration; adding storage, micro-USB port, battery, and I/O expansion to the Neblina. A NOR flash recorder and an EEPROM module are also included on the ProMotion board. The development kit with the extensive software support allows system integrators and evaluators to start development within minutes.
This repository is part of the development kit that provides a Python interface to interact with and simulate the behaviour of Neblina.
- python3
- pip3
- pyserial
- bluepy (Linux-only)
- Windows 10 64-bit or Ubuntu 14.04 LTS 64-bit
- ProMotion board
- Micro USB cable
Refer to the Quick Start guide to learn about the hardware.
In order to connect neblina to the computer, the COM port name is required. Follow these steps to retrieve the COM port name associated with Neblina, depending on your platform.
- Disconnect
ProMotion
from the computer, if already connected, and then turn it off. - Prior to connecting
ProMotion
, openDevice Manager
and navigate toPorts (COM & LTP)
. - Connect
ProMotion
to the computer using the micro-USB port. Note thatProMotion
should be turned off when plugging it into the computer. - Monitor the change to the list of COM ports. The COM ports names follow the
COMx
pattern (wherex
is the associated COM port number)
- Disconnect
ProMotion
from the computer, if already connected, and then turn it off. - Prior to connecting
ProMotion
, execute the following command at the terminal.
$ ls /dev/ttyACM*
- Connect
ProMotion
to the computer using the micro-USB port. Note thatProMotion
should be turned off when plugging it into the computer. - Run
ls /dev/ttyACM*
again and find the change to the list of ports. The COM ports names follow the/dev/ttyACMx
pattern (wherex
is the associated COM port number) - It is required to give permissions to use the COM port. Set with the following command by replace
x
with the associated COM port number, and<username>
by the currently logged in user:
$ chown <username> /dev/ttyACMx
The unit tests allow for the validation of the decoding and encoding process of the packets transferred between the computer and the board. Make sure the pyslip submodule has been cloned (see below) and then you can run the unit tests by executing the script:
$ ./runNeblinaDataTests.sh
It is suggested to install these dependencies in a virtual environment. More information here.
$ git clone https://github.com/Motsai/neblina-python.git
On Linux here are the minimum requirements:
$ apt-get install python-pip3
$ pip3 install pyserial
To be able to use Bluetooth Low Energy (BLE) on Linux, you must also install these dependencies:
$ apt-get install libglib2.0-dev
$ pip3 install bluepy
In order to include the directories required to run neblina-python
, add the following lines at the end of ~/.bashrc
by replacing /path/to/the/repo/
with the path where neblina-python
folder is located:
$ export PYTHONPATH="${PYTHONPATH}:/path/to/the/repo/neblina-python"
It is recommended to run source ~/.bashrc
to execute the file you just modify to apply the changes. Otherwise, you need to open a new shell.
On Windows, you can first install pip and then simply try:
$ pip3 install pyserial
Note that if you are using Python 3.4 or higher, the pip is already installed on your machine. Currently, the BLE package is not available on Windows.
This demo is to demonstrate the capability of the ProMotion board to stream Euler angles through BLE and a Bluetooth dongle. Start by turning on your ProMotion kit by pressing the side button for 3 seconds. Once the LED lights up, you know it turned on. The device should be broadcasting its presence and MAC address to all who are listening.
The ProMotion's MAC address can be found by opening the Bluetooth icon in the top panel on your Linux machine, and doing a scan over the available BLE devices. Alternatively, it can be found by using the bluez utility hcitool.
python3 <base dir>/examples/streamEulerAngle.py -a <ProMotion MAC Address>
You can stop the streaming at any time by hitting Ctrl+C, otherwise it will continue streaming.
The list of all available features that can be streamed to both BLE and USB interfaces is available on the Neblina firmware's Release Notes.
The interactive shell currently supports only USB (not BLE). However, both Windows and Linux machines are supported.
cd <base dir>/examples
python3 streammenu.py -a <>
On the execution of the shell script, the program will ask you for the name of the COM port to connect to. Type the name of the COM port associated with the module and press 'Enter'.
To explore different streaming features of the ProMotion board, run the stream menu shell script, and type "help" to see the available commands:
help
Through the rest of this guide, we will go through a number of examples to explore the streaming features of the ProMotion board.
streamQuaternion
The quaternion data will then be streamed to the console. The information includes a timestamp in microseconds, which is followed by the four elements of a unit-length quaternion vector.
You can stop the streaming at any time by hitting Ctrl+C.
streamEulerAngle
This will stream the Yaw, Pitch and Roll angles in degrees using the aerospace rotation sequence, where Yaw takes place first, and is then followed by Pitch and Roll. The timestamp value in microseconds is also provided. The streaming can be stopped by hitting ctrl+C.
To stream the 3-axis accelerometer and gyroscope data:
streamIMU
To stream the 3-axis accelerometer and magnetometer data:
streamMAG
getBatteryLevel
getTemperature
To record, and playback a specific motion feature:
eraseStorage 0 //erase the on-chip recorder (optional), 0: quick erase, 1: mass erase
sessionRecordQuaternion <number of samples> //by default, the streaming frequency is 50 Hz.
sessionPlayback <session ID> <dump to file option> //use the same session ID as returned by the record command
Note from the above snapshot that the session ID "0" has been returned after the recording is issued. Consequently, the playback command should define the session ID "0" to point to the right session on the NOR flash. Furthermore, the <dump to file>
option is enabled above to store the data into a csv file. The dump file will be stored in the "record" folder:
You can also try recording the IMU raw sensor data, or Euler angles using the following commands:
sessionRecordEulerAngles <number of samples>
sessionRecordIMU <number of samples>
At any time, you can inquire about the number of sessions present in the recorder, as well as the length of each session:
getSessionCount //returns the total number of recorded sessions in the NOR flash recorder
getSessionInfo <Session ID> //returns the length of a recorder session
EEPROMWrite <page_number> <string>
EEPROMRead <page_number>
For more information on streammenu commands or to see all available commands, please refer to the reference guide