icm20948
Add-On Required: This feature requires the MATLAB Support Package for Raspberry Pi Hardware add-on.
Description
The icm20948
object reads acceleration, angular velocity, magnetic field,
and temperature using the TDK ICM-20948 sensor. The ICM-20948 is a 9 degree of freedom (DOF)
inertial measurement unit (IMU) used to read acceleration, angular velocity, and magnetic
field in all three dimensions.
The icm20948
object represents a connection to the sensor on the
Raspberry Pi® hardware I2C bus. Attach an ICM-20948 sensor to the I2C pins on the Raspberry Pi hardware. You can read the data from your sensor in MATLAB®using the object functions.
Before you use the icm20948
object, create a Raspberry Pi object using raspi
and set its properties as mentioned in
raspi
.
Creation
Description
creates a sensor object with default property values. The object represents the connection
to the sensor on the Raspberry Pi hardware, imu
= icm20948(mypi
)mypi
.
creates a sensor object with properties using one or more imu
= icm20948(r
,Name,Value
)Name,Value
pair arguments.
Input Arguments
Usage
Create Connection to ICM-20948 Sensor
Ensure that the I2C interface on the Raspberry Pi kernel is enabled and then create an icm20948
sensor
object.
You can enable the I2C interface using:
Raspberry Pi Kernel I2C Interfacing options on Linux terminal. For more information, see Enable I2C Interface on Raspberry Pi Hardware Kernel or
Raspberry Pi Resource Monitor App. For more information, see Enabling External Peripherals on Raspberry Pi Hardware Kernel.
Create a connection from MATLAB to the Raspberry Pi hardware board.
mypi = raspi('raspberrypi-hysdu8X38o','rocky','bullwinkle')
mypi = Raspi with Properties: DeviceAddress: 'raspberrypi-hysdu8X38o' Port: 18734 BoardName: 'Raspberry Pi 3 Model B+' AvailableLEDs: {'led0'} AvailableDigitalPins: [4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27] AvailableSPIChannels: {‘CE0’,’CE1’} AvailableI2CBuses: {'i2c-1'} I2CBusSpeed: 100000 AvailabelWebCams: mmal service 16.1 (platform:bcm2835-v4l2)
Get the addresses of the ICM-20948 sensor connected to the I2C bus
'i2c-1'
.
sensor = scanI2CBus(mypi,'i2c-1');
ans = 1×2 cell array {'0x69'} {'0xC'}
Create an icm20948
sensor object on the I2C bus
'i2c-1'
on address {'0x69','0xC'}
.
sensor = icm20948(mypi,'Bus','i2c-1','I2CAddress',{'0x69','0xC'});
sensor = icm20948 with properties: I2CAddress: 105 ("0x69") : 12 ("0xC") Bus: i2c-1
Object Functions
readAcceleration | Read one sample of acceleration from sensor |
readAngularVelocity | Read one sample of angular velocity from sensor |
readTemperature | Read one sample of temperature from sensor |
readMagneticField | Read one sample of magnetic field from sensor |
Extended Capabilities
Version History
Introduced in R2023a
See Also
readAcceleration
| readAngularVelocity
| readTemperature
| readMagneticField