QMagnetometerReading#

The QMagnetometerReading class represents one reading from the magnetometer. More

Inheritance diagram of PySide6.QtSensors.QMagnetometerReading

Synopsis#

Properties#

  • calibrationLevel - The accuracy of the reading

  • x - The raw magnetic flux density on the X axis

  • y - The raw magnetic flux density on the Y axis

  • z - The raw magnetic flux density on the Z axis

Functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

QMagnetometerReading Units#

The magnetometer returns magnetic flux density values along 3 axes. The scale of the values is teslas. The axes are arranged as follows.

../../_images/sensors-coordinates2.jpg

The magnetometer can report on either raw magnetic flux values or geomagnetic flux values. By default it returns raw magnetic flux values. The returnGeoValues property must be set to return geomagnetic flux values.

The primary difference between raw and geomagnetic values is that extra processing is done to eliminate local magnetic interference from the geomagnetic values so they represent only the effect of the Earth’s magnetic field. This process is not perfect and the accuracy of each reading may change.

The image below shows the difference between geomagnetic (on the left) and raw (on the right) readings for a phone that is being subjected to magnetic interference.

../../_images/sensors-geo-vs-raw-magnetism.jpg

The accuracy of each reading is measured as a number from 0 to 1. A value of 1 is the highest level that the device can support and 0 is the worst.

Calibration#

If the device is reporting low accuracy, then calibration might be needed before acceptable measurements can be provided. Basic calibration can usually be done by either rotating your device in a figure of eight, or by rotating the device along each of its three axes. For more information, check your device’s documentation on how to calibrate the magnetic sensor.

class PySide6.QtSensors.QMagnetometerReading(parent)#
Parameters:

parentPySide6.QtCore.QObject

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property PᅟySide6.QtSensors.QMagnetometerReading.calibrationLevel: float#

This property holds the accuracy of the reading..

Measured as a value from 0 to 1 with higher values being better.

Note that this only changes when measuring geomagnetic flux density. Raw magnetic flux readings will always have a value of 1.

See also

QMagnetometerReading Units Calibration

Access functions:
property PᅟySide6.QtSensors.QMagnetometerReading.x: float#

This property holds the raw magnetic flux density on the X axis..

Measured as teslas.

See also

QMagnetometerReading Units

Access functions:
  • x ()

property PᅟySide6.QtSensors.QMagnetometerReading.y: float#

This property holds the raw magnetic flux density on the Y axis..

Measured as teslas.

See also

QMagnetometerReading Units

Access functions:
  • y ()

property PᅟySide6.QtSensors.QMagnetometerReading.z: float#

This property holds the raw magnetic flux density on the Z axis..

Measured as teslas.

See also

QMagnetometerReading Units

Access functions:
  • z ()

PySide6.QtSensors.QMagnetometerReading.calibrationLevel()#
Return type:

float

Getter of property calibrationLevel .

PySide6.QtSensors.QMagnetometerReading.setCalibrationLevel(calibrationLevel)#
Parameters:

calibrationLevel – float

Sets the accuracy of the reading to calibrationLevel.

PySide6.QtSensors.QMagnetometerReading.setX(x)#
Parameters:

x – float

Sets the raw magnetic flux density on the X axis to x.

See also

x()

PySide6.QtSensors.QMagnetometerReading.setY(y)#
Parameters:

y – float

Sets the raw magnetic flux density on the Y axis to y.

See also

y()

PySide6.QtSensors.QMagnetometerReading.setZ(z)#
Parameters:

z – float

Sets the raw magnetic flux density on the Z axis to z.

See also

z()

PySide6.QtSensors.QMagnetometerReading.x()#
Return type:

float

See also

setX()

Getter of property x .

PySide6.QtSensors.QMagnetometerReading.y()#
Return type:

float

See also

setY()

Getter of property y .

PySide6.QtSensors.QMagnetometerReading.z()#
Return type:

float

See also

setZ()

Getter of property z .