Main Content

readMagneticField

Read the magnetic field measured by the Magnetometer along the x, y and z axis

Add-On Required: This feature requires the MATLAB Support Package for Raspberry Pi Hardware add-on.

Description

example

magField = readMagneticField(mysh) returns the magnetic field measured by the Magnetometer along the x, y, and the z axes.

The unit of measurement for the Magnetometer raw data is microtesla (µT).

example

[magField,Ts] = readMagneticField(mysh) returns the magnetic field measured by the Magnetometer along the x, y, and the z axes with timestamp. The unit of measurement for the Magnetometer field is microtesla (µT).

example

magFieldRaw = readMagneticField(mysh,raw) returns the magnetic field measured by the Magnetometer along the x, y, and the z axes. The ‘raw’ argument is to specify that the output should be uncalibrated raw data.

example

[magFieldRaw,Ts]= readMagneticField(mysh,raw) returns the magnetic field measured by the Magnetometer along the x, y, and the z axes with timestamp. The ‘raw’ argument is to specify that the output should be uncalibrated raw data.

The full scale range for the Magnetometer is +/- 4 gauss.

Sense HAT IMU sensor axis information is shown below.

Examples

collapse all

To read the magnetic field along the x, y, and the z axis.

magField = readMagneticField(mysh) 
magField =  

      -0.3045    0.2769   10.0417 

Read the magnetic field measured by the Magnetometer along the x, y, and the z axis.

To read the magnetic field along the x, y, and the z axes measured by the Magnetometer along with the time stamp at which the data was read.

[magField,ts] = readMagneticField(mysh)  
magField= 

 -0.1847    0.5511    0.1847 

ts =  

   09-Aug-2016 15:37:19  

Read the magnetic field measured by the Magnetometer along the x, y, and the z axis with timestamp.

To read raw uncalibrated magnetic field along the x, y, and the z axis.

magFieldRaw = readMagneticField(mysensehat,'raw')
magFieldRaw = 

         865       -1189        2002 

Read the raw uncalibrated magnetic field value measured by the Magnetometer along the x, y, and the z axis.

To read raw uncalibrated magnetic field along the x, y, and the z axis.

[magFieldRaw,ts] = readMagneticField(mysensehat,'raw') 
magFieldRaw= 

         865       -1189        2002 

ts = 

  09-Aug-2016 15:37:19 
 

Read the raw uncalibrated magnetic field value measured by the Magnetometer along the x, y, and the z axis with the timestamp.

Input Arguments

collapse all

Connection to a SenseHAT board, specified as a sensehat object.

Argument to specify that the output should be uncalibrated raw data.

Output Arguments

collapse all

The magnetic field measured by the Magnetometer along the x,y, and z axes. This is a 1x3 double data. The unit of measurement for the Magnetometer data is microtesla (µT).

Extended Capabilities

Version History

Introduced in R2016b