Jupyter Notebooks are a powerful cross-platform method for analyzing data using Python
You can definitely use Jupyter to plot, analyze and calibrate your sensor data. This method is the most powerful because you can do plotting and calculations. However, we assume you already have Jupyter installed (either desktop or thru Anaconda) and have some familiarity with running 'notebook' style Python!
Step 1 - Download Calibration Notebook
The gyro/magnetometer notebook lives in the SensorLab Arduino library, in the notebooks
folder.
Look for this section in the website:
You must open this notebook within Jupyter - you cannot run it direct from github or from the command line as a text file!
Once open, your browser will look like this:
Step 2 - Upload the SensorLab imucal
Example
Next we have to tell the microcontroller board to send the magnetometer (and, if there is one, accelerometer and gyroscope) data out over serial in the right format.
Open up the Adafruit_SensorLab->calibration->imucal
Open up the serial console, you'll see SensorLab initialization and detection of whatever magnetometer is available. In this case is a LIS3MDL, but any magnetometer can be calibrated!
You'll then see a stream of data that looks like:Raw:-58,-815,8362,76,-121,-95,-375,-159,-24
Uni:-0.07,-0.98,10.00,0.0832,-0.1327,-0.1046,-37.50,-15.93,-2.50
The first three numbers are accelerometer data - if you don't have an accelerometer, they will be 0
The middle three numbers are gyroscope data - if you don't have an gyroscope, they will be 0
The last three numbers are magnetometer, they should definitely not be zeros!
Close the serial port, and go back to Jupyter. In the first cell, find where we define the PORT and change the port to match your serial/COM port. For windows it'll be something like COM4 for Mac/Linux it'll be like /dev/cu.USBSERIAL or something
Run the first cell so the serial port is set
Then run the second cell, you should see output like this - the serial port is opened and IMU raw data is output as numbers
If you get errors or no numbers, hard-reset the board (click the reset button once) then try re-running the cell again.
At the next cell we will perform the data capture. Move the board away from any strong magnets and run this cell
At the bottom of the cell you should start seeing a live plot of 3 circles - each one represents the X, Y and Z offsets. Keep spinning the board in various directions until you get 3 spheroids
Once you're happy, use the mouse to click on the graph. This will cause the data capture to stop
Run the next cell to perform the analysis. You'll get your X/Y/Z magnetic ranges and the final hard-offset calibration values.
In this case, the calibration is X=-5.21, Y=-7.7 and Z= 20.86
Page last edited March 08, 2024
Text editor powered by tinymce.