32#ifdef ARDUINO_T_BEAM_S3_SUPREME
33#include <XPowersAXP2101.tpp>
48#if defined(ARDUINO_T_BEAM_S3_SUPREME)
50 power.
begin(Wire1, AXP2101_SLAVE_ADDRESS, 42, 41);
54 power.setALDO1Voltage(3300);
56 power.setALDO2Voltage(3300);
71 Serial.println(
"Failed to find QMC6309 - check your wiring!");
77 int16_t x_result = 0, y_result = 0, z_result = 0;
79 Serial.print(
"Self-test ");
80 Serial.println(self_test_result ?
"passed" :
"failed");
81 Serial.print(
"X-axis: "); Serial.println(x_result);
82 Serial.print(
"Y-axis: "); Serial.println(y_result);
83 Serial.print(
"Z-axis: "); Serial.println(z_result);
88 float data_rate_hz = 200.0f;
104 down_sample_ratio)) {
105 Serial.println(
"Magnetometer configured successfully.");
107 Serial.println(
"Magnetometer configuration failed.");
112 Serial.print(
"Manufacturer: "); Serial.println(info.
manufacturer);
113 Serial.print(
"Model: "); Serial.println(info.
model);
114 Serial.print(
"I2C Address: 0x"); Serial.println(info.
i2c_address, HEX);
115 Serial.print(
"Version: "); Serial.println(info.
version);
116 Serial.print(
"UID: 0x"); Serial.println(info.
uid);
120 Serial.print(
"DataRate: "); Serial.println(cfg.
sample_rate);
121 Serial.print(
"FullScaleRange: "); Serial.println(cfg.
range);
122 Serial.print(
"Mode: "); Serial.println((uint8_t)cfg.
mode);
130 Serial.print(
" Magnetic Declination: ");
131 Serial.print(declination_deg, 2);
134 Serial.print(
" Sensitivity: ");
136 Serial.println(
" Gauss/LSB");
140 Serial.println(
"Read data now...");
155 Serial.print(
"Mag:");
156 Serial.print(
" X:"); Serial.print(
x);
157 Serial.print(
" Y:"); Serial.print(
y);
158 Serial.print(
" Z:"); Serial.print(z);
161 Serial.print(
" Metadata:");
163 Serial.print(data.
raw.
x);
165 Serial.print(data.
raw.
y);
167 Serial.print(data.
raw.
z);
169 Serial.print(
" Heading (rad): ");
171 Serial.print(
" rad");
173 Serial.print(
" Heading (deg): ");
179 Serial.print(
" Magnetic Strength: ");
180 Serial.print(strength, 2);
181 Serial.println(
" μT");
184 Serial.println(
"\tWarning: Data Overflow occurred!");
OperationMode
Enumeration of sensor operation modes.
MagFullScaleRange
Enumeration defining full-scale range settings for the sensor.
MagDownSampleRatio
Enumeration defining down-sample ratios for the sensor.
@ DSR_1
1x down-sample ratio
MagOverSampleRatio
Enumeration defining over-sample ratios for the sensor.
@ OSR_1
1x over-sample ratio
bool begin(SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize the sensor using custom callback interface.
virtual void setDeclination(float declination_deg)
Set the magnetic declination correction value.
virtual SensorConfig getConfig() const
Get current sensor configuration.
float getSensitivity() const
Get sensor sensitivity.
SensorInfo getSensorInfo() const
Get sensor information.
bool configMagnetometer(OperationMode mode, MagFullScaleRange range, float data_rate_hz, MagOverSampleRatio osr, MagDownSampleRatio dsr=MagDownSampleRatio::DSR_1) override
Configures the magnetometer with multiple parameters.
bool readData(MagnetometerData &data) override
Reads the magnetic field data from the sensor.
bool selfTest() override
Checks if the sensor is functioning correctly.
static const char * typeToString(SensorType type)
Convert sensor type enumeration to string representation.
float dmsToDecimalDegrees(int degrees, int minutes, float seconds=0.0f)
Convert degrees-minutes-seconds to decimal degrees.
float calculateMagneticStrength(const MagnetometerData &data)
Calculate total magnetic field strength.
float gaussToMicroTesla(float gauss)
Converts Gauss to microTesla.
SensorQMC6309 magnetometer
Structure representing magnetometer data.
float heading_degrees
heading angle (degrees)
float heading
heading angle (radians)
SensorVector magnetic_field
magnetic field strength (Gauss)
bool overflow
data overflow flag
int16_t x
X-axis raw value.
int16_t y
Y-axis raw value.
int16_t z
Z-axis raw value.
Structure representing sensor configuration parameters.
float sample_rate
Sample rate in Hz.
float range
Measurement range.
OperationMode mode
Operation mode.
Structure containing sensor identification information.
uint8_t version
Hardware/firmware version.
uint8_t i2c_address
Default I2C address.
uint32_t uid
Unique identifier.
SensorType type
Sensor type.
const char * manufacturer
Manufacturer name.
const char * model
Model name/identifier.