Wiring the TLV493D is easy, since it only requires power and two wires for an I2C connection. Additionally, the STEMMA QT connectors give you additional solderless options for wiring:
- Connect board VCC (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
- Connect board GND (black wire) to Arduino GND
- Connect board SCL (yellow wire) to Arduino SCL
- Connect board SDA (blue wire) to Arduino SDA
Arduino Library Installation
Fortunately Infineon have written a library for you for the TLV493D which you can install using the Arduino IDE's Library Manager:
Click the Manage Libraries ... menu item, search for Xensiv TLx493D and install it. Make sure to avoid the deprecated versions that might appear with similar names.
Xensiv / Infineon Examples
There are a few examples, but which read the X, Y, and Z axis measurements in milli-teslas (mT).
You can see the examples by navigating to the appropriate spot in the File --> Examples --> XENSIV 3D submenu. To get started quickly here is a simple variation on the read_iic_sensor.
Many Adafruit boards have two I2C buses. You might need to change Wire to Wire1.
The code below is the example read_iic_sensor from the Arduino IDE Examples -> XENSIV 3D Magnetic Sensor TLx493D. The examples are available after you load the library as shown above.
/** Project CPP includes. */
#include "TLx493D_inc.hpp"
using namespace ifx::tlx493d;
/* Definition of the power pin and sensor objects for Kit2Go XMC1100 boards. */
// const uint8_t POWER_PIN = 15; // XMC1100 : LED2
// TLx493D_A1B6 dut(Wire, TLx493D_IIC_ADDR_A0_e);
// TLx493D_A2B6 dut(Wire, TLx493D_IIC_ADDR_A0_e);
// TLx493D_P2B6 dut(Wire, TLx493D_IIC_ADDR_A0_e);
// TLx493D_W2B6 dut(Wire, TLx493D_IIC_ADDR_A0_e);
/** Definition of the power pin and sensor objects for S2Go with XMC4700 Relax Lite board. */
// const uint8_t POWER_PIN = 8; // XMC : P1.10
// TLx493D_A1B6 dut(Wire, TLx493D_IIC_ADDR_A0_e);
// TLx493D_A2BW dut(Wire, TLx493D_IIC_ADDR_A0_e);
// TLx493D_W2B6 dut(Wire, TLx493D_IIC_ADDR_A0_e);
// TLx493D_W2BW dut(Wire, TLx493D_IIC_ADDR_A0_e);
/** P3XX evaluation board */
const uint8_t POWER_PIN = 8;
TLx493D_P3B6 dut(Wire, TLx493D_IIC_ADDR_A0_e);
/** Definition of the power pin and sensor objects for Arduino Uno boards */
/** Care must be taken to level shift down to 3.3V as the sensor boards expect only 3.3V ! */
/** Therefore disabled here. */
// const uint8_t POWER_PIN = 7;
// TLx493D_W2B6 dut(Wire, TLx493D_IIC_ADDR_A0_e);
// TLx493D_W2BW dut(Wire, TLx493D_IIC_ADDR_A0_e);
/** Definition of a counter variable. */
uint8_t count = 0;
void setup() {
Serial.begin(115200);
delay(3000);
/** Definition of the power pin to power up the sensor. */
/** Set delay after power-on to 50 for A1B6 Kit2Go sensor. */
/** All other Kit2Go boards */
// dut.setPowerPin(POWER_PIN, OUTPUT, INPUT, HIGH, LOW, 0, 250000);
/** P3XX evaluation board */
dut.setPowerPin(POWER_PIN, OUTPUT, INPUT, LOW, HIGH, 1000, 250000);
dut.begin();
Serial.print("setup done.\n");
}
/** In the loop we continuously reading the temperature value as well as the
* magnetic values in X, Y, Z-direction of the sensor and printing them to
* the serial monitor
*/
void loop() {
double t, x, y, z;
dut.setSensitivity(TLx493D_FULL_RANGE_e);
Serial.print(true == dut.getMagneticFieldAndTemperature(&x, &y, &z, &t) ? "getMagneticFieldAndTemperature ok\n" : "getMagneticFieldAndTemperature error\n");
dut.printRegisters();
Serial.print("\nTemperature is: ");
Serial.print(t);
Serial.println("°C");
Serial.print("Value X is: ");
Serial.print(x);
Serial.println(" mT");
Serial.print("Value Y is: ");
Serial.print(y);
Serial.println(" mT");
Serial.print("Value Z is: ");
Serial.print(z);
Serial.println(" mT");
dut.setSensitivity(TLx493D_SHORT_RANGE_e);
Serial.print(true == dut.getMagneticFieldAndTemperature(&x, &y, &z, &t) ? "getMagneticFieldAndTemperature ok\n" : "getMagneticFieldAndTemperature error\n");
dut.printRegisters();
Serial.print("\nTemperature is: ");
Serial.print(t);
Serial.println("°C");
Serial.print("Value X is: ");
Serial.print(x);
Serial.println(" mT");
Serial.print("Value Y is: ");
Serial.print(y);
Serial.println(" mT");
Serial.print("Value Z is: ");
Serial.print(z);
Serial.println(" mT");
Serial.print("\n\n\n\n");
delay(1000);
Serial.print("count : ");
Serial.println(count);
if( ++count == 4 ) {
Serial.println("\nBefore reset -------------------------------------------------------------------------------------------------------");
/** Reset does not work for W2BW : either drive strength too low or delay to stabilize critical. */
dut.reset(true, dut.getSensorType() != TLx493D_A1B6_e);
Serial.println("\nAfter reset -------------------------------------------------------------------------------------------------------");
count = 0;
}
}
Once you compile and upload the example to your Arduino compatible board of choice, open the serial monitor, verify that your baud rate setting matches the example, and you should see measurements for the three axes being printed. If you wave a magnet near the sensor you can see the values changing!
Page last edited October 29, 2025
Text editor powered by tinymce.