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.
/** 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 // some board swith multiple I2C need Wire --> Wire1 TLx493D_A1B6 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. */ dut.setPowerPin(POWER_PIN, OUTPUT, INPUT, HIGH, LOW, 0, 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.getMagneticFieldAndTemperature(&x, &y, &z, &t); 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("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 January 27, 2025
Text editor powered by tinymce.