Adafruit Holiday Shipping Deadlines 2018: Attention! Please place all UPS Next Day orders by Monday 12/17/2018 11 AM EST
0

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, or even use Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for MakeCode, CircuitPython, 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 9,200+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython – Python on Microcontrollers is here!

Have an amazing project to share? Join the SHOW-AND-TELL every Wednesday night at 7:30pm ET on Google+ Hangouts.

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 — Japanese word working and more in December’s issue of HackSpace magazine!

Wearables — Solder-less magic

Electronics — = != ==.

Biohacking — Finding Bliss with Anandamide

Python for Microcontrollers — sysfs is dead! long live libgpiod! libgpiod for linux & Python running hardware @circuitpython @micropython @ThePSF #Python @Adafruit #Adafruit

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



2 Comments

  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.