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!
The gyro/magnetometer notebook lives in the SensorLab Arduino library, in the
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:
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
Select your desired board & port from the Tools menu then click Upload
Open up the serial console, you'll see SensorLab initialization and detection of whatever magnetometer is available. In this case is a LSM9DS1, but any gyroscope can be calibrated!
You'll then see a stream of data that looks like:
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, they should definitely not be zeros!
The last three numbers are magnetometer - if you don't have an magnetometer, they will be 0
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.
Skip the magnetometer cells, and find the Gyroscope offset calibration cell
Place the board down on a flat stable surface, we like to put a book on top of it to keep it flat and steady. You don't want any shifts or movement while you run the calibrator!
You'll see a 3 second countdown, then the serial port is opened and data collected
Once it's done you'll see a plotting of the data output. You should see something like this with red, green and blue lines. There may be some offset as expected, but the lines should wobble around a point without big spikes or increases/decreases.
Above the graph you'll see analysis of the average value (zero-g offset) like so:
In this case, the zero-g calibration is X = 0.044 Y = -0.0148, and Z = -0.0111
The units are in SI units radians / second not degree/s (dps)!
You'll also see the results of removing the offset, this should be 3 noisy but nearly-zero-centered lines. The higher the quality of the gyro, the lower the jitter in the measurements, and the lower the offset.