Since there's dozens of different sensor manufacturers out there, and we don't want to have a ton of #ifdef's in our code to manage each kind, we'll be using Adafruit SensorLab to manage detecting the various magnetometers, accelerometers, pressure sensors... etc!
Adafruit SensorLab automatically detects a wide range of sensors, over I2C, no matter what I2C address it's on. It will return an Adafruit Unified Sensor object that we can query for events. You can't do advanced stuff like manually setting ranges or internal filters, but for many projects the basics will do just fine!
We'll be assuming you have the sensor on the main I2C port, and of course use the matching Adafruit library to verify the sensor is working and powered right before you continue!
Install SensorLab
Since there are a ton of sensors, and we also use Arcada in a few examples, there's a lot of libraries to install
No really, we have a lot of software involved here - probably 20 or so libraries total!
For that reason we really strongly recommend you use Arduino 1.8.10 or greater which handles automatic library dependency installation. Otherwise you will be frustrated...
Select the Sketch -> Include Library -> Manage Libraries...
Search for Sensor Lab and install the Adafruit library you see
Page last edited March 08, 2024
Text editor powered by tinymce.