jurassic-marc / witmotion-bwt901cl-accelerometer-reverse-engineer

Reverse engineering the WitMotion BWT901CL accelerometer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reverse Engineering WitMotion BWT901CL Accelerometer

This project is concerned with reverse engineering the WitMotion BWT901CL accelerometer to enable its feed to be ingested through the kdb+ TICK architecture.

Disclaimer

This project was developed using:

  • WitMotion BWT901CL accelerometer
  • Linux
  • kdb+/q
  • KX Dashboards

The project was developed on Linux Ubuntu 16.04 LTS.

This software was last ran on 18/03/2021.


Introduction

This package allows users to display stream information including acceleration, angular velocity and angle from the WitMotion BWT901CL accelerometer through KX Dashboards.

Getting Started

Follow the instructions below to display your accelerometer's data.

Prerequisites


Download and configure kdb+/q

To download and configure kdb+/q, follow this link.

Download KX Dashboards

To download KX Dashboards, follow this link.

This project uses CLI commands which have been depreciated in later versions of Linux. This project assumes that these tools are installed on your local machine but it notes alternative commands that can be used when appropriate.

Elevate permissions to root

Run the super user command and enter your password when prompted:


sudo su


Ensure Bluetoothd is running

Run the system command to bring up your Bluetooth daemon service:


systemctl start bluetoothd

or


service bluetoothd start

To check bluetoothd is running, run the following:


systemctl status bluetoothd

or


service bluetoothd status

You should get a read out like:


● bluetooth.service - Bluetooth service
   Loaded: loaded (/etc/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-11-06 21:38:45 CET; 6s ago
     Docs: man:bluetoothd(8)
 Main PID: 2434 (bluetoothd)
   Status: "Running"
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/bluetooth.service
           └─2434 /usr/lib/bluetooth/bluetoothd


Ensure Bluetooth adaptor is up

Run the command below to bring up your registered Bluetooth adaptor:


hcitool dev up

To verify your Bluetooth adaptor is up, run this command:


hcitool dev

You should get a read out like this:


Devices:
        hci0    74:DF:BF:37:DA:C0


Installation

To install this project on your local machine, follow these instructions:

  1. Clone this repo to your local machine:

git clone <HTTPS URL>/witmotion-bwt901cl-accelerometer-reverse-engineer.git /path/to/proj/


  1. Turn on your accelerometer.

Configuration

To configure this application follow these steps.

Discover your BWT901CL accelerometer's MAC address

In a Linux terminal run the following commands:


bluetoothctl

then in the Bluetooth controller prompt


scan on

then after a few seconds


scan off

finally, search through the printed MAC addresses for the accelerometer's, it should look something like this


[NEW] Device 20:20:08:24:49:23  HC-06

or


hcitool scan

then search through the printed MAC addresses for the accelerometer's, it should look something like this


[NEW] Device 20:20:08:24:49:23  HC-06

Note: If the accelerometer was undetected, run the above command with lescan rather than scan.


Verify your BWT901CL accelerometer

This is an optional step to verify that our MAC address is correct by running the following:


hcitool info 20:20:08:24:49:23

You should get something similar to the following:


Requesting information ...
        Handle: 32 (0x0020)
        LMP Version: 4.2 (0x8) LMP Subversion: 0x22bb
        Manufacturer: Telink Semiconductor Co. Ltd (529)~
        Features: 0x39 0x00 0x00 0x00 0x00 0x00 0x00 0x00


Alter the script to point to your BWT901CL accelerometer's MAC address

In the ./init.sh script change the placeholder MAC address with your accelerometer's:


rfcomm bind rfcomm0 20:20:08:24:49:23

picocom /dev/rfcomm0 -b 115200 > stream.txt


Operation

Note: The stream scripts run in the background so can be ran in the same terminal, however the kdb+ server and KX Dashboards server run in the foreground so 2 terminal tabs are required.

Follow the steps below to display your accelerometer's stream.

Start and record the accelerometer's stream

Run the corresponding script:


sh ./bin/init.sh &


Parse the accelerometer's stream

Run the corresponding script:


sh ./bin/parse.sh &


Bring up the kdb+ server

Run the corresponding script:


q ./q/init.q


Bring up the KX Dashboards server

Run the corresponding script:


q dash.q -p 10001 -u 1

Note: This must be ran inside the KX Dashboards folder.


Configure a dashboard

To configure your data connection and UI components, follow this video.

Note: The port used for the kdb server is 6010.


Issues

No Bluetooth adaptors detected

If running the following command:


hcitool dev

Results in:


Devices:
        _____


Your Linux OS does not recongise any Bluetooth adaptors. This is likely if you are running Linux non-natively, i.e. Virtual Machine, virtualisation, etc. Install Linux natively as a dual-boot OS or seek online advice.

Author

Marc Templeton | LinkedIn | Medium

About

Reverse engineering the WitMotion BWT901CL accelerometer.


Languages

Language:q 72.5%Language:Shell 27.5%