Playing with the Atomic Pi’s gyroscope and accelerometer (BNO055)

Martin Dobberstein (gutschilla)
5 min readJul 10, 2019
Bottom: The power breakout board with a 2.5mm power jack. Top: the 5V 4A power supply.

So I got myself an Atomic Pi to tinker around. I bought it out of curiosity. An x86 CPU with a gyro for cheap. Gotta try this out!

Yes. A 35$ computer board that needs soldering (or a 7$ expansion board) to power it. I bough both on Amazon for 52$ + shipping. I power it with a Leicke 5V 4A power supply for 17€ even though 3 Amps should be enough. But as I want to use the Atomic Pi 24/7 … I prefer keeping a safety margin.

The grand plan for the gyroscope/acceleromenter

The idea is that the Atomic Pi will check it’s horizontal and vertical position and acceleration periodically and send that data over to a server where we can store that data and plot nice charts from that, triggering alerts from certain thresholds.

An overpowered poor man’s intrusion detection system. That’s right!

Connect the jacks

Thankfully, the Atomic Pi comes with an Ubuntu 18.04 derivative pre-configured. I connected the HDMI port with a monitor and connected the power supply to the 2.5mm power jack, added a cheap USB hub since there’s only one USB-A port on the board to get both a mouse and keyboard attached.

I am curious whether that password is the same for all Atomic Pies.

The first login screen shows the default password for the user “atomicpi”. You probably want to change that immediately after login.

Connecting to the BNO055 accelerometer on i2c bus

Digital Loggers, the company behind the Atomic Pi put up with a github repo with some examples for the BNO055. Unfortunately they don’t work out of the box and require some digging in the fine manual:

Chapter 3.1 (Using BNO055 from Node.JS) sais that the accelerometer is configured on I2C bus 50.

Second, the README for their github repo https://guthub.com/digitalloggers/node-BNO055is a bit out of date.

You will need a C compiler and NodeJS Version 8 via

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y build-essential nodejs

to get the dependency ic2-busto compile. Versions 10 and 12 won’t work.

Now get some data

This a minimally-tweaked index.js from their repo. The key difference is the module name ‘bno055’ and the device address /dev/i2c-50 . I also reordered the output and round values to better fit in a publication. In production you probably just go with the floating numbers returned.

var BNO055 = require('bno055');
var async = require('async');
var imu = new BNO055({device: "/dev/i2c-50"});imu.beginNDOF(function() {
console.info('imu running');
setInterval(function() {
async.series({
euler: imu.getEuler.bind(imu),
linearAcceleration: imu.getLinearAcceleration.bind(imu)
},
function(err, results) {
var rot = results.euler;
var accel = results.linearAcceleration;
var data = {
heading: Math.round(rot.heading),
roll: Math.round(rot.roll),
pitch: Math.round(rot.pitch),
x: Math.round(accel.x),
y: Math.round(accel.y),
z: Math.round(accel.z),
};
console.info( 'imu: ', JSON.stringify(data) );
});
}, 250);
});

Starting the script as root (superuser access needed to access the i2c device)sudo nodejs index.js yields:

