Wireless Sensor Hobbyist Project using a Nordic nRF52840 Dongle and a Raspberry Pi computer. The Nordic chip is attached to an accelerometer, magnetometer and gyroscope, which is used for an AHRS (Attitude and Heading Reference System). The output from the AHRS is sent over Bluetooth Low Energy (BLE) from the Nordic to the Raspberry Pi where the object orientation is visualized using the Raspberry Pi graphics hardware, and control of the AHRS parameter settings can be interactively changed using a Python-based GUI.
The project is under active development. The AHRS calibration routines are still very primitive and so the calculated Euler angles are not terribly accurate at this time. With improvements to the calibration routines I expect much better accuracy.
The Raspberry Pi3B is able to receive the Euler angles from the Nordic chip over Bluetooth LE, and to visualize the orientation using the Pi graphics by displaying a primitive 3D cube. The response time is very good. The calibration and control panel GUI on the Raspberry Pi operates correctly but still needs a lot of improvement.
The IMU is not currently available from Adafruit, however I am looking into adding support for a more readily available IMU with an I2C interface that would have the same or better performance and functionality.
- Nordic Semiconductor nRF52840 Dongle
- Adafruit 4485 -- LSM6DS33 + LIS3MDL - 9 DoF IMU with Accel / Gyro / Mag or equivalent
- Raspberry Pi3B (may work with other Pis)
- Personal computer, Ubuntu Linux or Windows running WSL, with USB-A Connector
- Optional: Adafruit #3309 - CP2104 Friend - USB to Serial Converter or equivalent, for Serial Console to Nordic chip.
- Optional: liPo Battery for Nordic chip
- Nordic Semiconductor nRF52 SDK v17.1.0 or later Select s140 Softdevice support.
- Nordic recommended Development IDE. One of the following:
- ARM GNU/GCC (Recommended for this project, version 9.2 or later).
- SEGGER Embedded Studio (SES)
- MDK-ARM Keil µVision
- IAR
- Python3
- BlueZ v5.47 or later
- Bluepy v1.3 or later
The Software development platform I've used for the Nordic Semiconductor Board is an x86 Windows PC running Windows WSL (Windows Subsystem for Linux).
I have also used Cygwin which is a software layer which runs on top of Windows 10/11 and provides functionality similar to a Linux distribution. You can compile the Nordic Semiconductor source code once you have installed the GNU GCC toolchain (using Cygwin's package manager). It's a very simple way to run Windows and Linux applications on the same box.
Assumes Ubuntu TLS 22.04.04 LTS running under Windows WSL.
sudo apt-get install gcc-arm-none-eabi
In the Nordic nRF52 SDK, edit the file components/toolchain/gcc/Makefile. and change the following Makefile variables to point to your installation and version of the ARM gcc compiler (Linux example shown, Makefile.posix).
GNU_INSTALL_ROOT ?= /usr/bin/ GNU_VERSION ?= 10.3.1 GNU_PREFIX ?= arm-none-eabi
Edit the location of the Nordic SDK in the WirelessSensor/Sensor/src/Makefile:
SDK_ROOT := /home//NordicSDK/nRF5_SDK_17.1.0_ddde560
- cd into the Directory Sensor/src
- Type 'make'
- Install Nordic firmware onto board using nRF Connect for Desktop via USB or SEGGER debugger
This installation covers Ubuntu 22.04.04 LTS Assumes python3.10 is already installed
sudo apt update sudo apt upgrade
sudo apt-get install bluez
sudo apt-get install python3-pip
sudo apt-get install libglib2.0-dev
pip install bluepy
sudo apt-get install python3-tk
pip install matplotlib
sudo apt install python3-opengl pip3 install PyOpenGL
pip install pyopengltk
AttributeError: 'EGLPlatform' object has no attribute 'GLX'. Did you mean: 'GL'?
unset WAYLAND_DISPLAY or pip3 install --force-reinstall "PyOpenGL==3.1.5"
#sudo apt install libgles2 #sudo apt install libgles2-mesa #sudo apt install libegl-dev
- Refine AHRS calibration
- Improve calibration algorithm for accelerometer
- remove fixed constants
- require less operator intervention to do calibration
- Angles take a while to stabilize
- use magnetometer to calibrate gyroscope
- add support for setting hardware register configuration bits
- Fix singularity at North and South Poles, can't get to 90 degree pitch (gimbal lock)
- Fix Pitch sign reversal
- Further testing
- Nordic Timer to drive AHRS to improve accuracy? sampleFreq needs to be set right.
- Re-organize all code
- Place devi2c better, why does not work in constructor
- BLE code
- DFU Over the Air Updates
- cleanup BLE code to remove junk
- Remove / replace HRS and other remnants
- Improve performance, being aware of battery life
- Battery Power
- Prototype Board
- Calibration Storage, so you don't have to do calibration every time you power on components/libraries/fds/fds.h
- Add Doyxgen documentation for all code, procedures, and parameters
- Add circuit schematic
- Add general documentation on the project, algorithms, calibration
- Develop Mechanical Test fixture to hold board and measure actual orientation to compare against calculated orientation.
- Improve Calibration and Control GUI
- Look at adding support for Visual Studio Code
- On Server side, look at adding support for Arduino
- On Client side, look at adding Android support