@@ -118,12 +118,35 @@ config.apply_magnetometer_calibration(mag)
118118
119119---
120120
121+ ## Accelerometer Calibration
122+
123+ Store and restore accelerometer bias offsets for the ISM330DL.
124+
125+ ### Store calibration
126+
127+ ``` python
128+ config.set_accelerometer_calibration(ox = 0.01 , oy = - 0.02 , oz = 0.03 )
129+ Read calibration
130+ cal = config.get_accelerometer_calibration()
131+ # -> {"ox": 0.01, "oy": -0.02, "oz": 0.03} or None
132+ ```
133+
134+ ### Apply calibration to a sensor
135+ ``` python
136+ from ism330dl import ISM330DL
137+
138+ imu = ISM330DL(i2c)
139+ config.apply_accelerometer_calibration(imu)
140+ ```
141+
142+ ---
143+
121144# JSON Format
122145
123146Data is stored as compact JSON to fit within 1 KB:
124147
125148``` json
126- {"rev" :3 ,"name" :" STeaMi-01" ,"tc" :{"hts" :{"g" :1.0 ,"o" :-0.5 }},"cm" :{"hx" :12.3 ,"hy" :-5.1 ,"hz" :0.8 ,"sx" :1.01 ,"sy" :0.98 ,"sz" :1.0 }}
149+ {"rev" :3 ,"name" :" STeaMi-01" ,"tc" :{"hts" :{"g" :1.0 ,"o" :-0.5 }},"cm" :{"hx" :12.3 ,"hy" :-5.1 ,"hz" :0.8 ,"sx" :1.01 ,"sy" :0.98 ,"sz" :1.0 }, "cal_accel" :{ "ox" : 0.01 , "oy" : -0.02 , "oz" : 0.03 } }
127150```
128151
129152| Key | Content |
@@ -136,6 +159,8 @@ Data is stored as compact JSON to fit within 1 KB:
136159| ` cm ` | Magnetometer calibration dict |
137160| ` cm.hx/hy/hz ` | Hard-iron offsets (X, Y, Z) |
138161| ` cm.sx/sy/sz ` | Soft-iron scale factors (X, Y, Z) |
162+ | ` cal_accel ` | Accelerometer calibration dict |
163+ | ` cal_accel.ox/oy/oz ` | Bias offsets in g (X, Y, Z) |
139164
140165Sensor short keys: ` hts ` (HTS221), ` mag ` (LIS2MDL), ` ism ` (ISM330DL),
141166` hid ` (WSEN-HIDS), ` pad ` (WSEN-PADS).
@@ -149,6 +174,7 @@ Sensor short keys: `hts` (HTS221), `mag` (LIS2MDL), `ism` (ISM330DL),
149174| ` show_config.py ` | Display current board configuration |
150175| ` calibrate_temperature.py ` | Calibrate all sensors against WSEN-HIDS reference |
151176| ` calibrate_magnetometer.py ` | Calibrate LIS2MDL with OLED display and persistent storage |
177+ | ` calibrate_accelerometer.py ` | Calibrate ISM330DL accelerometer bias and persist it |
152178
153179Run with mpremote:
154180
0 commit comments