The new Nexus phones com with the all new, all exciting 'Android Sensor Hub'. Apple has a similar thing, they call it the 'Motion Coprocessor'. I recently worked with the tech behind those names and I wanted to take the minute and explain what I know.

PCBs tell stories, you just have to listen

Thanks to iFixit and their Teardowns! And the smart people there identifying chips!

Let's start with the STM32. This chip is a microcontroller. A microcontroller is a processors smaller cousin. It doesn't run an OS, but it can still be programmed. It just runs that program, with no Operating System between it and the hardware. It can't do a lot of the stuff a processor can, but it still can do a lot of stuff and with very little power. The core of this microcontroller comes from ARM and is called 'Cortex'. In the same way ARM has cores for processors, they also have cores for microcontrollers.

Next up, the BMP280. This sensor measures temperature and air pressure. From the air pressure, you can calculate the height, same way an airplane does. It's not good for absolute height, because the air pressure is dependent on the weather, but for height differences, it works great. It's way good enough to tell if you changed floors in a building.

The BMI160 is a combined accelerometer and gyro. The accelerometer measures the acceleration. That way the phone always knows where 'down' is (because it measures 1g in this direction) and it can measure shocks, etc. The gyro does the same, but for rotary acceleration instead of linear acceleration. When you rotate your phone, it measures how fast the pace of the rotation changes.

Finally, the BMM150 is a geomagnetic sensor, it measures earth's magnetic field and is the core of all your compass apps.

All data is beautiful

How does all of this go together?

From air pressure, you get height, from the compass you get orientation, from accelerometer and gyro you get movement. Combine all that data, and you get a really good picture of the devices altitude, attitude and how it moves. If you are on a plane, all that data is combined to tell you pitch, roll and yaw and the rate at which they change. This is what keeps your Quadcopter from crashing. The whole idea is simply called 'Sensor Fusion'. To get all that data together, it has to be read from the sensors and processed, using algorithms to combine the different measurements. This is what the STM32 microcontroller does. It can do that more directly and with less overhead than the main processor, running all the algorithms very efficiently and providing the processed data. It's a dedicated chip, like a GPU, but for sensor data.

If you further combine that data with the position from GPS, you can greatly improve the GPS performance.

Further down the rabbid hole

Every Smartphone out there has those sensors (some of them don't have gyros, tough). Some of them have the extra microcontroller. The iPhones is on the same chip as the main processor (remember, those are ARM cores, you can license them in the same way you can license ARM cores for processors). Every Quadcopter and drone also has those.

And for us, that's great. An by 'us', I mean hackers, makers and tinkerers. You can buy those same chips in quantities of one yourself. I use chips from Bosch (obviously there also are other vendors, like InvenSense) in water rockets, to measure the flights height and acceleration. There are numerous projects out there who also use them. Self-built drones, robots, etc. The cool thing about Bosch's sensors is that they have Open Source drivers and I guess that may also have played a role in why Google chose to use them.

What I don't get however, is why they chose exactly those chips. Bosch offers a chip named BNO055 and that's the one I'd chosen. It combines the accelerometer, the gyro, the geomagnetic sensor AND the microcontroller on ONE chip measuring 5x4 mm. So instead of 4 chips, you'd have just two. The microcontroller on the BNO055 can also take the data from all it's own chips and external ones - the pressure sensor - perform the Sensor Fusion and provide the data to the main processor. Having everything in one chips saves space and reduces the complexitx of the PCB, because you don't have to run wires from the sensor to the microcontroller.

The BNO055 costs about $12 if you buy one, which is a lot, but it's also amazing that you can buy them at all. If you buy 1000 pieces, the prices goes down to $8 - you can imagine that they get even cheaper when you buy millions, like Smartphone manufacturers do.

And you don't even have to make your own PCBs, you can just head over to Adafruit and buy a readymade 10DOF and a microcontroller board like the Arduino or whatever else you like and start building stuff on your own. There are even Open Source implementations of Sensor Fusion algorithms.

Turns out, the 'Android Sensor Hub' and 'Motion Coprocessor' are the most accessible parts in a modern smartphone. If your are nerd enough, you could build your own for about 20 (hard) to 50 (easier) bucks.

I know because I did.