Basic Example
Description
Once the Arduino library has been installed, the Example1_BasicReadings.ino
example file can be accessed from the File > Examples > SparkFun TMAG5273 Arduino Library > Example1_BasicReadings drop-down menu. This example reads the raw magnetic flux (mT) and temperature (°C) data from the TMAG5273 sensor through the I2C interface and displays them in the Serial Monitor.
Example1_BasicReadings.ino
Code Verification
This code was last verified to be functional under the following parameters:
Hardware Connections
For this example, users simply need to connect their Qwiic Hall-Effect Sensor board to their microcontroller, utilizing the I2C interface. With the recommended hardware, users can easily connect their boards with the Qwiic connection system.
Pin Connections
For users with a development board without a Qwiic connector, the table below illustrates the required pin connections. Make sure that the logic-level of the sensor is compatible with the development board that is being connected.
Sensor Pin | Microcontroller Pin | RedBoard/Uno |
---|---|---|
SCL |
I2C - Serial Clock | SCL /A5 |
SDA |
I2C - Serial Data | SDA /A4 |
3V3 |
Power: 1.7 to 3.6V | 3.3V |
GND |
Ground | GND |
Serial Monitor
This example reads the magnetic flux (mT) and temperature values (°C) from the TMAG5273 sensor and displays them in the Serial Monitor.
The magnetic flux (mT) and temperature (°C) values streamed from the TMAG5273 sensor into the Serial Monitor.
Tip
For this example to work, users will need to move a magnet near the sensor.
Warning
The casing of rare Earth magnets is often conductive. Users should take precautions to avoid shorting out the components or electrical contacts with these types of magnets.