imu running
imu: {"heading":360,"roll":-6,"pitch":-2,"x":0,"y":0,"z":0}
imu: {"heading":360,"roll":-6,"pitch":-2,"x":0,"y":0,"z":0}
imu: {"heading":0,"roll":-6,"pitch":-2,"x":0,"y":0,"z":0}
imu: {"heading":2,"roll":-2,"pitch":5,"x":0,"y":0,"z":1}
imu: {"heading":3,"roll":-13,"pitch":8,"x":1,"y":-1,"z":-3}
imu: {"heading":6,"roll":-30,"pitch":1,"x":1,"y":0,"z":0}
imu: {"heading":6,"roll":-24,"pitch":1,"x":0,"y":0,"z":0}
imu: {"heading":360,"roll":2,"pitch":2,"x":0,"y":0,"z":-1}
imu: {"heading":355,"roll":9,"pitch":5,"x":1,"y":-1,"z":0}
imu: {"heading":0,"roll":-25,"pitch":20,"x":-1,"y":0,"z":-2}
imu: {"heading":11,"roll":-65,"pitch":53,"x":0,"y":0,"z":0}
imu: {"heading":7,"roll":-57,"pitch":170,"x":-1,"y":0,"z":0}
imu: {"heading":8,"roll":-22,"pitch":-175,"x":0,"y":-1,"z":0}
imu: {"heading":17,"roll":-7,"pitch":-171,"x":1,"y":0,"z":0}
imu: {"heading":13,"roll":-15,"pitch":-171,"x":-1,"y":0,"z":1}
imu: {"heading":356,"roll":-66,"pitch":-179,"x":-1,"y":-1,"z":0}
imu: {"heading":359,"roll":-64,"pitch":45,"x":1,"y":-1,"z":1}
imu: {"heading":358,"roll":-28,"pitch":41,"x":1,"y":1,"z":1}
imu: {"heading":84,"roll":-13,"pitch":49,"x":0,"y":0,"z":0}
imu: {"heading":85,"roll":-25,"pitch":32,"x":0,"y":1,"z":2}
imu: {"heading":85,"roll":-39,"pitch":-7,"x":1,"y":0,"z":0}
imu: {"heading":81,"roll":-23,"pitch":-7,"x":1,"y":-2,"z":1}
imu: {"heading":85,"roll":-10,"pitch":-1,"x":-1,"y":0,"z":0}
imu: {"heading":94,"roll":-5,"pitch":3,"x":0,"y":4,"z":1}
imu: {"heading":87,"roll":-6,"pitch":0,"x":0,"y":-3,"z":0}
imu: {"heading":88,"roll":-6,"pitch":-1,"x":0,"y":-1,"z":

Yay! As we can see, I first rotated the device around (roll and pitch) and then shook it back and forth (y: 4, y: -3).

All we need from here is

  • sending that data to a server
  • storing it
  • exporting it as time series
  • abuse Prometheus/Grafana for long-term storage and display

Comparison and rationale

I am pretty impressed by the Atomic Pi.

Price: The base board is really just 35$ and capable solderers should find a way around using the 7$ power breakout board. Power supplies in the US ship at around 10$. So more or less the Raspberry Pi’s price point.

  • The only reasonable x86 CPU-bearing board below 100$ I know of. And much below 100$.
  • But already packing a gyroscope and accelerometer. An absolute orientation breakout from adafruit packing the same BNO055 chip is 35$ alone.
  • But already coming with 16GB of eMMc. 4$ saved on an SD card! Yay!
  • But already running a ready-to-use Linux. Power on, go play.
  • It has a stereo amp — add 12V 1A power and you can drive 2 x 5W speakers directly from the board. For whatever reason you would want to combine that capability with a gyro/accel (maybe some position-driven KAOSS pad-alike).

So it’s not all that much.

But if you want to have a ready-to-use computer with a gyroscope and accelerometer which is not your old smartphone then it’s pretty great!

Or if you’re bound to use x86 software — plain standard desktop software (Did anyone say Windows?)

Speed: The Atomic Pi’s QuadCore Intel Atom x5-Z8350 CPU running at 1.44GHz is quick, the thing is almost usable as a desktop computer. Browsing the internet with Chromium is really OK.

The desktop: I’d probably use plain a Ubuntu for desktop usage.

Synthetic testing with Chromium on browserbench.org showed:

  • Raspberry 3B+: 5.4 runs/minute
  • Raspberry 4B 2GB: 17.4 runs/minute (pretty impressive gain)
  • Atomic Pi: 15.62 runs/minute
  • My 2016 XPS13 (i5–6200U): 57.0 runs/minute

So, while it runs circles around the Raspberry Pi 3, it’s basically on par with version 4 — the 2GB version is a bit more expensive than the Atomic Pi but considering the 8$ power expansion card it’s basically the same.

Tomorrow, I’ll weld this thing to my apartment’s door 🙂

--

--

Martin Dobberstein (gutschilla)

Roles: Web agency co-founder, Freelance consultant, Tech-Lead at a banking startup, IT Head, Solution Architect