Adafruit’s New ‘Unified Sensor Driver’!

Adafruit has always prided itself on going the extra mile.  We always try to provide the the best breakouts possible, but we also put that extra bit of effort into making sure we have a driver for each of those products as well.  You want to get started with your new HW as soon as you pull it out of that box … we’re happy to try to make that possible to the best extent that we can!  Call it the Adafruit Difference. 🙂

That said … writing all those drivers can be pretty time consuming, and then you need to add some example code on top of them to show how the driver works.  While I was digging around inside the Android source code for something different, I noticed the intelligent way they abstract away all sensor data down to a single C typedef.  The dial went straight to 11 in my head, and the first thing I thought was: ‘why am I not doing this?!?’.  I pulled out an MCU and tried to adapt the Android code (conveniently written in C), slimming the typedefs down a bit, adding a couple sensor types, … but keeping the same general structure.  After a bit of trial and error, the Adafruit Unified Sensor Driver was born.  Driver use and development will never be the same (at least for me)!

We have a reasonably complete tutorial on how the Unified Sensor Driver System works … but you can also have a look at the source code for Adafruit_Sensor on github.  In a nutshell what does this do, though?  Essentially, it takes any supported sensor type (accelerometers, gyroscopes, pressure sensors, light sensors, etc.) and converts the raw units used by the system (0..1023) into standard SI units on a specific scale.  Every accelerometer using the system will report acceleration in m/s^2, pressure sensors will all use hectoPascal (hPa), light sensors use SI lux units, etc.!  No more 0..1023 … you get units you understand out of the box and every time!

Don’t know which accelerometer to use, or what speed or resolution you need?  No problem … start with whatever you’ve got, and you can just drop in any other ‘Unified’ sensor later.  You’ll get exactly the same SI unit types and scales, call the same two functions, and all you need to change in the single line constructor!  No more out of stock headaches … just take any other similar sensor and use that as a stand-in, and you don’t have to relearn a whole new driver and set of functions.

But have a look at the learning guide, the source code, and try it out if you have a product that currently has a ‘Unified’ drivers (there’s a list here). And above all, let us know what you think and what can be improved.  This is still a bit of an experiment for us, but it definitely feels like the right direction to move things!

Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Join 15,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

What do you want from CircuitPython in 2020?

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Follow Adafruit on Instagram for top secret new products, behinds the scenes and more https://www.instagram.com/adafruit/

Maker Business — Apple’s Mac Pro doesn’t fall far from the tree

Wearables — An unexpected diffusion

Electronics — Proceed with caution

Biohacking — Vitamin-C + Gelatin for Accelerated Recovery

Python for Microcontrollers — CircuitPython powers the Open Hardware Summit for 2020! #Python #Adafruit #CircuitPython @circuitpython @micropython @ThePSF @Adafruit

Adafruit IoT Monthly — Learning from IoT Projects, Adafruit Joins the LoRa Alliance, Ring Ransoms, and more!

Microsoft MakeCode — MakeCode: Opening a World of Possibilities

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !


  1. Looks cool, look forward to trying it, though I hope it doesn’t mean there will no longer be sensor-specific examples.

    For instance, sometimes 0-1023 data is enough and doesn’t need to be converted to units, in applications where the sensor is modulating something else (light or music outputs, for example).

    Still curious to try it out all the same!

  2. AO: You still have the underlying functions (0..1023, etc.) since you need to implement them anyway to do anything useful, and you’re of course still free to call them … this is just another layer that sits on top to standardise things.

Sorry, the comment form is closed at this time.